Running on a remote host #43

Closed
OnkelTem opened this Issue Apr 11, 2012 · 6 comments

Comments

Projects
None yet
3 participants

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.

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);
Owner

NV commented Apr 11, 2012

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 May 4, 2012

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

Owner

NV commented May 4, 2012

Yes, you can mount SSH drive locally.

Adrian-S commented May 5, 2012

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.

Owner

NV commented May 7, 2012

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

@NV NV closed this Jun 9, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment