fixed inconsistency in "admin" domain definition

This commit is contained in:
tigerbot 2017-05-31 15:56:28 -06:00
parent 810d0a8e90
commit be1a60d2e7
2 changed files with 21 additions and 17 deletions

View File

@ -1,3 +1,12 @@
var adminDomains = [
'localhost.alpha.daplie.me'
, 'localhost.admin.daplie.me'
, 'alpha.localhost.daplie.me'
, 'admin.localhost.daplie.me'
, 'localhost.daplie.invalid'
];
module.exports.adminDomains = adminDomains;
module.exports.create = function (deps, conf) { module.exports.create = function (deps, conf) {
'use strict'; 'use strict';
@ -43,20 +52,14 @@ module.exports.create = function (deps, conf) {
*/ */
] ]
}; };
adminDomains.forEach(function (id) {
opts.sites.push({ opts.sites.push({
// greenlock: {} $id: id
$id: 'localhost.alpha.daplie.me'
, paths: [ , paths: [
{ $id: '/', modules: [ { $id: 'serve', paths: [ path.resolve(__dirname, '..', '..', 'admin', 'public') ] } ] } { $id: '/', modules: [ { $id: 'serve', paths: [ path.resolve(__dirname, '..', '..', 'admin', 'public') ] } ] }
, { $id: '/api/', modules: [ { $id: 'app', path: path.join(__dirname, 'admin') } ] } , { $id: '/api/', modules: [ { $id: 'app', path: path.join(__dirname, 'admin') } ] }
] ]
}); });
opts.sites.push({
$id: 'localhost.daplie.invalid'
, paths: [
{ $id: '/', modules: [ { $id: 'serve', paths: [ path.resolve(__dirname, '..', '..', 'admin', 'public') ] } ] }
, { $id: '/api/', modules: [ { $id: 'app', path: path.join(__dirname, 'admin') } ] }
]
}); });
var app = require('../app.js')(deps, conf, opts); var app = require('../app.js')(deps, conf, opts);

View File

@ -51,7 +51,7 @@ module.exports.create = function (deps, conf, greenlockMiddleware) {
var result = {}; var result = {};
lines.slice(1).forEach(function (line) { lines.slice(1).forEach(function (line) {
var match = /(.*)\s*:\s*(.*)/.exec(line); var match = /([^:]*?)\s*:\s*(.*)/.exec(line);
if (match) { if (match) {
result[match[1].toLowerCase()] = match[2]; result[match[1].toLowerCase()] = match[2];
} else { } else {
@ -186,8 +186,9 @@ module.exports.create = function (deps, conf, greenlockMiddleware) {
var adminServer; var adminServer;
function checkAdmin(conn, opts, headers) { function checkAdmin(conn, opts, headers) {
var admin = adminDomains.some(function (re) { var host = separatePort(headers.host).host;
return re.test(headers.host); var admin = require('./admin').adminDomains.some(function (domain) {
return host === domain;
}); });
if (admin) { if (admin) {