Files
server/bin/server
T
Liu Jia HaoandDESKTOP-0P848CA\edinl_6z7c6t 9071931395 fix syntax error (#2)
Co-authored-by: DESKTOP-0P848CA\edinl_6z7c6t <[email protected]>
2021-11-20 08:58:27 +08:00

69 lines
1.7 KiB
JavaScript
Executable File

#!/usr/bin/env node -r esm
require('localenv');
const optimist = require('optimist');
const log = require('book');
const Debug = require('debug');
const CreateServer = require('../server');
const debug = Debug('localtunnel');
const argv = optimist
.usage('Usage: $0 --port [num]')
.options('secure', {
default: false,
describe: 'use this flag to indicate proxy over https'
})
.options('port', {
default: '80',
describe: 'listen on this port for outside requests'
})
.options('address', {
default: '0.0.0.0',
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)',
})
.options('max-sockets', {
default: 10,
describe: 'maximum number of tcp sockets each client is allowed to establish at one time (the tunnels)'
})
.argv;
if (argv.help) {
optimist.showHelp();
process.exit();
}
const server = CreateServer({
max_tcp_sockets: argv['max-sockets'],
secure: argv.secure,
domain: argv.domain,
});
server.listen(argv.port, argv.address, () => {
debug('server listening on port: %d', server.address().port);
});
process.on('SIGINT', () => {
process.exit();
});
process.on('SIGTERM', () => {
process.exit();
});
process.on('uncaughtException', (err) => {
log.error(err);
});
process.on('unhandledRejection', (reason, promise) => {
log.error(reason);
});
// vim: ft=javascript