forcessl Kiwi server plugin, ssl checkbox checked if on ssl
authorDarren <darren@darrenwhitlen.com>
Sat, 1 Oct 2011 17:23:23 +0000 (18:23 +0100)
committerDarren <darren@darrenwhitlen.com>
Sat, 1 Oct 2011 17:23:23 +0000 (18:23 +0100)
css/ui.css
js/front.events.js
js/front.js
node/app.js
node/client/index.html.jade
node/kiwi_modules/forcessl.js [new file with mode: 0644]

index 59a5dbd30a91e1ce3d3f426d8f01a94b6035440f..0b9860567548a31b5c95fbee98013492c71ed247 100644 (file)
@@ -41,7 +41,7 @@
 \r
 }\r
 #kiwi #login input[type=checkbox] { width:auto !important; }\r
-#kiwi #login .more { border-top: 1px dotted #888888; }\r
+#kiwi #login .more { border-top: 1px dotted #888888; font-size: 0.9em;}\r
 #kiwi #login .more_link {\r
        font-size:12px;\r
        position:relative;\r
index ad0716a9f87000c1fc489a5a709ddb0d9e84ab13..571f85449ff83e208c9e74f49aa7666864e58202 100644 (file)
@@ -163,6 +163,11 @@ kiwi.front.events = {
             Tabview.getServerTab().addMsg(null, ' ', '=== Failed to connect :(', 'status');\r
             kiwi.plugs.run('connect', {success: false});\r
         }\r
+\r
+        // Now that we're connected, warn the user if they really want to quit\r
+        window.onbeforeunload = function() {\r
+            return "Are you sure you leave Kiwi IRC?";\r
+        };\r
     },\r
     onConnectFail: function (e, data) {\r
         var reason = (typeof data.reason === 'string') ? data.reason : '';\r
index a8c5351ca60b585c7829543001204e53d38c6114..a0b818987ba76fa2cd607a34b6bc6ae683ab8463 100644 (file)
@@ -45,10 +45,6 @@ kiwi.front = {
 
         kiwi.front.ui.registerKeys();
 
-        window.onbeforeunload = function() {
-            return "Are you sure you leave Kiwi IRC?";
-        };
-
         $('#kiwi .toolbars').resize(kiwi.front.ui.doLayoutSize);
         $(window).resize(kiwi.front.ui.doLayoutSize);
 
index 8b066859f678959160ca7492014adcba22d68e8f..ee31709ac9a00abcd018b80c4abeec246e943273 100644 (file)
@@ -529,11 +529,19 @@ this.ircSocketDataHandler = function (data, websocket, ircSocket) {
 
 this.httpHandler = function (request, response) {
     var uri, uri_parts, subs, useragent, agent, server_set, server, nick, debug, touchscreen, hash,
-        min = {}, public_http_path, port, ssl,
+        min = {}, public_http_path, port, ssl, host, obj, args,
         secure = (typeof request.client.encrypted === 'object');
 
     //try {
         if (kiwi.config.handle_http) {
+            // Run through any plugins..
+            args = {request: request, response: response};
+            obj = kiwi.kiwi_mod.run('http', args);
+            if (obj === null) {
+                return;
+            }
+            response = args.response;
+
             uri = url.parse(request.url, true);
             uri_parts = uri.pathname.split('/');
 
@@ -593,7 +601,7 @@ this.httpHandler = function (request, response) {
                 debug = (typeof uri.query.debug !== 'undefined');
 
                 port = 6667;
-                ssl = false;
+                ssl = (typeof request.socket.pair !== 'undefined');
                 if (uri_parts[1] !== 'client') {
                     if (uri.query) {
                         server_set = ((typeof uri.query.server !== 'undefined') && (uri.query.server !== ''));
@@ -701,6 +709,8 @@ this.websocketListen = function (ports, host, handler, key, cert) {
             hs.listen(port.number, host);
             console.log("Listening on %s:%d without SSL", host, port.number);
         }
+
+        kiwi.httpServers.push(hs);
     });
 
     _.each(kiwi.io, function (io) {
index a24e2a40de85c3713df1778c5d3e259f798ab86c..ec7e94ca3a2727eef1fdfe9128662e200510153d 100644 (file)
@@ -54,7 +54,7 @@ html(lang="en-gb")
                                         label(for="port") Port:
                                         input(type="text", id="port", name="port", class="port", value=port)
                                     li
-                                        label(for="password") Server password:
+                                        label(for="password") Password:
                                         input(type="text", id="password", name="password", class="password")
                                     li
                                         label(for="ssl") SSL:
@@ -159,7 +159,7 @@ html(lang="en-gb")
             
             
             function addEvents(){
-                $('.more_link').click(function(){ $('.content.bottom').slideDown('fast'); $('.network').focus(); return false; });
+                $('.more_link').click(function(){ $('.content.bottom').slideDown('fast'); $('.channel').focus(); return false; });
                 $('a.connect').click(function(){ $('.formconnectwindow').submit(); return false; });
 
                 var input_submit = function(e){
@@ -169,6 +169,7 @@ html(lang="en-gb")
                 $('.formconnectwindow .channel').keydown(input_submit);
                 $('.formconnectwindow .network').keydown(input_submit);
                 $('.formconnectwindow .port').keydown(input_submit);
+                $('.formconnectwindow .password').keydown(input_submit);
             }
 
 
diff --git a/node/kiwi_modules/forcessl.js b/node/kiwi_modules/forcessl.js
new file mode 100644 (file)
index 0000000..1b4d46d
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * forcessl Kiwi module
+ * Force clients to use an SSL port by redirecting them
+ */
+
+var kiwi = require('../kiwi.js');
+
+
+exports.onhttp = function (ev) {
+       // TODO: request.socket.pair seems to only be set in a SSL req, is this
+       // the best way to check for this?
+       if (typeof ev.request.socket.pair === 'undefined') {
+           host = ev.request.headers.host;
+           //port = 443;
+           
+           if (host.search(/:/)) {
+               //port = parseInt(host.substring(host.search(/:/) + 1), 10);
+               host = host.substring(0, host.search(/:/));
+           }
+           if (kiwi.config.ports[0].number != 443) {
+               for (i in kiwi.config.ports) {
+                       if (kiwi.config.ports[i].secure) {
+                               host += ':' + kiwi.config.ports[0].number.toString();
+                               break;
+                       }
+               }
+           }
+
+           console.log('https://' + host + ev.request.url);
+           ev.response.writeHead(302, {'Location': 'https://' + host + ev.request.url});
+           ev.response.end();
+
+           return null;
+       }
+
+       return ev;
+}
\ No newline at end of file