function websocketDisconnect() {
_.each(this.irc_connections, function (irc_connection, i, cons) {
if (irc_connection) {
- irc_connection.end('QUIT :' + (config.get().quit_message || ''));
+ irc_connection.end('QUIT :' + (global.config.quit_message || ''));
irc_connection.dispose();
cons[i] = null;
}
if (new_config) {
loaded_config = new_config;
+ global.config = new_config[environment];
return loaded_config;
} else {
return false;
HttpHandler.prototype.serve = function (request, response) {
// The incoming requests base path (ie. /kiwiclient)
- var base_path = config.get().http_base_path || '/kiwi',
+ var base_path = global.config.http_base_path || '/kiwi',
base_path_regex;
// Trim of any trailing slashes
function findWebIrc(connect_data) {
- var webirc_pass = config.get().webirc_pass;
- var ip_as_username = config.get().ip_as_username;
+ var webirc_pass = global.config.webirc_pass;
+ var ip_as_username = global.config.ip_as_username;
var tmp;
// Do we have a WEBIRC password for this?
// If we're not running in the forground and we have a log file.. switch
// console.log to output to a file
-if (process.argv.indexOf('-f') === -1 && config.get().log) {
+if (process.argv.indexOf('-f') === -1 && global.config.log) {
(function () {
- var log_file_name = config.get().log;
+ var log_file_name = global.config.log;
if (log_file_name[0] !== '/') {
log_file_name = __dirname + '/../' + log_file_name;
// Make sure we have a valid config file and at least 1 server
-if (Object.keys(config.get()).length === 0) {
+if (Object.keys(global.config).length === 0) {
console.log('Couldn\'t find a valid config file!');
process.exit(1);
}
-if ((!config.get().servers) || (config.get().servers.length < 1)) {
+if ((!global.config.servers) || (global.config.servers.length < 1)) {
console.log('No servers defined in config file');
process.exit(2);
}
// Start up a weblistener for each found in the config
-_.each(config.get().servers, function (server) {
- var wl = new WebListener(server, config.get().transports);
+_.each(global.config.servers, function (server) {
+ var wl = new WebListener(server, global.config.transports);
wl.on('connection', function (client) {
clients.add(client);
process.title = 'kiwiirc';
// Change UID/GID
-if ((config.get().group) && (config.get().group !== '')) {
- process.setgid(config.get().group);
+if ((global.config.group) && (global.config.group !== '')) {
+ process.setgid(global.config.group);
}
-if ((config.get().user) && (config.get().user !== '')) {
- process.setuid(config.get().user);
+if ((global.config.user) && (global.config.user !== '')) {
+ process.setuid(global.config.user);
}
this.ws.enable('browser client minification');
this.ws.enable('browser client etag');
this.ws.set('transports', transports);
- this.ws.set('resource', (config.get().http_base_path || '') + '/transport');
+ this.ws.set('resource', (global.config.http_base_path || '') + '/transport');
this.ws.of('/kiwi').authorization(authoriseConnection)
.on('connection', function () {
// If a forwarded-for header is found, switch the source address
if (handshakeData.headers['x-forwarded-for']) {
// Check we're connecting from a whitelisted proxy
- if (!config.get().http_proxies || config.get().http_proxies.indexOf(address) < 0) {
+ if (!global.config.http_proxies || global.config.http_proxies.indexOf(address) < 0) {
console.log('Unlisted proxy:', address);
callback(null, false);
return;
handshakeData.real_address = address;
// If enabled, don't go over the connection limit
- if (config.get().max_client_conns && config.get().max_client_conns > 0) {
- if (global.clients.numOnAddress(address) + 1 > config.get().max_client_conns) {
+ if (global.config.max_client_conns && global.config.max_client_conns > 0) {
+ if (global.clients.numOnAddress(address) + 1 > global.config.max_client_conns) {
return callback(null, false);
}
}