From: Darren Date: Sat, 29 Mar 2014 15:35:25 +0000 (+0000) Subject: Add server + client versions to CTCP VERSION reply X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=9b95f5f120ac805de2d0ab8dada867e3dbbd0feb;p=KiwiIRC.git Add server + client versions to CTCP VERSION reply --- diff --git a/client/src/models/gateway.js b/client/src/models/gateway.js index 0744803..c602437 100644 --- a/client/src/models/gateway.js +++ b/client/src/models/gateway.js @@ -247,13 +247,23 @@ _kiwi.model.Gateway = function () { this.parseKiwi = function (command, data) { + var client_info_data; + this.trigger('kiwi:' + command, data); this.trigger('kiwi', data); switch (command) { case 'connected': + // Send some info on this client to the server + client_info_data = { + command: 'client_info', + build_version: _kiwi.global.build_version + }; + this.rpc.call('kiwi', client_info_data); + this.connect_callback && this.connect_callback(); delete this.connect_callback; + break; } }; diff --git a/server/client.js b/server/client.js index d41dc52..1798b38 100755 --- a/server/client.js +++ b/server/client.js @@ -147,7 +147,17 @@ function kiwiCommand(command, callback) { } else { return callback('Hostname, port and nickname must be specified'); } - break; + + break; + + case 'client_info': + // keep hold of selected parts of the client_info + this.client_info = { + build_version: command.build_version.toString() || undefined + }; + + break; + default: callback(); } diff --git a/server/irc/commands.js b/server/irc/commands.js index e1bf119..96927dc 100644 --- a/server/irc/commands.js +++ b/server/irc/commands.js @@ -585,7 +585,7 @@ handlers = { }, 'PRIVMSG': function (command) { - var tmp, namespace, time, msg; + var tmp, namespace, time, msg, version_string, client_info; // Check if we have a server-time time = getServerTime.call(this, command); @@ -611,7 +611,17 @@ handlers = { time: time }); } else if (msg.substr(1, 7) === 'VERSION') { - this.irc_connection.write('NOTICE ' + command.nick + ' :' + String.fromCharCode(1) + 'VERSION KiwiIRC' + String.fromCharCode(1)); + client_info = this.irc_connection.state.client.client_info; + version_string = global.build_version; + + // If the client build_version differs from the server, add this to the version_string + if (client_info && client_info.build_version !== global.build_version) { + version_string += ', client build: ' + client_info.build_version; + } + + version_string = 'KiwiIRC (' + version_string + ')'; + + this.irc_connection.write('NOTICE ' + command.nick + ' :' + String.fromCharCode(1) + 'VERSION ' + version_string + String.fromCharCode(1)); } else if (msg.substr(1, 6) === 'SOURCE') { this.irc_connection.write('NOTICE ' + command.nick + ' :' + String.fromCharCode(1) + 'SOURCE http://www.kiwiirc.com/' + String.fromCharCode(1)); } else if (msg.substr(1, 10) === 'CLIENTINFO') { diff --git a/server/kiwi.js b/server/kiwi.js index 68dcf62..58df810 100755 --- a/server/kiwi.js +++ b/server/kiwi.js @@ -13,6 +13,10 @@ var fs = require('fs'), process.chdir(__dirname + '/../'); +// Get our own version from package.json +global.build_version = require('../package.json').version; + +// Load the config, using -c argument if available (function (argv) { var conf_switch = argv.indexOf('-c'); if (conf_switch !== -1) {