mirror of
https://github.com/bitinflow/localtunnel.git
synced 2026-03-13 21:45:54 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
afbdc3697e | ||
|
|
0049f21b55 | ||
|
|
509841104b | ||
|
|
92caf2f204 |
@@ -27,14 +27,13 @@ var opt = {
|
||||
|
||||
lt_client(opt.port, opt, function(err, tunnel) {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
return process.exit(1);
|
||||
throw err;
|
||||
}
|
||||
|
||||
console.log('your url is: %s', tunnel.url);
|
||||
|
||||
tunnel.on('error', function(err) {
|
||||
console.error(err);
|
||||
throw err;
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
15
client.js
15
client.js
@@ -87,13 +87,13 @@ TunnelCluster.prototype.open = function() {
|
||||
});
|
||||
|
||||
function conn_local() {
|
||||
debug('connecting locally to %s:%d', local_host, local_port);
|
||||
|
||||
if (remote.destroyed) {
|
||||
debug('remote destroyed');
|
||||
self.emit('dead');
|
||||
return;
|
||||
}
|
||||
|
||||
debug('connecting locally to %s:%d', local_host, local_port);
|
||||
remote.pause();
|
||||
|
||||
// connection to local http server
|
||||
@@ -103,19 +103,24 @@ TunnelCluster.prototype.open = function() {
|
||||
});
|
||||
|
||||
function remote_close() {
|
||||
debug('remote close');
|
||||
self.emit('dead');
|
||||
local.end();
|
||||
};
|
||||
|
||||
remote.once('close', remote_close);
|
||||
|
||||
local.on('error', function(err) {
|
||||
// TODO some languages have single threaded servers which makes opening up
|
||||
// multiple local connections impossible. We need a smarter way to scale
|
||||
// and adjust for such instances to avoid beating on the door of the server
|
||||
local.once('error', function(err) {
|
||||
debug('local error %s', err.message);
|
||||
local.end();
|
||||
|
||||
remote.removeListener('close', remote_close);
|
||||
|
||||
if (err.code !== 'ECONNREFUSED') {
|
||||
return local.emit('error', err);
|
||||
return remove.end();
|
||||
}
|
||||
|
||||
// retrying connection to local server
|
||||
@@ -146,8 +151,8 @@ TunnelCluster.prototype.open = function() {
|
||||
// tunnel is considered open when remote connects
|
||||
remote.once('connect', function() {
|
||||
self.emit('open', remote);
|
||||
conn_local();
|
||||
});
|
||||
remote.once('connect', conn_local);
|
||||
};
|
||||
|
||||
var Tunnel = function(opt) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"author": "Roman Shtylman <shtylman@gmail.com>",
|
||||
"name": "localtunnel",
|
||||
"description": "expose localhost to the world",
|
||||
"version": "1.1.0",
|
||||
"version": "1.1.1",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/shtylman/localtunnel.git"
|
||||
|
||||
Reference in New Issue
Block a user