Handle subdomains #36
@@ -36,6 +36,9 @@ var stats = {
|
|||||||
tunnels: 0
|
tunnels: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// are we serving from a subdomain?
|
||||||
|
var sub = false;
|
||||||
|
|
||||||
function maybe_bounce(req, res, sock, head) {
|
function maybe_bounce(req, res, sock, head) {
|
||||||
// without a hostname, we won't know who the request is for
|
// without a hostname, we won't know who the request is for
|
||||||
var hostname = req.headers.host;
|
var hostname = req.headers.host;
|
||||||
@@ -44,6 +47,12 @@ function maybe_bounce(req, res, sock, head) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var subdomain = tldjs.getSubdomain(hostname);
|
var subdomain = tldjs.getSubdomain(hostname);
|
||||||
|
// if we're serving from a subdomain do a proper check
|
||||||
|
if (sub) {
|
||||||
|
var subsub = (subdomain || '').split('.');
|
||||||
|
subdomain = subsub.length > 1 ? subsub[0] : '';
|
||||||
|
}
|
||||||
|
|
||||||
if (!subdomain) {
|
if (!subdomain) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -180,6 +189,8 @@ module.exports = function(opt) {
|
|||||||
opt = opt || {};
|
opt = opt || {};
|
||||||
|
|
||||||
var schema = opt.secure ? 'https' : 'http';
|
var schema = opt.secure ? 'https' : 'http';
|
||||||
|
|
||||||
|
sub = opt.sub || false;
|
||||||
|
|
||||||
var app = express();
|
var app = express();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user