2013-07-28 15:49:29 +00:00
|
|
|
var fs = require("fs");
|
2014-01-22 23:11:26 +00:00
|
|
|
var path = require("path");
|
2014-05-21 02:30:14 +00:00
|
|
|
var net = require("net");
|
2014-01-22 23:11:26 +00:00
|
|
|
var YAML = require("yamljs");
|
2013-05-30 18:07:29 +00:00
|
|
|
|
2017-07-20 03:47:02 +00:00
|
|
|
import { loadFromToml } from './configuration/configloader';
|
2017-05-29 02:38:43 +00:00
|
|
|
import { CamoConfig } from './configuration/camoconfig';
|
2017-07-17 05:35:33 +00:00
|
|
|
import { PrometheusConfig } from './configuration/prometheusconfig';
|
2017-09-27 04:22:15 +00:00
|
|
|
import { EmailConfig } from './configuration/emailconfig';
|
2017-04-05 06:02:31 +00:00
|
|
|
|
2017-07-09 03:11:54 +00:00
|
|
|
const LOGGER = require('@calzoneman/jsli')('config');
|
2017-04-05 06:02:31 +00:00
|
|
|
|
2013-07-28 15:49:29 +00:00
|
|
|
var defaults = {
|
2014-01-22 23:11:26 +00:00
|
|
|
mysql: {
|
|
|
|
server: "localhost",
|
2015-02-14 22:20:26 +00:00
|
|
|
port: 3306,
|
2014-01-22 23:11:26 +00:00
|
|
|
database: "cytube3",
|
|
|
|
user: "cytube3",
|
2015-02-14 22:20:26 +00:00
|
|
|
password: "",
|
2017-02-03 07:05:50 +00:00
|
|
|
"pool-size": 10
|
2013-07-28 15:49:29 +00:00
|
|
|
},
|
2014-04-11 05:14:52 +00:00
|
|
|
listen: [
|
|
|
|
{
|
2015-02-14 18:17:06 +00:00
|
|
|
ip: "0.0.0.0",
|
2014-04-11 05:14:52 +00:00
|
|
|
port: 8080,
|
|
|
|
http: true,
|
|
|
|
},
|
|
|
|
{
|
2015-02-14 18:17:06 +00:00
|
|
|
ip: "0.0.0.0",
|
2014-04-11 05:14:52 +00:00
|
|
|
port: 1337,
|
|
|
|
io: true
|
|
|
|
}
|
|
|
|
],
|
2014-01-22 23:11:26 +00:00
|
|
|
http: {
|
2014-04-11 15:52:51 +00:00
|
|
|
"default-port": 8080,
|
2014-02-26 16:50:59 +00:00
|
|
|
"root-domain": "localhost",
|
2014-02-28 02:50:47 +00:00
|
|
|
"alt-domains": ["127.0.0.1"],
|
2014-02-24 05:27:07 +00:00
|
|
|
minify: false,
|
2014-11-17 03:06:10 +00:00
|
|
|
"max-age": "7d",
|
|
|
|
gzip: true,
|
2015-02-16 03:56:00 +00:00
|
|
|
"gzip-threshold": 1024,
|
2016-05-21 23:59:28 +00:00
|
|
|
"cookie-secret": "change-me",
|
|
|
|
index: {
|
|
|
|
"max-entries": 50
|
2017-06-28 06:37:18 +00:00
|
|
|
},
|
|
|
|
"trust-proxies": [
|
|
|
|
"loopback"
|
|
|
|
]
|
2014-01-22 23:11:26 +00:00
|
|
|
},
|
|
|
|
https: {
|
2014-04-11 15:52:51 +00:00
|
|
|
enabled: false,
|
2014-01-26 06:01:36 +00:00
|
|
|
domain: "https://localhost",
|
2014-04-11 15:52:51 +00:00
|
|
|
"default-port": 8443,
|
2014-01-22 23:11:26 +00:00
|
|
|
keyfile: "localhost.key",
|
|
|
|
passphrase: "",
|
2014-03-06 04:26:10 +00:00
|
|
|
certfile: "localhost.cert",
|
2015-03-05 04:31:45 +00:00
|
|
|
cafile: "",
|
2017-09-20 03:49:33 +00:00
|
|
|
ciphers: "HIGH:!DSS:!aNULL@STRENGTH"
|
2014-01-22 23:11:26 +00:00
|
|
|
},
|
|
|
|
io: {
|
2014-02-26 16:57:49 +00:00
|
|
|
domain: "http://localhost",
|
2014-04-11 15:52:51 +00:00
|
|
|
"default-port": 1337,
|
2017-12-26 19:00:18 +00:00
|
|
|
"ip-connection-limit": 10
|
2014-01-22 23:11:26 +00:00
|
|
|
},
|
2015-03-27 23:44:46 +00:00
|
|
|
"youtube-v3-key": "",
|
2017-06-16 07:16:59 +00:00
|
|
|
"channel-blacklist": [],
|
|
|
|
"channel-path": "r",
|
2014-01-22 23:11:26 +00:00
|
|
|
"channel-save-interval": 5,
|
2017-06-16 07:16:59 +00:00
|
|
|
"channel-storage": {
|
|
|
|
type: "file"
|
|
|
|
},
|
2014-02-06 16:37:00 +00:00
|
|
|
"max-channels-per-user": 5,
|
2014-02-10 01:52:24 +00:00
|
|
|
"max-accounts-per-ip": 5,
|
2014-01-22 23:11:26 +00:00
|
|
|
"guest-login-delay": 60,
|
|
|
|
aliases: {
|
|
|
|
"purge-interval": 3600000,
|
|
|
|
"max-age": 2592000000
|
2014-01-25 19:55:00 +00:00
|
|
|
},
|
2014-04-07 19:41:21 +00:00
|
|
|
"vimeo-workaround": false,
|
2014-01-25 19:55:00 +00:00
|
|
|
"html-template": {
|
2014-02-06 00:05:52 +00:00
|
|
|
title: "CyTube Beta", description: "Free, open source synchtube"
|
|
|
|
},
|
|
|
|
"reserved-names": {
|
|
|
|
usernames: ["^(.*?[-_])?admin(istrator)?([-_].*)?$", "^(.*?[-_])?owner([-_].*)?$"],
|
|
|
|
channels: ["^(.*?[-_])?admin(istrator)?([-_].*)?$", "^(.*?[-_])?owner([-_].*)?$"],
|
|
|
|
pagetitles: []
|
2014-02-14 00:15:22 +00:00
|
|
|
},
|
2016-11-02 05:44:26 +00:00
|
|
|
"contacts": [],
|
2014-05-21 02:30:14 +00:00
|
|
|
"aggressive-gc": false,
|
|
|
|
playlist: {
|
|
|
|
"max-items": 4000,
|
|
|
|
"update-interval": 5
|
2014-05-22 03:33:24 +00:00
|
|
|
},
|
2014-06-01 18:43:18 +00:00
|
|
|
ffmpeg: {
|
2015-05-19 23:48:08 +00:00
|
|
|
enabled: false,
|
|
|
|
"ffprobe-exec": "ffprobe"
|
2014-09-13 05:01:54 +00:00
|
|
|
},
|
2015-02-21 08:12:26 +00:00
|
|
|
"link-domain-blacklist": [],
|
|
|
|
setuid: {
|
|
|
|
enabled: false,
|
|
|
|
"group": "users",
|
2015-02-23 22:08:43 +00:00
|
|
|
"user": "nobody",
|
|
|
|
"timeout": 15
|
2015-02-21 08:12:26 +00:00
|
|
|
},
|
2016-07-16 05:06:27 +00:00
|
|
|
"service-socket": {
|
|
|
|
enabled: false,
|
|
|
|
socket: "service.sock"
|
2016-08-12 03:04:51 +00:00
|
|
|
},
|
2017-03-21 04:37:32 +00:00
|
|
|
"twitch-client-id": null,
|
|
|
|
poll: {
|
|
|
|
"max-options": 50
|
|
|
|
}
|
2014-01-22 23:11:26 +00:00
|
|
|
};
|
2013-07-06 17:00:02 +00:00
|
|
|
|
2014-01-22 23:11:26 +00:00
|
|
|
/**
|
|
|
|
* Merges a config object with the defaults, warning about missing keys
|
|
|
|
*/
|
|
|
|
function merge(obj, def, path) {
|
|
|
|
for (var key in def) {
|
|
|
|
if (key in obj) {
|
|
|
|
if (typeof obj[key] === "object") {
|
|
|
|
merge(obj[key], def[key], path + "." + key);
|
2013-07-28 15:49:29 +00:00
|
|
|
}
|
2014-01-22 23:11:26 +00:00
|
|
|
} else {
|
2017-04-05 06:02:31 +00:00
|
|
|
LOGGER.warn("Missing config key " + (path + "." + key) +
|
2014-01-22 23:11:26 +00:00
|
|
|
"; using default: " + JSON.stringify(def[key]));
|
|
|
|
obj[key] = def[key];
|
2013-07-28 15:49:29 +00:00
|
|
|
}
|
2014-01-22 23:11:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var cfg = defaults;
|
2017-05-29 02:38:43 +00:00
|
|
|
let camoConfig = new CamoConfig();
|
2017-07-17 05:35:33 +00:00
|
|
|
let prometheusConfig = new PrometheusConfig();
|
2017-09-27 04:22:15 +00:00
|
|
|
let emailConfig = new EmailConfig();
|
2013-07-28 15:49:29 +00:00
|
|
|
|
2014-01-22 23:11:26 +00:00
|
|
|
/**
|
|
|
|
* Initializes the configuration from the given YAML file
|
|
|
|
*/
|
|
|
|
exports.load = function (file) {
|
|
|
|
try {
|
|
|
|
cfg = YAML.load(path.join(__dirname, "..", file));
|
|
|
|
} catch (e) {
|
|
|
|
if (e.code === "ENOENT") {
|
2017-04-05 06:02:31 +00:00
|
|
|
LOGGER.info(file + " does not exist, assuming default configuration");
|
2014-01-22 23:11:26 +00:00
|
|
|
cfg = defaults;
|
|
|
|
return;
|
|
|
|
} else {
|
2017-04-05 06:02:31 +00:00
|
|
|
LOGGER.error("Error loading config file " + file + ": ");
|
|
|
|
LOGGER.error(e);
|
2014-01-22 23:11:26 +00:00
|
|
|
if (e.stack) {
|
2017-04-05 06:02:31 +00:00
|
|
|
LOGGER.error(e.stack);
|
2014-01-22 23:11:26 +00:00
|
|
|
}
|
|
|
|
cfg = defaults;
|
2013-07-28 15:49:29 +00:00
|
|
|
return;
|
|
|
|
}
|
2014-01-22 23:11:26 +00:00
|
|
|
}
|
2013-07-28 15:49:29 +00:00
|
|
|
|
2014-01-22 23:11:26 +00:00
|
|
|
if (cfg == null) {
|
2017-04-05 06:02:31 +00:00
|
|
|
LOGGER.info(file + " is an Invalid configuration file, " +
|
2014-01-22 23:11:26 +00:00
|
|
|
"assuming default configuration");
|
|
|
|
cfg = defaults;
|
|
|
|
return;
|
|
|
|
}
|
2013-07-28 15:49:29 +00:00
|
|
|
|
2017-09-27 04:22:15 +00:00
|
|
|
if (cfg.mail) {
|
|
|
|
LOGGER.error(
|
|
|
|
'Old style mail configuration found in config.yaml. ' +
|
|
|
|
'Email will not be delivered unless you copy conf/example/email.toml ' +
|
|
|
|
'to conf/email.toml and edit it to your liking. ' +
|
|
|
|
'To remove this warning, delete the "mail:" block in config.yaml.'
|
|
|
|
);
|
2014-01-22 23:11:26 +00:00
|
|
|
}
|
2017-09-27 04:22:15 +00:00
|
|
|
|
2014-01-22 23:11:26 +00:00
|
|
|
merge(cfg, defaults, "config");
|
2014-02-26 20:28:24 +00:00
|
|
|
|
|
|
|
preprocessConfig(cfg);
|
2017-04-05 06:02:31 +00:00
|
|
|
LOGGER.info("Loaded configuration from " + file);
|
2017-05-29 02:38:43 +00:00
|
|
|
|
|
|
|
loadCamoConfig();
|
2017-07-17 05:35:33 +00:00
|
|
|
loadPrometheusConfig();
|
2017-09-27 04:22:15 +00:00
|
|
|
loadEmailConfig();
|
2014-02-26 20:28:24 +00:00
|
|
|
};
|
|
|
|
|
2017-09-27 04:22:15 +00:00
|
|
|
function checkLoadConfig(configClass, filename) {
|
2017-05-29 02:38:43 +00:00
|
|
|
try {
|
2017-09-27 04:22:15 +00:00
|
|
|
return loadFromToml(
|
|
|
|
configClass,
|
|
|
|
path.resolve(__dirname, '..', 'conf', filename)
|
|
|
|
);
|
2017-05-29 02:38:43 +00:00
|
|
|
} catch (error) {
|
|
|
|
if (error.code === 'ENOENT') {
|
2017-09-27 04:22:15 +00:00
|
|
|
return null;
|
2017-05-29 02:38:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (typeof error.line !== 'undefined') {
|
2017-09-27 04:22:15 +00:00
|
|
|
LOGGER.error(`Error in conf/${fileanme}: ${error} (line ${error.line})`);
|
2017-05-29 02:38:43 +00:00
|
|
|
} else {
|
2017-09-27 04:22:15 +00:00
|
|
|
LOGGER.error(`Error loading conf/${filename}: ${error.stack}`);
|
2017-05-29 02:38:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-27 04:22:15 +00:00
|
|
|
function loadCamoConfig() {
|
|
|
|
const conf = checkLoadConfig(CamoConfig, 'camo.toml');
|
|
|
|
|
|
|
|
if (conf === null) {
|
|
|
|
LOGGER.info('No camo configuration found, chat images will not be proxied.');
|
|
|
|
camoConfig = new CamoConfig();
|
|
|
|
} else {
|
|
|
|
camoConfig = conf;
|
|
|
|
const enabled = camoConfig.isEnabled() ? 'ENABLED' : 'DISABLED';
|
|
|
|
LOGGER.info(`Loaded camo configuration from conf/camo.toml. Camo is ${enabled}`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-17 05:35:33 +00:00
|
|
|
function loadPrometheusConfig() {
|
2017-09-27 04:22:15 +00:00
|
|
|
const conf = checkLoadConfig(PrometheusConfig, 'prometheus.toml');
|
|
|
|
|
|
|
|
if (conf === null) {
|
|
|
|
LOGGER.info('No prometheus configuration found, defaulting to disabled');
|
|
|
|
prometheusConfig = new PrometheusConfig();
|
|
|
|
} else {
|
|
|
|
prometheusConfig = conf;
|
2017-07-17 05:35:33 +00:00
|
|
|
const enabled = prometheusConfig.isEnabled() ? 'ENABLED' : 'DISABLED';
|
2017-09-27 04:22:15 +00:00
|
|
|
LOGGER.info(
|
|
|
|
'Loaded prometheus configuration from conf/prometheus.toml. ' +
|
|
|
|
`Prometheus listener is ${enabled}`
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2017-07-17 05:35:33 +00:00
|
|
|
|
2017-09-27 04:22:15 +00:00
|
|
|
function loadEmailConfig() {
|
|
|
|
const conf = checkLoadConfig(EmailConfig, 'email.toml');
|
|
|
|
|
|
|
|
if (conf === null) {
|
|
|
|
LOGGER.info('No email configuration found, defaulting to disabled');
|
|
|
|
emailConfig = new EmailConfig();
|
|
|
|
} else {
|
|
|
|
emailConfig = conf;
|
|
|
|
LOGGER.info('Loaded email configuration from conf/email.toml.');
|
2017-07-17 05:35:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-05 06:02:31 +00:00
|
|
|
// I'm sorry
|
2014-02-26 20:28:24 +00:00
|
|
|
function preprocessConfig(cfg) {
|
|
|
|
// Root domain should start with a . for cookies
|
|
|
|
var root = cfg.http["root-domain"];
|
2014-02-28 02:50:47 +00:00
|
|
|
root = root.replace(/^\.*/, "");
|
2014-02-26 20:28:24 +00:00
|
|
|
cfg.http["root-domain"] = root;
|
2015-02-21 20:48:24 +00:00
|
|
|
if (root.indexOf(".") !== -1 && !net.isIP(root)) {
|
2014-03-01 23:37:59 +00:00
|
|
|
root = "." + root;
|
|
|
|
}
|
|
|
|
cfg.http["root-domain-dotted"] = root;
|
2014-02-26 20:28:24 +00:00
|
|
|
|
|
|
|
// Debug
|
2014-01-22 23:11:26 +00:00
|
|
|
if (process.env.DEBUG === "1" || process.env.DEBUG === "true") {
|
|
|
|
cfg.debug = true;
|
|
|
|
} else {
|
|
|
|
cfg.debug = false;
|
|
|
|
}
|
|
|
|
|
2014-02-26 20:28:24 +00:00
|
|
|
// Strip trailing slashes from domains
|
2014-01-26 06:01:36 +00:00
|
|
|
cfg.https.domain = cfg.https.domain.replace(/\/*$/, "");
|
2014-02-26 20:28:24 +00:00
|
|
|
|
2014-05-21 02:30:14 +00:00
|
|
|
// Socket.IO URLs
|
|
|
|
cfg.io["ipv4-nossl"] = "";
|
|
|
|
cfg.io["ipv4-ssl"] = "";
|
|
|
|
cfg.io["ipv6-nossl"] = "";
|
|
|
|
cfg.io["ipv6-ssl"] = "";
|
|
|
|
for (var i = 0; i < cfg.listen.length; i++) {
|
|
|
|
var srv = cfg.listen[i];
|
2015-02-14 18:17:06 +00:00
|
|
|
if (!srv.ip) {
|
|
|
|
srv.ip = "0.0.0.0";
|
|
|
|
}
|
2014-05-21 02:30:14 +00:00
|
|
|
if (!srv.io) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (srv.ip === "") {
|
|
|
|
if (srv.port === cfg.io["default-port"]) {
|
|
|
|
cfg.io["ipv4-nossl"] = cfg.io["domain"] + ":" + cfg.io["default-port"];
|
|
|
|
} else if (srv.port === cfg.https["default-port"]) {
|
|
|
|
cfg.io["ipv4-ssl"] = cfg.https["domain"] + ":" + cfg.https["default-port"];
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (net.isIPv4(srv.ip) || srv.ip === "::") {
|
|
|
|
if (srv.https && !cfg.io["ipv4-ssl"]) {
|
|
|
|
if (srv.url) {
|
|
|
|
cfg.io["ipv4-ssl"] = srv.url;
|
|
|
|
} else {
|
2014-06-13 03:29:12 +00:00
|
|
|
cfg.io["ipv4-ssl"] = cfg.https["domain"] + ":" + srv.port;
|
2014-05-21 02:30:14 +00:00
|
|
|
}
|
|
|
|
} else if (!cfg.io["ipv4-nossl"]) {
|
|
|
|
if (srv.url) {
|
|
|
|
cfg.io["ipv4-nossl"] = srv.url;
|
|
|
|
} else {
|
2014-06-13 03:29:12 +00:00
|
|
|
cfg.io["ipv4-nossl"] = cfg.io["domain"] + ":" + srv.port;
|
2014-05-21 02:30:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (net.isIPv6(srv.ip) || srv.ip === "::") {
|
|
|
|
if (srv.https && !cfg.io["ipv6-ssl"]) {
|
|
|
|
if (!srv.url) {
|
2017-04-05 06:02:31 +00:00
|
|
|
LOGGER.error("Config Error: no URL defined for IPv6 " +
|
2014-05-21 02:30:14 +00:00
|
|
|
"Socket.IO listener! Ignoring this listener " +
|
|
|
|
"because the Socket.IO client cannot connect to " +
|
|
|
|
"a raw IPv6 address.");
|
2017-04-05 06:02:31 +00:00
|
|
|
LOGGER.error("(Listener was: " + JSON.stringify(srv) + ")");
|
2014-05-21 02:30:14 +00:00
|
|
|
} else {
|
|
|
|
cfg.io["ipv6-ssl"] = srv.url;
|
|
|
|
}
|
|
|
|
} else if (!cfg.io["ipv6-nossl"]) {
|
|
|
|
if (!srv.url) {
|
2017-04-05 06:02:31 +00:00
|
|
|
LOGGER.error("Config Error: no URL defined for IPv6 " +
|
2014-05-21 02:30:14 +00:00
|
|
|
"Socket.IO listener! Ignoring this listener " +
|
|
|
|
"because the Socket.IO client cannot connect to " +
|
|
|
|
"a raw IPv6 address.");
|
2017-04-05 06:02:31 +00:00
|
|
|
LOGGER.error("(Listener was: " + JSON.stringify(srv) + ")");
|
2014-05-21 02:30:14 +00:00
|
|
|
} else {
|
|
|
|
cfg.io["ipv6-nossl"] = srv.url;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
cfg.io["ipv4-default"] = cfg.io["ipv4-ssl"] || cfg.io["ipv4-nossl"];
|
|
|
|
cfg.io["ipv6-default"] = cfg.io["ipv6-ssl"] || cfg.io["ipv6-nossl"];
|
|
|
|
|
2014-02-26 20:28:24 +00:00
|
|
|
// Generate RegExps for reserved names
|
2014-02-06 00:05:52 +00:00
|
|
|
var reserved = cfg["reserved-names"];
|
|
|
|
for (var key in reserved) {
|
|
|
|
if (reserved[key] && reserved[key].length > 0) {
|
|
|
|
reserved[key] = new RegExp(reserved[key].join("|"), "i");
|
|
|
|
} else {
|
|
|
|
reserved[key] = false;
|
|
|
|
}
|
|
|
|
}
|
2014-05-22 03:33:24 +00:00
|
|
|
|
|
|
|
/* Convert channel blacklist to a hashtable */
|
|
|
|
var tbl = {};
|
|
|
|
cfg["channel-blacklist"].forEach(function (c) {
|
|
|
|
tbl[c.toLowerCase()] = true;
|
|
|
|
});
|
|
|
|
cfg["channel-blacklist"] = tbl;
|
|
|
|
|
2017-06-16 07:16:59 +00:00
|
|
|
/* Check channel path */
|
2017-06-17 04:50:17 +00:00
|
|
|
if(!/^[-\w]+$/.test(cfg["channel-path"])){
|
2017-06-16 07:16:59 +00:00
|
|
|
LOGGER.error("Channel paths may only use the same characters as usernames and channel names.");
|
|
|
|
process.exit(78); // sysexits.h for bad config
|
|
|
|
}
|
|
|
|
|
2014-09-13 05:01:54 +00:00
|
|
|
if (cfg["link-domain-blacklist"].length > 0) {
|
|
|
|
cfg["link-domain-blacklist-regex"] = new RegExp(
|
|
|
|
cfg["link-domain-blacklist"].join("|").replace(/\./g, "\\."), "gi");
|
|
|
|
} else {
|
|
|
|
// Match nothing
|
|
|
|
cfg["link-domain-blacklist-regex"] = new RegExp("$^", "gi");
|
|
|
|
}
|
|
|
|
|
2015-03-27 23:44:46 +00:00
|
|
|
if (cfg["youtube-v3-key"]) {
|
|
|
|
require("cytube-mediaquery/lib/provider/youtube").setApiKey(
|
|
|
|
cfg["youtube-v3-key"]);
|
|
|
|
} else {
|
2017-04-05 06:02:31 +00:00
|
|
|
LOGGER.warn("No YouTube v3 API key set. YouTube links will " +
|
2015-06-07 15:45:23 +00:00
|
|
|
"not work. See youtube-v3-key in config.template.yaml and " +
|
2015-03-27 23:44:46 +00:00
|
|
|
"https://developers.google.com/youtube/registering_an_application for " +
|
|
|
|
"information on registering an API key.");
|
|
|
|
}
|
|
|
|
|
2016-09-19 04:35:08 +00:00
|
|
|
if (cfg["twitch-client-id"]) {
|
|
|
|
require("cytube-mediaquery/lib/provider/twitch-vod").setClientID(
|
|
|
|
cfg["twitch-client-id"]);
|
2017-05-27 18:49:27 +00:00
|
|
|
require("cytube-mediaquery/lib/provider/twitch-clip").setClientID(
|
|
|
|
cfg["twitch-client-id"]);
|
2016-09-19 04:35:08 +00:00
|
|
|
} else {
|
2017-04-05 06:02:31 +00:00
|
|
|
LOGGER.warn("No Twitch Client ID set. Twitch VOD links will " +
|
2016-09-19 04:35:08 +00:00
|
|
|
"not work. See twitch-client-id in config.template.yaml and " +
|
|
|
|
"https://github.com/justintv/Twitch-API/blob/master/authentication.md#developer-setup" +
|
|
|
|
"for more information on registering a client ID");
|
|
|
|
}
|
|
|
|
|
2016-11-02 05:44:26 +00:00
|
|
|
// Remove calzoneman from contact config (old default)
|
|
|
|
cfg.contacts = cfg.contacts.filter(contact => {
|
|
|
|
return contact.name !== 'calzoneman';
|
|
|
|
});
|
|
|
|
|
2014-02-26 20:28:24 +00:00
|
|
|
return cfg;
|
|
|
|
}
|
2014-01-22 23:11:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieves a configuration value with the given key
|
|
|
|
*
|
|
|
|
* Accepts a dot-separated key for nested values, e.g. "http.port"
|
|
|
|
* Throws an error if a nonexistant key is requested
|
|
|
|
*/
|
|
|
|
exports.get = function (key) {
|
|
|
|
var obj = cfg;
|
|
|
|
var keylist = key.split(".");
|
|
|
|
var current = keylist.shift();
|
|
|
|
var path = current;
|
|
|
|
while (keylist.length > 0) {
|
|
|
|
if (!(current in obj)) {
|
|
|
|
throw new Error("Nonexistant config key '" + path + "." + current + "'");
|
|
|
|
}
|
|
|
|
obj = obj[current];
|
|
|
|
current = keylist.shift();
|
|
|
|
path += "." + current;
|
|
|
|
}
|
|
|
|
|
|
|
|
return obj[current];
|
|
|
|
};
|
2017-01-06 04:58:07 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets a configuration value with the given key
|
|
|
|
*
|
|
|
|
* Accepts a dot-separated key for nested values, e.g. "http.port"
|
|
|
|
* Throws an error if a nonexistant key is requested
|
|
|
|
*/
|
|
|
|
exports.set = function (key, value) {
|
|
|
|
var obj = cfg;
|
|
|
|
var keylist = key.split(".");
|
|
|
|
var current = keylist.shift();
|
|
|
|
var path = current;
|
|
|
|
while (keylist.length > 0) {
|
|
|
|
if (!(current in obj)) {
|
|
|
|
throw new Error("Nonexistant config key '" + path + "." + current + "'");
|
|
|
|
}
|
|
|
|
obj = obj[current];
|
|
|
|
current = keylist.shift();
|
|
|
|
path += "." + current;
|
|
|
|
}
|
|
|
|
|
|
|
|
obj[current] = value;
|
|
|
|
};
|
2017-05-29 02:38:43 +00:00
|
|
|
|
|
|
|
exports.getCamoConfig = function getCamoConfig() {
|
|
|
|
return camoConfig;
|
|
|
|
};
|
2017-07-17 05:35:33 +00:00
|
|
|
|
|
|
|
exports.getPrometheusConfig = function getPrometheusConfig() {
|
|
|
|
return prometheusConfig;
|
|
|
|
};
|
2017-09-27 04:22:15 +00:00
|
|
|
|
|
|
|
exports.getEmailConfig = function getEmailConfig() {
|
|
|
|
return emailConfig;
|
|
|
|
};
|