]> arthur.barton.de Git - netdata.git/commitdiff
properly handle redirections from https netdata to http netdata
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sun, 11 Sep 2016 00:23:01 +0000 (03:23 +0300)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sun, 11 Sep 2016 00:23:01 +0000 (03:23 +0300)
conf.d/health_alarm_notify.conf
web/goto-host-from-alarm.html
web/index.html

index 0e3d23f9b1badd715eda31c5a110e45df08fd39a..84e0b2111a1ce736da4f1cb61b16c7fe0f624015 100644 (file)
@@ -72,6 +72,7 @@ SEND_SLACK="YES"
 # Login to slack.com and create an incoming webhook.
 # You need only one for all your netdata servers.
 # Without it, netdata cannot send slack notifications.
+# Get yours from: https://api.slack.com/incoming-webhooks
 SLACK_WEBHOOK_URL=""
 
 # if a role's recipients are not configured, a notification will be send to
index e1849bc3f60bb2ce2d9793596fd9a2ca3f550bfd..987ee11ee5390e0f73d98d21f01cb6131a6f063f 100755 (executable)
     var gotoServerValidateRemaining = 0;
     var gotoServerMiddleClick = false;
     var gotoServerStop = false;
+    var thisIsHttps = false;
+    var urlsInHttp = 0;
     function gotoServerValidateUrl(id, guid, url) {
         var penaldy = 0;
-        if(document.location.toString().startsWith('http://') && url.toString().startsWith('https://'))
-                // we penalize https only if the current url is http
-                // to allow the user walk through all its servers.
-                penaldy = 500;
+        var error = 'failed';
+
+        if(thisIsHttps === false && url.toString().startsWith('https://')) {
+            // we penalize https only if the current url is http
+            // to allow the user walk through all its servers.
+            penaldy = 500;
+        }
+
+        else if(thisIsHttps === true && url.toString().startsWith('http://')) {
+            error = 'can\'t check';
+            urlsInHttp++;
+        }
 
         var finalURL = netdataURL(url);
 
@@ -66,7 +76,7 @@
                         gotoServerStop = true;
 
                         if(gotoServerMiddleClick) {
-                            window.open(finalURL, '_blank');
+                            window.open(finalURL);
                             gotoServerMiddleClick = false;
                             document.getElementById('gotoServerResponse').innerHTML = '<b>Opening new window to ' + NETDATA.registry.machines[guid].name + '<br/><a href="' + finalURL + '">' + url + '</a></b><br/>(check your pop-up blocker if it fails)';
                         }
                     }
                 }
                 else {
-                    document.getElementById(guid + '-' + id + '-status').innerHTML = "failed!";
+                    document.getElementById(guid + '-' + id + '-status').innerHTML = error;
                     gotoServerValidateRemaining--;
                     if(gotoServerValidateRemaining <= 0) {
                         gotoServerMiddleClick = false;
                         document.getElementById('gotoServerResponse').innerHTML = '<b>Sorry! I cannot find any operational URL for this server</b>';
+
+                        if(thisIsHttps === true && urlsInHttp > 0) {
+                            document.getElementById('gotoServerResponse').innerHTML += '<br/>redirecting myself to HTTP to allow checking';
+                            document.location = document.location.toString().replace('https://', 'http://');
+                        }
                     }
                 }
             });
     }
 
     var netdataRegistryCallback = function(machines_array) {
+        document.getElementById('message').innerHTML = 'These are the URLs this machine is known:';
+
+        if(document.location.toString().startsWith('https://'))
+            thisIsHttps = true;
+
         if(machines_array) {
             var len = machines_array.length;
             while(len--) {
 <body>
 <div class="container" id="">
     <div id="bodylog" style="padding-top: 8vmax; font-size: 2.0vmax;">
-        Please wait...
+        <span id="message">Please wait...</span>
 
         <div style="padding-top: 20px;">
             <table id="gotoServerList" class="table">
index df54b3e043c84cc7d29e1da0c30fa163511595b1..8f31ae54279875dbb9c7d0623ee14e47125f8470 100644 (file)
@@ -1263,11 +1263,16 @@ var gotoServerMiddleClick = false;
 var gotoServerStop = false;
 function gotoServerValidateUrl(id, guid, url) {
     var penaldy = 0;
+    var error = 'failed';
+
     if(document.location.toString().startsWith('http://') && url.toString().startsWith('https://'))
             // we penalize https only if the current url is http
             // to allow the user walk through all its servers.
             penaldy = 500;
 
+    else if(document.location.toString().startsWith('https://') && url.toString().startsWith('http://'))
+        error = 'can\'t check';
+    
     var finalURL = netdataURL(url);
 
     setTimeout(function() {