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');
}
// TODO: Should this close all the websocket connections too?
function websocketError() {
this.dispose();
-}
\ No newline at end of file
+}
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;