From 3d753975b1f1c4416b7682d1aa6a886ac5b648f3 Mon Sep 17 00:00:00 2001 From: Darren Date: Sat, 28 Sep 2013 15:36:58 +0100 Subject: [PATCH] Unknown IRC commands sent to client; RPL_WHOISACCOUNT, RPL_WHOISHOST, ERR_USERONCHANNEL, RPL_WHOISSECURE --- client/assets/src/models/network.js | 19 ++++++++++ server/irc/commands.js | 55 +++++++++++++++++++++++++++-- server/irc/server.js | 21 ++++++++++- server/irc/user.js | 27 ++++++++++++++ 4 files changed, 118 insertions(+), 4 deletions(-) diff --git a/client/assets/src/models/network.js b/client/assets/src/models/network.js index 5f773b5..93ede55 100644 --- a/client/assets/src/models/network.js +++ b/client/assets/src/models/network.js @@ -133,6 +133,7 @@ this.gateway.on('away', onAway, this); this.gateway.on('list_start', onListStart, this); this.gateway.on('irc_error', onIrcError, this); + this.gateway.on('unknown_command', onUnknownCommand, this); }, @@ -725,6 +726,9 @@ panel.addMsg(' ', '== ' + _kiwi.global.i18n.translate('client_models_network_channel_inviteonly').fetch(event.channel), 'status'); _kiwi.app.message.text(_kiwi.global.i18n.translate('client_models_network_channel_inviteonly').fetch(event.channel)); break; + case 'user_on_channel': + panel.addMsg(' ', '== ' + event.nick + ' is already on this channel'); + break; case 'channel_is_full': panel.addMsg(' ', '== ' + _kiwi.global.i18n.translate('client_models_network_channel_limitreached').fetch(event.channel), 'status'); _kiwi.app.message.text(_kiwi.global.i18n.translate('client_models_network_channel_limitreached').fetch(event.channel)); @@ -762,6 +766,21 @@ //_kiwi.front.tabviews.server.addMsg(null, ' ', '== ' + data, 'status'); } } + + + function onUnknownCommand(event) { + var display_params = _.clone(event.params); + + // A lot of commands have our nick as the first parameter. This is redundant for us + if (display_params[0] && display_params[0] == this.get('nick')) { + display_params.shift(); + } + + if (event.trailing) + display_params.push(event.trailing); + + this.panels.server.addMsg('', '[' + event.command + '] ' + display_params.join(', ', '')); + } } )(); diff --git a/server/irc/commands.js b/server/irc/commands.js index 4778c9e..053da58 100644 --- a/server/irc/commands.js +++ b/server/irc/commands.js @@ -30,6 +30,7 @@ irc_numerics = { '321': 'RPL_LISTSTART', '322': 'RPL_LIST', '323': 'RPL_LISTEND', + '330': 'RPL_WHOISACCOUNT', '331': 'RPL_NOTOPIC', '332': 'RPL_TOPIC', '333': 'RPL_TOPICWHOTIME', @@ -43,6 +44,7 @@ irc_numerics = { '372': 'RPL_MOTD', '375': 'RPL_MOTDSTART', '376': 'RPL_ENDOFMOTD', + '378': 'RPL_WHOISHOST', '379': 'RPL_WHOISMODES', '401': 'ERR_NOSUCHNICK', '404': 'ERR_CANNOTSENDTOCHAN', @@ -54,6 +56,7 @@ irc_numerics = { '433': 'ERR_NICKNAMEINUSE', '441': 'ERR_USERNOTINCHANNEL', '442': 'ERR_NOTONCHANNEL', + '443': 'ERR_USERONCHANNEL', '451': 'ERR_NOTREGISTERED', '464': 'ERR_PASSWDMISMATCH', '470': 'ERR_LINKCHANNEL', @@ -64,6 +67,7 @@ irc_numerics = { '481': 'ERR_NOPRIVILEGES', '482': 'ERR_CHANOPRIVSNEEDED', '670': 'RPL_STARTTLS', + '671': 'RPL_WHOISSECURE', '900': 'RPL_SASLAUTHENTICATED', '903': 'RPL_SASLLOGGEDIN', '904': 'ERR_SASLNOTAUTHORISED', @@ -85,7 +89,7 @@ IrcCommands.prototype.dispatch = function (command, data) { if (handlers[command]) { handlers[command].call(this, data); } else { - unknownCommand(command, data); + unknownCommand.call(this, command, data); } }; @@ -101,8 +105,26 @@ IrcCommands.addNumeric = function (numeric, handler_name) { }; unknownCommand = function (command, data) { - // TODO: Do something here, log? -}; + var params = _.clone(data.params); + + this.irc_connection.emit('server ' + this.irc_connection.irc_host.hostname + ' unknown_command', { + command: command, + params: params, + trailing: data.trailing + }); + + +/* + this.irc_connection.emit(namespace + ' ' + command.params[0] + ' notice', { + from_server: command.prefix ? true : false, + nick: command.nick || command.prefix || undefined, + ident: command.ident, + hostname: command.hostname, + target: command.params[0], + msg: command.trailing + }); + */ + }; handlers = { @@ -213,6 +235,26 @@ handlers = { }); }, + 'RPL_WHOISHOST': function (command) { + this.irc_connection.emit('user ' + command.params[1] + ' whoishost', { + nick: command.params[1], + msg: command.trailing + }); + }, + + 'RPL_WHOISSECURE': function (command) { + this.irc_connection.emit('user ' + command.params[1] + ' whoissecure', { + nick: command.params[1] + }); + }, + + 'RPL_WHOISACCOUNT': function (command) { + this.irc_connection.emit('user ' + command.params[1] + ' whoisaccount', { + nick: command.params[1], + account: command.params[2] + }); + }, + 'RPL_WHOWASUSER': function (command) { this.irc_connection.emit('user ' + command.params[1] + ' whowas', { nick: command.params[1], @@ -697,6 +739,13 @@ handlers = { }); }, + ERR_USERONCHANNEL: function (command) { + this.irc_connection.emit('server ' + this.irc_connection.irc_host.hostname + ' user_on_channel', { + nick: command.params[1], + channel: command.params[2] + }); + }, + ERR_CHANNELISFULL: function (command) { this.irc_connection.emit('server ' + this.irc_connection.irc_host.hostname + ' channel_is_full', { channel: command.params[1], diff --git a/server/irc/server.js b/server/irc/server.js index e68766f..6ec4828 100755 --- a/server/irc/server.js +++ b/server/irc/server.js @@ -27,11 +27,13 @@ var IrcServer = function (irc_connection) { not_on_channel: onNotOnChannel, channel_is_full: onChannelIsFull, invite_only_channel: onInviteOnlyChannel, + user_on_channel: onUserAlreadyInChannel, banned_from_channel: onBannedFromChannel, bad_channel_key: onBadChannelKey, chanop_privs_needed: onChanopPrivsNeeded, nickname_in_use: onNicknameInUse, - erroneus_nickname: onErroneusNickname + erroneus_nickname: onErroneusNickname, + unknown_command: onUnknownCommand }; EventBinder.bindIrcEvents('server *', this.irc_events, this, this.irc_connection); @@ -197,6 +199,14 @@ function onInviteOnlyChannel(event) { }); } +function onUserAlreadyInChannel(event) { + this.irc_connection.clientEvent('irc_error', { + error: 'user_on_channel', + channel: event.channel, + nick: event.nick + }); +} + function onBannedFromChannel(event) { this.irc_connection.clientEvent('irc_error', { error: 'banned_from_channel', @@ -236,3 +246,12 @@ function onErroneusNickname(event) { reason: event.reason }); } + +function onUnknownCommand(event) { + this.irc_connection.clientEvent('unknown_command', { + error: 'unknown_command', + command: event.command, + params: event.params, + trailing: event.trailing + }); +} diff --git a/server/irc/user.js b/server/irc/user.js index 387b7f1..95df588 100755 --- a/server/irc/user.js +++ b/server/irc/user.js @@ -17,6 +17,9 @@ var IrcUser = function (irc_connection, nick) { whoisidle: onWhoisIdle, whoisregnick: onWhoisRegNick, whoisserver: onWhoisServer, + whoishost: onWhoisHost, + whoissecure: onWhoisSecure, + whoisaccount: onWhoisAccount, endofwhois: onWhoisEnd, whowas: onWhoWas, endofwhowas: onWhoWasEnd, @@ -138,6 +141,30 @@ function onWhoisRegNick(event) { }); } +function onWhoisHost(event) { + this.irc_connection.clientEvent('whois', { + nick: event.nick, + msg: event.msg, + end: false + }); +} + +function onWhoisSecure(event) { + this.irc_connection.clientEvent('whois', { + nick: event.nick, + msg: 'Using a secure connection', + end: false + }); +} + +function onWhoisAccount(event) { + this.irc_connection.clientEvent('whois', { + nick: event.nick, + msg: 'Logged in as ' + event.account, + end: false + }); +} + function onWhoisEnd(event) { this.irc_connection.clientEvent('whois', { nick: event.nick, -- 2.25.1