Put id in path #171
+1
-1
@@ -1,4 +1,4 @@
|
||||
= require(node:10.1.0-alpine
|
||||
FROM node:10.1.0-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
|
||||
@@ -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 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.
|
||||
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.
|
||||
|
||||
#### setup
|
||||
|
||||
|
||||
+6
-6
@@ -1,12 +1,12 @@
|
||||
#!/usr/bin/env node -r esm
|
||||
|
||||
require('localenv');
|
||||
const optimist = require('optimist');
|
||||
import 'localenv';
|
||||
import optimist from 'optimist';
|
||||
|
||||
const log = require('book');
|
||||
const Debug = require('debug');
|
||||
import log from 'book';
|
||||
import Debug from 'debug';
|
||||
|
||||
const CreateServer = require('../server');
|
||||
import CreateServer from '../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 = 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)',
|
||||
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)',
|
||||
})
|
||||
.options('max-sockets', {
|
||||
default: 10,
|
||||
|
||||
+5
-5
@@ -1,7 +1,7 @@
|
||||
const http = require('http');
|
||||
const Debug = require('debug');
|
||||
const pump = require('pump');
|
||||
const EventEmitter = require('events');
|
||||
import http from 'http';
|
||||
import Debug from 'debug';
|
||||
import pump from 'pump';
|
||||
import EventEmitter from 'events';
|
||||
|
||||
// A client encapsulates req/res handling using an agent
|
||||
//
|
||||
@@ -129,4 +129,4 @@ class Client extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Client;
|
||||
export default Client;
|
||||
+6
-6
@@ -1,10 +1,10 @@
|
||||
const assert = require('assert';
|
||||
const http = require('http';
|
||||
const { Duplex } = require('stream';
|
||||
const WebSocket = require('ws';
|
||||
const net = require('net';
|
||||
import assert from 'assert';
|
||||
import http from 'http';
|
||||
import { Duplex } from 'stream';
|
||||
import WebSocket from 'ws';
|
||||
import net from 'net';
|
||||
|
||||
const Client = require('./Client';
|
||||
import Client from './Client';
|
||||
|
||||
class DummySocket extends Duplex {
|
||||
constructor(options) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
const { hri } = require('human-readable-ids');
|
||||
const Debug = require('debug');
|
||||
import { hri } from 'human-readable-ids';
|
||||
import Debug from 'debug';
|
||||
|
||||
const Client = require('./Client');
|
||||
const TunnelAgent = require('./TunnelAgent');
|
||||
import Client from './Client';
|
||||
import TunnelAgent from './TunnelAgent';
|
||||
|
||||
// Manage sets of clients
|
||||
//
|
||||
@@ -93,4 +93,4 @@ class ClientManager {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ClientManager;
|
||||
export default ClientManager;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const assert = require('assert';
|
||||
const net = require('net';
|
||||
import assert from 'assert';
|
||||
import net from 'net';
|
||||
|
||||
const ClientManager = require('./ClientManager';
|
||||
import ClientManager from './ClientManager';
|
||||
|
||||
describe('ClientManager', () => {
|
||||
it('should construct with no tunnels', () => {
|
||||
|
||||
+12
-12
@@ -1,8 +1,8 @@
|
||||
const { Agent } = require('http');
|
||||
const net = require('net');
|
||||
const assert = require('assert');
|
||||
const log = require('book');
|
||||
const Debug = require('debug');
|
||||
import { Agent } from 'http';
|
||||
import net from 'net';
|
||||
import assert from 'assert';
|
||||
import log from 'book';
|
||||
import Debug from '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 = require(holding on to all the sockets so they can be used for upgrades
|
||||
// this prevents it from 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 = require(killed connections, we don't worry about them
|
||||
// These errors happen from 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 = require(client for tunneling requests to client
|
||||
// new socket connection from 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 = require(available list
|
||||
// remove the socket from 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 = require(clients for many reasons
|
||||
// we do not log these errors, sessions can drop from 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 = require(the available socket pool for the agent
|
||||
// fetch a socket from 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 {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = TunnelAgent;
|
||||
export default TunnelAgent;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
const http = require('http';
|
||||
const net = require('net';
|
||||
const assert = require('assert';
|
||||
import http from 'http';
|
||||
import net from 'net';
|
||||
import assert from 'assert';
|
||||
|
||||
const TunnelAgent = require('./TunnelAgent';
|
||||
import TunnelAgent from './TunnelAgent';
|
||||
|
||||
describe('TunnelAgent', () => {
|
||||
it('should create an empty agent', async () => {
|
||||
|
||||
Generated
-3619
File diff suppressed because it is too large
Load Diff
@@ -1,16 +1,16 @@
|
||||
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 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 ClientManager = require('./lib/ClientManager');
|
||||
import ClientManager from './lib/ClientManager';
|
||||
|
||||
const debug = Debug('localtunnel:server');
|
||||
|
||||
module.exports = function(opt) {
|
||||
export default function(opt) {
|
||||
opt = opt || {};
|
||||
|
||||
const validHosts = (opt.domain) ? [opt.domain] : undefined;
|
||||
|
||||
+6
-6
@@ -1,10 +1,10 @@
|
||||
const request = require('supertest';
|
||||
const assert = require('assert';
|
||||
const { Server as WebSocketServer } = require('ws';
|
||||
const WebSocket = require('ws';
|
||||
const net = require('net';
|
||||
import request from 'supertest';
|
||||
import assert from 'assert';
|
||||
import { Server as WebSocketServer } from 'ws';
|
||||
import WebSocket from 'ws';
|
||||
import net from 'net';
|
||||
|
||||
const createServer = require('./server';
|
||||
import createServer from './server';
|
||||
|
||||
describe('Server', () => {
|
||||
it('server starts and stops', async () => {
|
||||
|
||||
Reference in New Issue
Block a user