Files
localtunnel/bin/client
Linus Unnebäck 92caf2f204 lt: better error handling
Let node handle the displaying of error and setting exit code.
2014-04-14 21:15:11 +02:00

41 lines
920 B
JavaScript
Executable File

#!/usr/bin/env node
var lt_client = require('../client');
var argv = require('optimist')
.usage('Usage: $0 --port [num]')
.demand(['port'])
.options('host', {
default: 'http://localtunnel.me',
describe: 'upstream server providing forwarding'
})
.options('subdomain', {
describe: 'request this subdomain'
})
.options('local-host', {
describe: 'tunnel traffic to this host instead of localhost'
})
.default('local-host', 'localhost')
.describe('port', 'internal http server port')
.argv;
var opt = {
host: argv.host,
port: argv.port,
local_host: argv['local-host'],
subdomain: argv.subdomain,
}
lt_client(opt.port, opt, function(err, tunnel) {
if (err) {
throw err;
}
console.log('your url is: %s', tunnel.url);
tunnel.on('error', function(err) {
throw err;
});
});
// vim: ft=javascript