support partially restricted modes
authorPepijn de Vos <pepijndevos@gmail.com>
Fri, 29 Mar 2013 21:02:49 +0000 (22:02 +0100)
committerPepijn de Vos <pepijndevos@gmail.com>
Fri, 29 Mar 2013 21:02:49 +0000 (22:02 +0100)
server/client.js
server/irc/state.js

index 4bfeb1bf44beddcff72cef6c10b36c0e909a9bb9..66b5dd126a48bcd6751da2f915b7365c25bcc906 100755 (executable)
@@ -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
+}
index aa531bee12fc87bf60cf2abe0aed1b5e2b34ba6a..cd99df446a09792fbfcef39ebde25eb785711d94 100755 (executable)
@@ -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;