Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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 0.0.0 to 0.0.1

README.md

11

client.js

@@ -10,3 +10,3 @@ // builtin

.options('host', {
default: 'http://lt.defunctzombie.com',
default: 'http://localtunnel.me',
describe: 'upstream server providing forwarding'

@@ -31,8 +31,11 @@ })

opt.uri = 'http://' + opt.host + ':' + opt.port + opt.path;
var base_uri = 'http://' + opt.host + ':' + opt.port + opt.path;
var internal;
var upstream;
var prev_id;
(function connect_proxy() {
opt.uri = base_uri + ((prev_id) ? prev_id : '?new');
request(opt, function(err, res, body) {

@@ -48,2 +51,5 @@ if (err) {

// store the id so we can try to get the same one
prev_id = body.id;
console.log('your url is: %s', body.url);

@@ -58,2 +64,3 @@

upstream.on('end', function() {
console.log('> upstream connection terminated');

@@ -60,0 +67,0 @@ // sever connection to internal server

4

package.json

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

"description": "expose localhost to the world",
"version": "0.0.0",
"version": "0.0.1",
"repository": {

@@ -12,3 +12,3 @@ "type": "git",

"dependencies": {
"request": "2.9.202",
"request": "2.11.4",
"book": "1.2.0",

@@ -15,0 +15,0 @@ "optimist": "0.3.4"

@@ -5,4 +5,18 @@

var net = require('net');
var url = require('url');
var FreeList = require('freelist').FreeList;
var argv = require('optimist')
.usage('Usage: $0 --port [num]')
.options('port', {
default: '80',
describe: 'listen on this port for outside requests'
})
.argv;
if (argv.help) {
require('optimist').showHelp();
process.exit();
}
// here be dragons

@@ -94,3 +108,2 @@ var HTTPParser = process.binding('http_parser').HTTPParser;

//var parser = new HTTPParser(HTTPParser.REQUEST);
var parser = parsers.alloc();

@@ -110,2 +123,18 @@ parser.socket = socket;

var hostname = req.headers.host;
if (!hostname) {
log.trace('no hostname: %j', req.headers);
// normal processing if not proxy
var res = new ServerResponse(req);
// TODO(shtylman) skip favicon for now, it caused problems
if (req.url === '/favicon.ico') {
return;
}
res.assignSocket(parser.socket);
self.emit('request', req, res);
return;
}
var match = hostname.match(/^([a-z]{4})[.].*/);

@@ -236,6 +265,35 @@

// generate new shit for client
var id = rand_id();
// ignore favicon
if (req.url === '/favicon.ico') {
res.writeHead(404);
return res.end();
}
var parsed = url.parse(req.url, true);
// redirect main page to github reference
if (req.url === '/' && !parsed.query.new) {
res.writeHead(301, { Location: 'http://shtylman.github.com/localtunnel/' });
res.end();
}
var match = req.url.match(/\/([a-z]{4})?/);
// user can request a particular set of characters
// will be given if not already taken
// this is useful when the main server is restarted
// users can keep testing with their expected ids
var requested_id;
if (match && match[1]) {
requested_id = match[1];
}
var id = requested_id || rand_id();
if (wait_list[id]) {
// new id
id = rand_id();
}
// generate new shit for client
if (wait_list[id]) {
wait_list[id].forEach(function(waiting) {

@@ -254,3 +312,3 @@ waiting.end();

res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ url: url, port: port }));
res.end(JSON.stringify({ url: url, id: id, port: port }));
});

@@ -287,3 +345,5 @@

server.listen(8000);
server.listen(argv.port, function() {
log.info('server listening on port: %d', server.address().port);
});
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