From c32042248a0648bed941e10bf657f0e7bab3450c Mon Sep 17 00:00:00 2001 From: Pepijn de Vos Date: Fri, 29 Mar 2013 22:02:49 +0100 Subject: [PATCH] support partially restricted modes --- server/client.js | 30 +++++++++--------------------- server/irc/state.js | 28 ++++++++-------------------- 2 files changed, 17 insertions(+), 41 deletions(-) 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; -- 2.25.1