Sub host options #65
+1
-2
@@ -18,8 +18,7 @@ const argv = optimist
|
|||||||
describe: 'listen on this port for outside requests'
|
describe: 'listen on this port for outside requests'
|
||||||
})
|
})
|
||||||
.options('sub-host', {
|
.options('sub-host', {
|
||||||
describe: 'additionally listen on these sub hosts for outside requests',
|
describe: 'additionally listen on this sub host for outside requests (can use this option multiple times)'
|
||||||
type: 'array'
|
|
||||||
})
|
})
|
||||||
.options('max-sockets', {
|
.options('max-sockets', {
|
||||||
default: 10,
|
default: 10,
|
||||||
|
|||||||
@@ -50,6 +50,8 @@ function maybe_bounce(req, res, sock, head, opt) {
|
|||||||
let subdomain = tldjs.getSubdomain(hostname);
|
let subdomain = tldjs.getSubdomain(hostname);
|
||||||
|
|
||||||
if (subdomain && opt.subHost) {
|
if (subdomain && opt.subHost) {
|
||||||
|
const subHosts = Array.isArray(opt.subHost)
|
||||||
|
? opt.subHost : [opt.subHost]
|
||||||
const subHost = opt.subHost.reduce((found, sub) => {
|
const subHost = opt.subHost.reduce((found, sub) => {
|
||||||
return found
|
return found
|
||||||
|| (subdomain.slice(-sub.length) == sub ? sub : '')
|
|| (subdomain.slice(-sub.length) == sub ? sub : '')
|
||||||
|
|||||||
Reference in New Issue
Block a user