Add some sanity checks for common first-startup issues
This commit is contained in:
parent
66d81ffb22
commit
c6f9b1611e
|
|
@ -2,7 +2,7 @@
|
||||||
"author": "Calvin Montgomery",
|
"author": "Calvin Montgomery",
|
||||||
"name": "CyTube",
|
"name": "CyTube",
|
||||||
"description": "Online media synchronizer and chat",
|
"description": "Online media synchronizer and chat",
|
||||||
"version": "3.63.1",
|
"version": "3.63.2",
|
||||||
"repository": {
|
"repository": {
|
||||||
"url": "http://github.com/calzoneman/sync"
|
"url": "http://github.com/calzoneman/sync"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -245,6 +245,28 @@ function loadEmailConfig() {
|
||||||
function preprocessConfig(cfg) {
|
function preprocessConfig(cfg) {
|
||||||
// Root domain should start with a . for cookies
|
// Root domain should start with a . for cookies
|
||||||
var root = cfg.http["root-domain"];
|
var root = cfg.http["root-domain"];
|
||||||
|
if (/127\.0\.0\.1|localhost/.test(root)) {
|
||||||
|
LOGGER.warn(
|
||||||
|
"Detected 127.0.0.1 or localhost in root-domain '%s'. This server " +
|
||||||
|
"will not work from other computers! Set root-domain to the domain " +
|
||||||
|
"the website will be accessed from (e.g. example.com)",
|
||||||
|
root
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (/^http/.test(root)) {
|
||||||
|
LOGGER.warn(
|
||||||
|
"root-domain '%s' should not contain http:// or https://, removing it",
|
||||||
|
root
|
||||||
|
);
|
||||||
|
root = root.replace(/^https?:\/\//, "");
|
||||||
|
}
|
||||||
|
if (/:\d+$/.test(root)) {
|
||||||
|
LOGGER.warn(
|
||||||
|
"root-domain '%s' should not contain a trailing port, removing it",
|
||||||
|
root
|
||||||
|
);
|
||||||
|
root = root.replace(/:\d+$/, "");
|
||||||
|
}
|
||||||
root = root.replace(/^\.*/, "");
|
root = root.replace(/^\.*/, "");
|
||||||
cfg.http["root-domain"] = root;
|
cfg.http["root-domain"] = root;
|
||||||
if (root.indexOf(".") !== -1 && !net.isIP(root)) {
|
if (root.indexOf(".") !== -1 && !net.isIP(root)) {
|
||||||
|
|
@ -328,6 +350,13 @@ function preprocessConfig(cfg) {
|
||||||
cfg.io["ipv4-default"] = cfg.io["ipv4-ssl"] || cfg.io["ipv4-nossl"];
|
cfg.io["ipv4-default"] = cfg.io["ipv4-ssl"] || cfg.io["ipv4-nossl"];
|
||||||
cfg.io["ipv6-default"] = cfg.io["ipv6-ssl"] || cfg.io["ipv6-nossl"];
|
cfg.io["ipv6-default"] = cfg.io["ipv6-ssl"] || cfg.io["ipv6-nossl"];
|
||||||
|
|
||||||
|
if (/127\.0\.0\.1|localhost/.test(cfg.io["ipv4-default"])) {
|
||||||
|
LOGGER.warn(
|
||||||
|
"socket.io is bound to localhost, this server will be inaccessible " +
|
||||||
|
"from other computers!"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Generate RegExps for reserved names
|
// Generate RegExps for reserved names
|
||||||
var reserved = cfg["reserved-names"];
|
var reserved = cfg["reserved-names"];
|
||||||
for (var key in reserved) {
|
for (var key in reserved) {
|
||||||
|
|
|
||||||
|
|
@ -488,6 +488,18 @@ module.exports = {
|
||||||
} else {
|
} else {
|
||||||
const server = http.createServer().listen(bind.port, bind.ip);
|
const server = http.createServer().listen(bind.port, bind.ip);
|
||||||
servers.push(server);
|
servers.push(server);
|
||||||
|
server.on("error", error => {
|
||||||
|
if (error.code === "EADDRINUSE") {
|
||||||
|
LOGGER.fatal(
|
||||||
|
"Could not bind %s: address already in use. Check " +
|
||||||
|
"whether another application has already bound this " +
|
||||||
|
"port, or whether another instance of this server " +
|
||||||
|
"is running.",
|
||||||
|
id
|
||||||
|
);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
uniqueListenAddresses.add(id);
|
uniqueListenAddresses.add(id);
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ module.exports = {
|
||||||
fs.exists(gdvttpath, function (exists) {
|
fs.exists(gdvttpath, function (exists) {
|
||||||
exists || fs.mkdirSync(gdvttpath);
|
exists || fs.mkdirSync(gdvttpath);
|
||||||
});
|
});
|
||||||
|
|
||||||
singleton = new Server();
|
singleton = new Server();
|
||||||
return singleton;
|
return singleton;
|
||||||
},
|
},
|
||||||
|
|
@ -161,6 +162,18 @@ var Server = function () {
|
||||||
if (bind.https && Config.get("https.enabled")) {
|
if (bind.https && Config.get("https.enabled")) {
|
||||||
self.servers[id] = https.createServer(opts, self.express)
|
self.servers[id] = https.createServer(opts, self.express)
|
||||||
.listen(bind.port, bind.ip);
|
.listen(bind.port, bind.ip);
|
||||||
|
self.servers[id].on("error", error => {
|
||||||
|
if (error.code === "EADDRINUSE") {
|
||||||
|
LOGGER.fatal(
|
||||||
|
"Could not bind %s: address already in use. Check " +
|
||||||
|
"whether another application has already bound this " +
|
||||||
|
"port, or whether another instance of this server " +
|
||||||
|
"is running.",
|
||||||
|
id
|
||||||
|
);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
});
|
||||||
self.servers[id].on("clientError", function (err, socket) {
|
self.servers[id].on("clientError", function (err, socket) {
|
||||||
try {
|
try {
|
||||||
socket.destroy();
|
socket.destroy();
|
||||||
|
|
@ -170,6 +183,18 @@ var Server = function () {
|
||||||
});
|
});
|
||||||
} else if (bind.http) {
|
} else if (bind.http) {
|
||||||
self.servers[id] = self.express.listen(bind.port, bind.ip);
|
self.servers[id] = self.express.listen(bind.port, bind.ip);
|
||||||
|
self.servers[id].on("error", error => {
|
||||||
|
if (error.code === "EADDRINUSE") {
|
||||||
|
LOGGER.fatal(
|
||||||
|
"Could not bind %s: address already in use. Check " +
|
||||||
|
"whether another application has already bound this " +
|
||||||
|
"port, or whether another instance of this server " +
|
||||||
|
"is running.",
|
||||||
|
id
|
||||||
|
);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
});
|
||||||
self.servers[id].on("clientError", function (err, socket) {
|
self.servers[id].on("clientError", function (err, socket) {
|
||||||
try {
|
try {
|
||||||
socket.destroy();
|
socket.destroy();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue