Easier webirc single server password config
authorDarren <darren@darrenwhitlen.com>
Sat, 9 Aug 2014 14:12:11 +0000 (15:12 +0100)
committerDarren <darren@darrenwhitlen.com>
Sat, 9 Aug 2014 14:12:11 +0000 (15:12 +0100)
config.example.js
server/irc/connection.js

index 8dbebe82708513f29e8dcb9b74e8ff1c9b82646d..17ce2713cd0e53c1096bb264a78eba8e196c7424 100644 (file)
@@ -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 = [
index 3242452ec0c7df9efd61a615e90b6ab12036fc74..63c33a58403d92fc0f2990d24e52752d0022cbfe 100644 (file)
@@ -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