Socket
Socket
Sign inDemoInstall

localtunnel

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

localtunnel - npm Package Compare versions

Comparing version 1.8.3 to 1.9.0

LICENSE

6

History.md

@@ -0,1 +1,7 @@

# 1.9.0 (2018-04-03)
* Add _request_ event to Tunnel emitter
* Update yargs to support config via environment variables
* Add basic request logging when --print-requests argument is used
# 1.8.3 (2017-06-11)

@@ -2,0 +8,0 @@

37

lib/Tunnel.js
var url = require('url');
var EventEmitter = require('events').EventEmitter;
var request = require('request');
var axios = require('axios');
var debug = require('debug')('localtunnel:client');

@@ -29,4 +29,3 @@

var params = {
path: '/',
json: true
responseType: 'json'
};

@@ -43,22 +42,15 @@

// where to quest
params.uri = base_uri + ((assigned_domain) ? assigned_domain : '?new');
var uri = base_uri + ((assigned_domain) ? assigned_domain : '?new');
(function get_url() {
request(params, function(err, res, body) {
if (err) {
// TODO (shtylman) don't print to stdout?
console.log('tunnel server offline: ' + err.message + ', retry 1s');
return setTimeout(get_url, 1000);
}
if (res.statusCode !== 200) {
var err = new Error((body && body.message) || 'localtunnel server returned an error, please try again');
axios.get(uri, params)
.then(function(res){
var body = res.data;
if (res.status !== 200) {
var err = new Error((body && body.message) || 'localtunnel server returned an error, please try again');
return cb(err);
}
var port = body.port;
var host = upstream.hostname;
var max_conn = body.max_conn_count || 1;
cb(null, {

@@ -71,3 +63,8 @@ remote_host: upstream.hostname,

});
});
})
.catch(function(err){
// TODO (shtylman) don't print to stdout?
console.log('tunnel server offline: ' + err.message + ', retry 1s');
return setTimeout(get_url, 1000);
})
})();

@@ -79,3 +76,3 @@ };

var opt = self._opt;
// increase max event listeners so that localtunnel consumers don't get

@@ -133,2 +130,6 @@ // warning messages as soon as they setup even one listener. See #71

tunnels.on('request', function(info) {
self.emit('request', info);
});
// establish as many tunnels as allowed

@@ -135,0 +136,0 @@ for (var count = 0 ; count < info.max_conn ; ++count) {

@@ -116,2 +116,12 @@ var EventEmitter = require('events').EventEmitter;

remote.on('data', function(data) {
const match = data.toString().match(/^(\w+) (\S+)/);
if (match) {
self.emit('request', {
method: match[1],
path: match[2],
});
}
});
// tunnel is considered open when remote connects

@@ -118,0 +128,0 @@ remote.once('connect', function() {

@@ -5,3 +5,3 @@ {

"description": "expose localhost to the world",
"version": "1.8.3",
"version": "1.9.0",
"license": "MIT",

@@ -13,6 +13,6 @@ "repository": {

"dependencies": {
"request": "2.81.0",
"yargs": "3.29.0",
"axios": "0.17.1",
"debug": "2.6.8",
"openurl": "1.1.1"
"openurl": "1.1.1",
"yargs": "6.6.0"
},

@@ -29,2 +29,2 @@ "devDependencies": {

"main": "./client.js"
}
}

@@ -36,2 +36,8 @@ # localtunnel

You may also specify arguments via env variables. E.x.
```
PORT=3000 lt
```
## API ##

@@ -63,3 +69,3 @@

* `subdomain` A *string* value requesting a specific subdomain on the proxy server. **Note** You may not actually receive this name depending on availablily.
* `subdomain` A *string* value requesting a specific subdomain on the proxy server. **Note** You may not actually receive this name depending on availability.
* `local_host` Proxy to this hostname instead of `localhost`. This will also cause the `Host` header to be re-written to this value in proxied requests.

@@ -73,2 +79,3 @@

|----|----|----|
|request|info|fires when a request is processed by the tunnel, contains _method_ and _path_ fields|
|error|err|fires when an error happens on the tunnel|

@@ -89,2 +96,4 @@ |close||fires when the tunnel has closed|

*go* [go-localtunnel](https://github.com/localtunnel/go-localtunnel)
## server ##

@@ -91,0 +100,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc