Adding support for password protected servers. Issue #44
authorJack Allnutt <m2ys4u@Gmail.com>
Sat, 1 Oct 2011 08:27:13 +0000 (09:27 +0100)
committerJack Allnutt <m2ys4u@Gmail.com>
Sat, 1 Oct 2011 08:27:13 +0000 (09:27 +0100)
js/front.js
js/gateway.js
node/app.js
node/client/index.html.jade

index 293408867f544f2cae70dbd39fc56a8af49c1b01..a8c5351ca60b585c7829543001204e53d38c6114 100644 (file)
@@ -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':
index 877f6364bfe1bfbbb3e9050d7a9c223398405e2b..468a18221483b57df0254e6f760d916586db208f 100644 (file)
@@ -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 () {
index de84541d12c1fb2919e0768f15148b446fa71d84..7898bf5b59f566e291b2a5ab3c24794636e31b23 100644 (file)
@@ -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);
index 58123ca2d3fc058faa3937715c26e22d843be7cd..a24e2a40de85c3713df1778c5d3e259f798ab86c 100644 (file)
@@ -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)