add --domain option to enable localtunnel servers on subdomains

This commit is contained in:
Roman Shtylman
2018-04-01 19:57:48 -07:00
parent 6b07a86ec1
commit 86dce49dd1
6 changed files with 76 additions and 9 deletions

View File

@@ -9,13 +9,16 @@ import ClientManager from './lib/ClientManager';
const debug = Debug('localtunnel:server');
function GetClientIdFromHostname(hostname) {
return tldjs.getSubdomain(hostname);
}
export default function(opt) {
opt = opt || {};
const validHosts = (opt.domain) ? [opt.domain] : undefined;
const myTldjs = tldjs.fromUserSettings({ validHosts });
function GetClientIdFromHostname(hostname) {
return myTldjs.getSubdomain(hostname);
}
const manager = new ClientManager(opt);
const schema = opt.secure ? 'https' : 'http';