From: Jack Allnutt Date: Thu, 24 Jan 2013 01:23:36 +0000 (+0000) Subject: Pass callback to state.connect, fix vars X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=b09157de7df850222786c5f8ea7950c46408b143;p=KiwiIRC.git Pass callback to state.connect, fix vars --- diff --git a/server/client.js b/server/client.js index ad343f7..ddcb312 100755 --- a/server/client.js +++ b/server/client.js @@ -121,7 +121,8 @@ function kiwiCommand(command, callback) { global.config.restrict_server_ssl, command.nick, {hostname: this.websocket.handshake.revdns, address: this.websocket.handshake.real_address}, - global.config.restrict_server_password); + global.config.restrict_server_password, + callback); } else { this.state.connect( @@ -130,7 +131,8 @@ function kiwiCommand(command, callback) { command.ssl, command.nick, {hostname: this.websocket.handshake.revdns, address: this.websocket.handshake.real_address}, - command.password); + command.password, + callback); } } else { return callback('Hostname, port and nickname must be specified'); diff --git a/server/irc/commands.js b/server/irc/commands.js index 452e959..3903f32 100644 --- a/server/irc/commands.js +++ b/server/irc/commands.js @@ -416,7 +416,7 @@ var listeners = { hostname: command.hostname, channel: command.params[0], msg: command.trailing - ); + }); } }, 'CAP': function (command) { diff --git a/server/irc/connection.js b/server/irc/connection.js index 01d4743..0d927c2 100644 --- a/server/irc/connection.js +++ b/server/irc/connection.js @@ -5,7 +5,7 @@ var net = require('net'), _ = require('lodash'); -var IrcConnection = function (hostname, port, ssl, nick, user, pass) { +var IrcConnection = function (hostname, port, ssl, nick, user, pass, state) { var that = this; events.EventEmitter.call(this); @@ -23,6 +23,9 @@ var IrcConnection = function (hostname, port, ssl, nick, user, pass) { this.user = user; // Contains users real hostname and address this.username = this.nick.replace(/[^0-9a-zA-Z\-_.]/, ''); this.password = pass; + + // State object + this.state = state; // IRC connection information this.irc_host = {hostname: hostname, port: port}; diff --git a/server/irc/state.js b/server/irc/state.js index df1ba05..768e62b 100755 --- a/server/irc/state.js +++ b/server/irc/state.js @@ -1,5 +1,7 @@ -var util = require('util'), - IrcConnection = require('./connection.js'); +var util = require('util'), + events = require('events'), + _ = require('lodash'), + IrcConnection = require('./connection.js').IrcConnection; var State = function (client, save_state) { events.EventEmitter.call(this); @@ -36,18 +38,20 @@ State.prototype.connect = function (hostname, port, ssl, nick, user, pass, callb global.config.restrict_server, global.config.restrict_server_port, global.config.restrict_server_ssl, - command.nick, + nick, user, - global.config.restrict_server_password); + global.config.restrict_server_password, + this); } else { con = new IrcConnection( - command.hostname, - command.port, - command.ssl, - command.nick, + hostname, + port, + ssl, + nick, user, - command.password); + pass, + this); } con_num = this.next_connection++; @@ -61,7 +65,7 @@ State.prototype.connect = function (hostname, port, ssl, nick, user, pass, callb }); con.on('error', function (err) { - console.log('irc_connection error (' + command.hostname + '):', err); + console.log('irc_connection error (' + hostname + '):', err); return callback(err.code, {server: con_num, error: err}); });