fix sub-host cli handling

This commit is contained in:
whitecolor
2017-06-07 17:02:51 +05:00
parent 5bc44fb901
commit 830476db19
2 changed files with 3 additions and 2 deletions
+1 -2
View File
@@ -18,8 +18,7 @@ const argv = optimist
describe: 'listen on this port for outside requests'
})
.options('sub-host', {
describe: 'additionally listen on these sub hosts for outside requests',
type: 'array'
describe: 'additionally listen on this sub host for outside requests (can use this option multiple times)'
})
.options('max-sockets', {
default: 10,
+2
View File
@@ -50,6 +50,8 @@ function maybe_bounce(req, res, sock, head, opt) {
let subdomain = tldjs.getSubdomain(hostname);
if (subdomain && opt.subHost) {
const subHosts = Array.isArray(opt.subHost)
? opt.subHost : [opt.subHost]
const subHost = opt.subHost.reduce((found, sub) => {
return found
|| (subdomain.slice(-sub.length) == sub ? sub : '')