From 79e4d009f465ac3db84e7ec96b3d9aeb55b414e6 Mon Sep 17 00:00:00 2001 From: Darren Date: Sat, 9 Aug 2014 15:12:11 +0100 Subject: [PATCH] Easier webirc single server password config --- config.example.js | 13 ++++++++----- server/irc/connection.js | 15 +++++++++++---- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/config.example.js b/config.example.js index 8dbebe8..17ce271 100644 --- a/config.example.js +++ b/config.example.js @@ -106,11 +106,14 @@ conf.modules = []; -// WebIRC passwords enabled for this server -conf.webirc_pass = { - //"irc.network.com": "configured_webirc_password", - //"127.0.0.1": "foobar" -}; +// WebIRC password enabled for this server +//conf.webirc_pass = "foobar"; + +// Multiple WebIRC passwords may be used for multiple servers +//conf.webirc_pass = { +// "irc.network.com": "configured_webirc_password", +// "127.0.0.1": "foobar" +//}; // Some IRCDs require the clients IP via the username/ident conf.ip_as_username = [ diff --git a/server/irc/connection.js b/server/irc/connection.js index 3242452..63c33a5 100644 --- a/server/irc/connection.js +++ b/server/irc/connection.js @@ -716,11 +716,19 @@ var socketConnectHandler = function () { function findWebIrc(connect_data) { var webirc_pass = global.config.webirc_pass, ip_as_username = global.config.ip_as_username, - tmp; + found_webirc_pass, tmp; - // Do we have a WEBIRC password for this? - if (webirc_pass && webirc_pass[this.irc_host.hostname]) { + // Do we have a single WEBIRC password? + if (typeof webirc_pass === 'string') { + found_webirc_pass = webirc_pass; + + // Do we have a WEBIRC password for this hostname? + } else if (typeof webirc_pass === 'object' && webirc_pass[this.irc_host.hostname]) { + found_webirc_pass = webirc_pass[this.irc_host.hostname]; + } + + if (found_webirc_pass) { // Build the WEBIRC line to be sent before IRC registration tmp = 'WEBIRC ' + webirc_pass[this.irc_host.hostname] + ' KiwiIRC '; tmp += this.user.hostname + ' ' + this.user.address; @@ -728,7 +736,6 @@ function findWebIrc(connect_data) { connect_data.prepend_data = [tmp]; } - // Check if we need to pass the users IP as its username/ident if (ip_as_username && ip_as_username.indexOf(this.irc_host.hostname) > -1) { // Get a hex value of the clients IP -- 2.25.1