From 7c7590eec122a0ee1bdd4d92d0ed28c2d2f76047 Mon Sep 17 00:00:00 2001 From: Darren Date: Sun, 21 Oct 2012 21:39:51 +0100 Subject: [PATCH] Ip via username rather than realname --- server/app.js | 15 +++++++++++---- server/config.json | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/server/app.js b/server/app.js index 7668bfc..d6af269 100644 --- a/server/app.js +++ b/server/app.js @@ -823,7 +823,10 @@ this.IRCConnection = function (websocket, nick, host, port, ssl, password, callb events.EventEmitter.call(this); onConnectHandler = function () { - var realname = nick; + // Inspired by: + // y4ry65yer56ytr + var realname = '[www.kiwiirc.com] ' + nick; + var username = nick.replace(/[^0-9a-zA-Z\-_.]/, ''); that.IRC.nick = nick; // Send the login data @@ -831,8 +834,11 @@ this.IRCConnection = function (websocket, nick, host, port, ssl, password, callb websocket.kiwi.hostname = (err) ? websocket.kiwi.address : _.first(domains); // Check if we need to pass the users IP as its realname - if (kiwi.config.ip_as_realname && kiwi.config.ip_as_realname.indexOf(host) > -1) { - realname = websocket.kiwi.address; + if (kiwi.config.ip_as_username && kiwi.config.ip_as_username.indexOf(host) > -1) { + // Get a hex value of the clients IP + username = websocket.kiwi.address.split('.').map(function(i, idx){ + return parseInt(i, 10).toString(16); + }).join(''); } // Do we have a WEBIRC password for this? @@ -847,7 +853,8 @@ this.IRCConnection = function (websocket, nick, host, port, ssl, password, callb websocket.sendServerLine('CAP LS'); websocket.sendServerLine('NICK ' + nick); - websocket.sendServerLine('USER kiwi_' + nick.replace(/[^0-9a-zA-Z\-_.]/, '') + ' 0 0 :' + realname); + websocket.sendServerLine('USER ' + username + ' 0 0 :' + realname); + console.log('Username:', username, 'Realname:', realname); that.connected = true; that.emit('connect'); diff --git a/server/config.json b/server/config.json index 6477b1e..4dfc684 100755 --- a/server/config.json +++ b/server/config.json @@ -37,7 +37,7 @@ "irc.example.com": "examplepassword", "127.0.0.1": "foobar" }, - "ip_as_realname": [], + "ip_as_username": [], "transports": [ "websocket", -- 2.25.1