From: Pepijn de Vos Date: Fri, 29 Mar 2013 21:02:49 +0000 (+0100) Subject: support partially restricted modes X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=c32042248a0648bed941e10bf657f0e7bab3450c;p=KiwiIRC.git support partially restricted modes --- diff --git a/server/client.js b/server/client.js index 4bfeb1b..66b5dd1 100755 --- a/server/client.js +++ b/server/client.js @@ -114,26 +114,14 @@ function kiwiCommand(command, callback) { if (command.hostname && command.port && command.nick) { var con; - if (global.config.restrict_server) { - this.state.connect( - global.config.restrict_server, - global.config.restrict_server_port, - global.config.restrict_server_ssl, - command.nick, - {hostname: this.websocket.handshake.revdns, address: this.websocket.handshake.real_address}, - global.config.restrict_server_password, - callback); - - } else { - this.state.connect( - command.hostname, - command.port, - command.ssl, - command.nick, - {hostname: this.websocket.handshake.revdns, address: this.websocket.handshake.real_address}, - command.password, - callback); - } + this.state.connect( + (global.config.restrict_server || command.hostname), + (global.config.restrict_server_port || command.port), + (global.config.restrict_server_ssl || command.ssl), + command.nick, + {hostname: this.websocket.handshake.revdns, address: this.websocket.handshake.real_address}, + (global.config.restrict_server_password || command.password), + callback); } else { return callback('Hostname, port and nickname must be specified'); } @@ -155,4 +143,4 @@ function websocketDisconnect() { // TODO: Should this close all the websocket connections too? function websocketError() { this.dispose(); -} \ No newline at end of file +} diff --git a/server/irc/state.js b/server/irc/state.js index aa531be..cd99df4 100755 --- a/server/irc/state.js +++ b/server/irc/state.js @@ -35,26 +35,14 @@ module.exports = State; State.prototype.connect = function (hostname, port, ssl, nick, user, pass, callback) { var that = this; var con, con_num; - if (global.config.restrict_server) { - con = new IrcConnection( - global.config.restrict_server, - global.config.restrict_server_port, - global.config.restrict_server_ssl, - nick, - user, - global.config.restrict_server_password, - this); - - } else { - con = new IrcConnection( - hostname, - port, - ssl, - nick, - user, - pass, - this); - } + con = new IrcConnection( + hostname, + port, + ssl, + nick, + user, + pass, + this); con_num = this.next_connection++; this.irc_connections[con_num] = con;