Sub host options #65

Closed
wclr wants to merge 3 commits from sub-host into master
2 changed files with 3 additions and 2 deletions
Showing only changes of commit 830476db19 - Show all commits
+1 -2
View File
@@ -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,
+2
View File
@@ -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 : '')