From: Jack Allnutt Date: Sat, 1 Oct 2011 08:27:13 +0000 (+0100) Subject: Adding support for password protected servers. Issue #44 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e8a707e761dcfb2974863ddf80a46cbec84d07bf;p=KiwiIRC.git Adding support for password protected servers. Issue #44 --- diff --git a/js/front.js b/js/front.js index 2934088..a8c5351 100644 --- a/js/front.js +++ b/js/front.js @@ -77,6 +77,7 @@ kiwi.front = { var netsel = $('#kiwi .formconnectwindow .network'), netport = $('#kiwi .formconnectwindow .port'), netssl = $('#kiwi .formconnectwindow .ssl'), + netpass = $('#kiwi .formconnectwindow .password'), nick = $('#kiwi .formconnectwindow .nick'), tmp; @@ -93,7 +94,7 @@ kiwi.front = { kiwi.front.ui.doLayout(); try { - kiwi.front.run('/connect ' + netsel.val() + ' ' + netport.val() + ' ' + (netssl.attr('checked') ? 'true' : '')); + kiwi.front.run('/connect ' + netsel.val() + ' ' + netport.val() + ' ' + (netssl.attr('checked') ? 'true' : 'false') + ' ' + netpass.val()); } catch (e) { console.log(e); } @@ -238,7 +239,7 @@ kiwi.front = { case '/connect': case '/server': if (typeof parts[1] === 'undefined') { - alert('Usage: /connect servername [port] [ssl]'); + alert('Usage: /connect servername [port] [ssl] [password]'); break; } @@ -253,7 +254,7 @@ kiwi.front = { } Tabview.getCurrentTab().addMsg(null, ' ', '=== Connecting to ' + parts[1] + ' on port ' + parts[2] + (parts[3] ? ' using SSL' : '') + '...', 'status'); - kiwi.gateway.connect(parts[1], parts[2], parts[3]); + kiwi.gateway.connect(parts[1], parts[2], parts[3], parts[4]); break; case '/nick': diff --git a/js/gateway.js b/js/gateway.js index 877f636..468a182 100644 --- a/js/gateway.js +++ b/js/gateway.js @@ -16,7 +16,7 @@ kiwi.gateway = { } }, - connect: function (host, port, ssl, callback) { + connect: function (host, port, ssl, password, callback) { if (typeof kiwi.gateway.kiwi_server !== 'undefined') { kiwi.gateway.socket = io.connect(kiwi_server, { 'try multiple transports': true, @@ -49,7 +49,7 @@ kiwi.gateway = { kiwi.gateway.socket.emit('message', {sid: this.session_id, data: $.toJSON(data)}, callback); }; - kiwi.gateway.socket.emit('irc connect', kiwi.gateway.nick, host, port, ssl, callback); + kiwi.gateway.socket.emit('irc connect', kiwi.gateway.nick, host, port, ssl, password, callback); console.log("kiwi.gateway.socket.on('connect')"); }); kiwi.gateway.socket.on('too_many_connections', function () { diff --git a/node/app.js b/node/app.js index de84541..7898bf5 100644 --- a/node/app.js +++ b/node/app.js @@ -766,7 +766,7 @@ this.websocketConnection = function (websocket) { -this.websocketIRCConnect = function (websocket, nick, host, port, ssl, callback) { +this.websocketIRCConnect = function (websocket, nick, host, port, ssl, password, callback) { var ircSocket; //setup IRC connection if (!ssl) { @@ -799,6 +799,9 @@ this.websocketIRCConnect = function (websocket, nick, host, port, ssl, callback) if ((kiwi.config.webirc) && (kiwi.config.webirc_pass[host])) { websocket.sendServerLine('WEBIRC ' + kiwi.config.webirc_pass[host] + ' KiwiIRC ' + websocket.kiwi.hostname + ' ' + websocket.kiwi.address); } + if (password) { + websocket.sendServerLine('PASS ' + password); + } websocket.sendServerLine('CAP LS'); websocket.sendServerLine('NICK ' + nick); websocket.sendServerLine('USER kiwi_' + nick.replace(/[^0-9a-zA-Z\-_.]/, '') + ' 0 0 :' + nick); diff --git a/node/client/index.html.jade b/node/client/index.html.jade index 58123ca..a24e2a4 100644 --- a/node/client/index.html.jade +++ b/node/client/index.html.jade @@ -44,15 +44,18 @@ html(lang="en-gb") a(href="", class="more_link") more div.content.bottom ul - li - label(for="network") Server: - input(type="text", id="network", name="network", class="network", value=server) li label(for="channel") Channel: input(type="text", id="channel", name="channel", class="channel", value="#kiwiirc") + li + label(for="network") Server: + input(type="text", id="network", name="network", class="network", value=server) li(class="section") label(for="port") Port: input(type="text", id="port", name="port", class="port", value=port) + li + label(for="password") Server password: + input(type="text", id="password", name="password", class="password") li label(for="ssl") SSL: - if (ssl)