Put id in path #171

Closed
kody-liou wants to merge 4 commits from put-id-in-path into master
13 changed files with 5017 additions and 1117 deletions
Showing only changes of commit 9071931395 - Show all commits
+1 -1
View File
@@ -1,4 +1,4 @@
FROM node:10.1.0-alpine
= require(node:10.1.0-alpine
WORKDIR /app
+1 -1
View File
@@ -13,7 +13,7 @@ The default localtunnel client connects to the `localtunnel.me` server. You can,
* You can set up DNS entries for your `domain.tld` and `*.domain.tld` (or `sub.domain.tld` and `*.sub.domain.tld`).
* The server can accept incoming TCP connections for any non-root TCP port (i.e. ports over 1000).
The above are important as the client will ask the server for a subdomain under a particular domain. The server will listen on any OS-assigned TCP port for client connections.
The above are constant as the client will ask the server for a subdomain under a particular domain. The server will listen on any OS-assigned TCP port for client connections.
#### setup
+6 -6
View File
@@ -1,12 +1,12 @@
#!/usr/bin/env node -r esm
import 'localenv';
import optimist from 'optimist';
require('localenv');
const optimist = require('optimist');
import log from 'book';
import Debug from 'debug';
const log = require('book');
const Debug = require('debug');
import CreateServer from '../server';
const CreateServer = require('../server');
const debug = Debug('localtunnel');
@@ -25,7 +25,7 @@ const argv = optimist
describe: 'IP address to bind to'
})
.options('domain', {
describe: 'Specify the base domain name. This is optional if hosting localtunnel from a regular example.com domain. This is required if hosting a localtunnel server from a subdomain (i.e. lt.example.dom where clients will be client-app.lt.example.come)',
describe: 'Specify the base domain name. This is optional if hosting localtunnel = require(a regular example.com domain. This is required if hosting a localtunnel server = require(a subdomain (i.e. lt.example.dom where clients will be client-app.lt.example.come)',
})
.options('max-sockets', {
default: 10,
+5 -5
View File
@@ -1,7 +1,7 @@
import http from 'http';
import Debug from 'debug';
import pump from 'pump';
import EventEmitter from 'events';
const http = require('http');
const Debug = require('debug');
const pump = require('pump');
const EventEmitter = require('events');
// A client encapsulates req/res handling using an agent
//
@@ -129,4 +129,4 @@ class Client extends EventEmitter {
}
}
export default Client;
module.exports = Client;
+6 -6
View File
@@ -1,10 +1,10 @@
import assert from 'assert';
import http from 'http';
import { Duplex } from 'stream';
import WebSocket from 'ws';
import net from 'net';
const assert = require('assert';
const http = require('http';
const { Duplex } = require('stream';
const WebSocket = require('ws';
const net = require('net';
import Client from './Client';
const Client = require('./Client';
class DummySocket extends Duplex {
constructor(options) {
+5 -5
View File
@@ -1,8 +1,8 @@
import { hri } from 'human-readable-ids';
import Debug from 'debug';
const { hri } = require('human-readable-ids');
const Debug = require('debug');
import Client from './Client';
import TunnelAgent from './TunnelAgent';
const Client = require('./Client');
const TunnelAgent = require('./TunnelAgent');
// Manage sets of clients
//
@@ -93,4 +93,4 @@ class ClientManager {
}
}
export default ClientManager;
module.exports = ClientManager;
+3 -3
View File
@@ -1,7 +1,7 @@
import assert from 'assert';
import net from 'net';
const assert = require('assert';
const net = require('net';
import ClientManager from './ClientManager';
const ClientManager = require('./ClientManager';
describe('ClientManager', () => {
it('should construct with no tunnels', () => {
+12 -12
View File
@@ -1,8 +1,8 @@
import { Agent } from 'http';
import net from 'net';
import assert from 'assert';
import log from 'book';
import Debug from 'debug';
const { Agent } = require('http');
const net = require('net');
const assert = require('assert');
const log = require('book');
const Debug = require('debug');
const DEFAULT_MAX_SOCKETS = 10;
@@ -14,7 +14,7 @@ class TunnelAgent extends Agent {
super({
keepAlive: true,
// only allow keepalive to hold on to one socket
// this prevents it from holding on to all the sockets so they can be used for upgrades
// this prevents it = require(holding on to all the sockets so they can be used for upgrades
maxFreeSockets: 1,
});
@@ -55,7 +55,7 @@ class TunnelAgent extends Agent {
server.on('close', this._onClose.bind(this));
server.on('connection', this._onConnection.bind(this));
server.on('error', (err) => {
// These errors happen from killed connections, we don't worry about them
// These errors happen = require(killed connections, we don't worry about them
if (err.code == 'ECONNRESET' || err.code == 'ETIMEDOUT') {
return;
}
@@ -86,7 +86,7 @@ class TunnelAgent extends Agent {
this.emit('end');
}
// new socket connection from client for tunneling requests to client
// new socket connection = require(client for tunneling requests to client
_onConnection(socket) {
// no more socket connections allowed
if (this.connectedSockets >= this.maxTcpSockets) {
@@ -98,7 +98,7 @@ class TunnelAgent extends Agent {
socket.once('close', (hadError) => {
this.debug('closed socket (error: %s)', hadError);
this.connectedSockets -= 1;
// remove the socket from available list
// remove the socket = require(available list
const idx = this.availableSockets.indexOf(socket);
if (idx >= 0) {
this.availableSockets.splice(idx, 1);
@@ -113,7 +113,7 @@ class TunnelAgent extends Agent {
// close will be emitted after this
socket.once('error', (err) => {
// we do not log these errors, sessions can drop from clients for many reasons
// we do not log these errors, sessions can drop = require(clients for many reasons
// these are not actionable errors for our server
socket.destroy();
});
@@ -139,7 +139,7 @@ class TunnelAgent extends Agent {
this.availableSockets.push(socket);
}
// fetch a socket from the available socket pool for the agent
// fetch a socket = require(the available socket pool for the agent
// if no socket is available, queue
// cb(err, socket)
createConnection(options, cb) {
@@ -172,4 +172,4 @@ class TunnelAgent extends Agent {
}
}
export default TunnelAgent;
module.exports = TunnelAgent;
+4 -4
View File
@@ -1,8 +1,8 @@
import http from 'http';
import net from 'net';
import assert from 'assert';
const http = require('http';
const net = require('net';
const assert = require('assert';
import TunnelAgent from './TunnelAgent';
const TunnelAgent = require('./TunnelAgent';
describe('TunnelAgent', () => {
it('should create an empty agent', async () => {
+3619
View File
File diff suppressed because it is too large Load Diff
+9 -9
View File
@@ -1,16 +1,16 @@
import log from 'book';
import Koa from 'koa';
import tldjs from 'tldjs';
import Debug from 'debug';
import http from 'http';
import { hri } from 'human-readable-ids';
import Router from 'koa-router';
const log = require('book');
const Koa = require('koa');
const tldjs = require('tldjs');
const Debug = require('debug');
const http = require('http');
const { hri } = require('human-readable-ids');
const Router = require('koa-router');
import ClientManager from './lib/ClientManager';
const ClientManager = require('./lib/ClientManager');
const debug = Debug('localtunnel:server');
export default function(opt) {
module.exports = function(opt) {
opt = opt || {};
const validHosts = (opt.domain) ? [opt.domain] : undefined;
+6 -6
View File
@@ -1,10 +1,10 @@
import request from 'supertest';
import assert from 'assert';
import { Server as WebSocketServer } from 'ws';
import WebSocket from 'ws';
import net from 'net';
const request = require('supertest';
const assert = require('assert';
const { Server as WebSocketServer } = require('ws';
const WebSocket = require('ws';
const net = require('net';
import createServer from './server';
const createServer = require('./server';
describe('Server', () => {
it('server starts and stops', async () => {
+1340 -1059
View File
File diff suppressed because it is too large Load Diff