localtunnel
Advanced tools
Comparing version 1.8.3 to 1.9.0
@@ -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 @@ |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
28286
101
0
3
12
431
+ Addedaxios@0.17.1
+ Addedaxios@0.17.1(transitive)
+ Addedcamelcase@3.0.0(transitive)
+ Addederror-ex@1.3.2(transitive)
+ Addedfind-up@1.1.2(transitive)
+ Addedfollow-redirects@1.15.9(transitive)
+ Addedget-caller-file@1.0.3(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedhosted-git-info@2.8.9(transitive)
+ Addedis-arrayish@0.2.1(transitive)
+ Addedis-buffer@1.1.6(transitive)
+ Addedis-core-module@2.15.1(transitive)
+ Addedis-utf8@0.2.1(transitive)
+ Addedload-json-file@1.1.0(transitive)
+ Addednormalize-package-data@2.5.0(transitive)
+ Addedparse-json@2.2.0(transitive)
+ Addedpath-exists@2.1.0(transitive)
+ Addedpath-parse@1.0.7(transitive)
+ Addedpath-type@1.1.0(transitive)
+ Addedpify@2.3.0(transitive)
+ Addedpinkie@2.0.4(transitive)
+ Addedpinkie-promise@2.0.1(transitive)
+ Addedread-pkg@1.1.0(transitive)
+ Addedread-pkg-up@1.0.1(transitive)
+ Addedrequire-directory@2.1.1(transitive)
+ Addedrequire-main-filename@1.0.1(transitive)
+ Addedresolve@1.22.8(transitive)
+ Addedsemver@5.7.2(transitive)
+ Addedset-blocking@2.0.0(transitive)
+ Addedspdx-correct@3.2.0(transitive)
+ Addedspdx-exceptions@2.5.0(transitive)
+ Addedspdx-expression-parse@3.0.1(transitive)
+ Addedspdx-license-ids@3.0.20(transitive)
+ Addedstrip-bom@2.0.0(transitive)
+ Addedsupports-preserve-symlinks-flag@1.0.0(transitive)
+ Addedvalidate-npm-package-license@3.0.4(transitive)
+ Addedwhich-module@1.0.0(transitive)
+ Addedyargs@6.6.0(transitive)
+ Addedyargs-parser@4.2.1(transitive)
- Removedrequest@2.81.0
- Removedajv@4.11.8(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@0.2.01.0.0(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaws-sign2@0.6.0(transitive)
- Removedaws4@1.13.2(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedboom@2.10.1(transitive)
- Removedcall-bind@1.0.7(transitive)
- Removedcamelcase@1.2.1(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedco@4.6.0(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcore-util-is@1.0.2(transitive)
- Removedcryptiles@2.0.5(transitive)
- Removeddashdash@1.14.1(transitive)
- Removeddefine-data-property@1.1.4(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removedes-define-property@1.0.0(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.1.4(transitive)
- Removedget-intrinsic@1.2.4(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedgopd@1.0.1(transitive)
- Removedhar-schema@1.0.5(transitive)
- Removedhar-validator@4.2.1(transitive)
- Removedhas-property-descriptors@1.0.2(transitive)
- Removedhas-proto@1.0.3(transitive)
- Removedhas-symbols@1.0.3(transitive)
- Removedhawk@3.1.3(transitive)
- Removedhoek@2.16.3(transitive)
- Removedhttp-signature@1.1.1(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedisarray@2.0.5(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-stable-stringify@1.1.1(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsonify@0.0.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedoauth-sign@0.8.2(transitive)
- Removedobject-keys@1.1.1(transitive)
- Removedperformance-now@0.2.0(transitive)
- Removedpunycode@1.4.1(transitive)
- Removedqs@6.4.1(transitive)
- Removedrequest@2.81.0(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedset-function-length@1.2.2(transitive)
- Removedsntp@1.0.9(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedstringstream@0.0.6(transitive)
- Removedtough-cookie@2.3.4(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtweetnacl@0.14.5(transitive)
- Removeduuid@3.4.0(transitive)
- Removedverror@1.10.0(transitive)
- Removedwindow-size@0.1.4(transitive)
- Removedyargs@3.29.0(transitive)
Updatedyargs@6.6.0