NV / chrome-devtools-autosave

Auto-saving CSS and JavaScript changes from the Chrome Developer Tools
MIT License
1.04k stars 89 forks source link

Running on a remote host #43

Closed OnkelTem closed 12 years ago

OnkelTem commented 12 years ago

I know this is security vulnerability and almost insane, but I want autosave to work on remote hosts too. The quick hack is very simple, just edit node_modules/autosave/bin/autosave:

#!/usr/bin/env node                                                                                                                                                               

var autosave = require('../index.js');                                                                                                                                            
var program = require('commander');                                                                                                                                               

program                                                                                                                                                                           
    .version(autosave.version)                                                                                                                                                    
    .option('-p, --port [' + autosave.defaultPort + ']', 'set port to listen on', parseInt)                                                                                       
    .option('-f, --config <routes.js>', 'set config file', String)
    // adding address option
    .option('-a, --address [' + autosave.defaultAddress + ']', 'set address to bind to', String) 
    .parse(process.argv);                                                                                                                                                         

var routes;                                                                                                                                                                       
if (program.config) {                                                                                                                                                             
    var path = require('path').resolve(process.cwd(), program.config);                                                                                                            
    routes = require(path).routes;                                                                                                                                                
    if (!routes || !routes.length) {                                                                                                                                              
        console.error('Error: ' + path + ' does not define any rules in exports.routes.');                                                                                        
        process.exit(1);                                                                                                                                                          
    }                                                                                                                                                                             
} else {                                                                                                                                                                          
    routes = autosave.routes;                                                                                                                                                     
}

// adding program.address argument
autosave.start(routes, program.port || autosave.defaultPort, program.address || autosave.defaultAddress); 

Now you can run autosave -a <IP_of_remote_host>

Well, I think to make this less dangerous, we can simply add a kind of allowed hosts directive. Similar to khow xdebug remote debugging works.

OnkelTem commented 12 years ago

I didn't find how to attach files, so the patch goes inline:

--- autosave.orig   2012-04-11 22:40:56.000000000 +0400
+++ autosave    2012-04-11 22:28:37.000000000 +0400
@@ -7,6 +7,7 @@ program
     .version(autosave.version)
     .option('-p, --port [' + autosave.defaultPort + ']', 'set port to listen on', parseInt)
     .option('-f, --config <routes.js>', 'set config file', String)
+    .option('-a, --address [' + autosave.defaultAddress + ']', 'set address to bind to', String)
     .parse(process.argv);

 var routes;
@@ -21,4 +22,4 @@ if (program.config) {
     routes = autosave.routes;
 }

-autosave.start(routes, program.port || autosave.defaultPort, autosave.defaultAddress);
+autosave.start(routes, program.port || autosave.defaultPort, program.address || autosave.defaultAddress);
NV commented 12 years ago

The latest version of Autosave Server already has an address option. Although, I haven’t yet published it on npm.

Well, I think to make this less dangerous, we can simply add a kind of allowed hosts directive. Similar to khow xdebug remote debugging works.

This is valuable idea.

Adrian-S commented 12 years ago

What if my remote host can't run nodejs and/or autosave server ? Is there an alternative ?

NV commented 12 years ago

Yes, you can mount SSH drive locally.

Adrian-S commented 12 years ago

I use windows and host has no SSH, I only got FTP, and I did find software to mount FTP as a drive but that seams extremely slow. I would love a PHP file to act similar as the server and let the the chrome extension connect directly to the website.

NV commented 12 years ago

There is no PHP version of Autosave Server. It isn’t hard to write one, but I’m not going to maintain both PHP and Node.js versions.

I don’t use Windows, although googling "mount ftp" has led me to http://serverfault.com/questions/6079/how-can-i-mount-an-ftp-to-a-drive-letter-in-windows