@cryptotaxi247 / netdata-1 / commits / 90efd6e23

properly handle redirections from https netdata to http netdata

Costa Tsaousis (ktsaou) committed Sep 11, 2016 at 03:23 UTC 90efd6e2392153f7bb7133783e417a92fbc2eb21
3 files changed +33 -7
conf.d/health_alarm_notify.conf
+1
@@ -72,6 +72,7 @@ SEND_SLACK="YES"
72 # Login to slack.com and create an incoming webhook.
73 # You need only one for all your netdata servers.
74 # Without it, netdata cannot send slack notifications.
75 +# Get yours from: https://api.slack.com/incoming-webhooks
76 SLACK_WEBHOOK_URL=""
77
78 # if a role's recipients are not configured, a notification will be send to
web/goto-host-from-alarm.html
+27 -7
@@ -46,12 +46,22 @@
46 var gotoServerValidateRemaining = 0;
47 var gotoServerMiddleClick = false;
48 var gotoServerStop = false;
49 + var thisIsHttps = false;
50 + var urlsInHttp = 0;
51 function gotoServerValidateUrl(id, guid, url) {
52 var penaldy = 0;
51 - if(document.location.toString().startsWith('http://') && url.toString().startsWith('https://'))
52 - // we penalize https only if the current url is http
53 - // to allow the user walk through all its servers.
54 - penaldy = 500;
53 + var error = 'failed';
54 +
55 + if(thisIsHttps === false && url.toString().startsWith('https://')) {
56 + // we penalize https only if the current url is http
57 + // to allow the user walk through all its servers.
58 + penaldy = 500;
59 + }
60 +
61 + else if(thisIsHttps === true && url.toString().startsWith('http://')) {
62 + error = 'can\'t check';
63 + urlsInHttp++;
64 + }
65
66 var finalURL = netdataURL(url);
67
@@ -66,7 +76,7 @@
76 gotoServerStop = true;
77
78 if(gotoServerMiddleClick) {
69 - window.open(finalURL, '_blank');
79 + window.open(finalURL);
80 gotoServerMiddleClick = false;
81 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)';
82 }
@@ -75,11 +85,16 @@
85 }
86 }
87 else {
78 - document.getElementById(guid + '-' + id + '-status').innerHTML = "failed!";
88 + document.getElementById(guid + '-' + id + '-status').innerHTML = error;
89 gotoServerValidateRemaining--;
90 if(gotoServerValidateRemaining <= 0) {
91 gotoServerMiddleClick = false;
92 document.getElementById('gotoServerResponse').innerHTML = '<b>Sorry! I cannot find any operational URL for this server</b>';
93 +
94 + if(thisIsHttps === true && urlsInHttp > 0) {
95 + document.getElementById('gotoServerResponse').innerHTML += '<br/>redirecting myself to HTTP to allow checking';
96 + document.location = document.location.toString().replace('https://', 'http://');
97 + }
98 }
99 }
100 });
@@ -87,6 +102,11 @@
102 }
103
104 var netdataRegistryCallback = function(machines_array) {
105 + document.getElementById('message').innerHTML = 'These are the URLs this machine is known:';
106 +
107 + if(document.location.toString().startsWith('https://'))
108 + thisIsHttps = true;
109 +
110 if(machines_array) {
111 var len = machines_array.length;
112 while(len--) {
@@ -119,7 +139,7 @@
139 <body>
140 <div class="container" id="">
141 <div id="bodylog" style="padding-top: 8vmax; font-size: 2.0vmax;">
122 - Please wait...
142 + <span id="message">Please wait...</span>
143
144 <div style="padding-top: 20px;">
145 <table id="gotoServerList" class="table">
web/index.html
+5
@@ -1263,11 +1263,16 @@ var gotoServerMiddleClick = false;
1263 var gotoServerStop = false;
1264 function gotoServerValidateUrl(id, guid, url) {
1265 var penaldy = 0;
1266 + var error = 'failed';
1267 +
1268 if(document.location.toString().startsWith('http://') && url.toString().startsWith('https://'))
1269 // we penalize https only if the current url is http
1270 // to allow the user walk through all its servers.
1271 penaldy = 500;
1272
1273 + else if(document.location.toString().startsWith('https://') && url.toString().startsWith('http://'))
1274 + error = 'can\'t check';
1275 +
1276 var finalURL = netdataURL(url);
1277
1278 setTimeout(function() {