-/*jslint continue: true, forin: true, regexp: true, confusion: true, undef: false, node: true, sloppy: true, nomen: true, plusplus: true, maxerr: 50, indent: 4 */
-
+/*jslint continue: true, forin: true, regexp: true, undef: false, node: true, nomen: true, plusplus: true, maxerr: 50, indent: 4 */
+"use strict";
var tls = require('tls'),
net = require('net'),
http = require('http'),
config_dirs = ['/etc/kiwiirc/', __dirname + '/'];
var loadConfig = function () {
- var i, j;
- var nconf = {};
- var cconf = {};
- var found_config = false;
+ var i, j,
+ nconf = {},
+ cconf = {},
+ found_config = false;
for (i in config_dirs) {
try {
if (fs.lstatSync(config_dirs[i] + config_filename).isDirectory() === false) {
break;
}
} catch (e) {
- switch (e.code){
+ switch (e.code) {
case 'ENOENT': // No file/dir
break;
default:
}
}
if (Object.keys(config).length === 0) {
- if (!found_config) console.log('Couldn\'t find a config file!');
+ if (!found_config) {
+ console.log('Couldn\'t find a config file!');
+ }
return false;
}
return [nconf, cconf];
};
-if (!loadConfig()) process.exit(0);
+if (!loadConfig()) {
+ process.exit(0);
+}
/*
ERR_NICKNAMEINUSE: '433',
ERR_USERNOTINCHANNEL: '441',
ERR_NOTONCHANNEL: '442',
+ ERR_NOTREGISTERED: '451',
ERR_LINKCHANNEL: '470',
ERR_CHANNELISFULL: '471',
ERR_INVITEONLYCHAN: '473',
ircSocket.IRC.options[opt[0]].push({symbol: matches[2].charAt(j), mode: matches[1].charAt(j)});
//console.log({symbol: matches[2].charAt(j), mode: matches[1].charAt(j)});
}
- console.log(ircSocket.IRC.options);
+ //console.log(ircSocket.IRC.options);
}
}
}
websocket.sendClientEvent('irc_error', {error: 'error', reason: msg.trailing});
websocket.disconnect();
break;
+ case ircNumerics.ERR_NOTREGISTERED:
+ if (ircSocket.IRC.registered) {
+ // We may be doing something wrong...
+ }
+ break;
default:
console.log("Unknown command (" + String(msg.command).toUpperCase() + ")");
}
}
var httpHandler = function (request, response) {
- var uri, subs, useragent, agent, server_set, server, nick, debug, touchscreen, hash;
- var min = {};
+ var uri, subs, useragent, agent, server_set, server, nick, debug, touchscreen, hash,
+ min = {};
if (config.handle_http) {
uri = url.parse(request.url, true);
subs = uri.pathname.substr(0, 4);
nick = '';
}
response.setHeader('X-Generated-By', 'KiwiIRC');
- hash = crypto.createHash('md5').update(touchscreen?'t':'f').update(debug?'t':'f').update(server_set?'t':'f').update(server).update(nick).update(agent).update(JSON.stringify(config)).digest('base64');
+ hash = crypto.createHash('md5').update(touchscreen ? 't' : 'f').update(debug ? 't' : 'f').update(server_set ? 't' : 'f').update(server).update(nick).update(agent).update(JSON.stringify(config)).digest('base64');
if (cache.html[hash]) {
if (request.headers['if-none-match'] === cache.html[hash].hash) {
response.statusCode = 304;
};
websocket.on('irc connect', function (nick, host, port, ssl, callback) {
- var ircSocket, login;
+ var ircSocket;
//setup IRC connection
if (!ssl) {
ircSocket = net.createConnection(port, host);
var rehash = function () {
- var changes, i;
- var reload_config = loadConfig();
+ var changes, i,
+ reload_config = loadConfig();
// If loading the new config errored out, dont attempt any changes
- if (reload_config === false) return false;
+ if (reload_config === false) {
+ return false;
+ }
// We just want the settings that have been changed
changes = reload_config[1];
case 'ssl_key':
case 'ssl_cert':
websocketListen(config.port, config.bind_address, httpHandler, config.listen_ssl, config.ssl_key, config.ssl_cert);
- delete changes['port'];
- delete changes['bind_address'];
- delete changes['listen_ssl'];
- delete changes['ssl_key'];
- delete changes['ssl_cert'];
+ delete changes.port;
+ delete changes.bind_address;
+ delete changes.listen_ssl;
+ delete changes.ssl_key;
+ delete changes.ssl_cert;
break;
case 'user':
case 'group':
changeUser();
- delete changes['user'];
- delete changes['group'];
+ delete changes.user;
+ delete changes.group;
break;
case 'module_dir':
case 'modules':
kiwi_mod.loadModules(kiwi_root, config);
kiwi_mod.printMods();
- delete changes['module_dir'];
- delete changes['modules'];
+ delete changes.module_dir;
+ delete changes.modules;
break;
}
}