|
73 | 73 | var penaldy = 0; |
74 | 74 | var error = 'failed'; |
75 | 75 |
|
76 | | - if(thisIsHttps === false && url.toString().startsWith('https://')) { |
| 76 | + if(thisIsHttps === false && url.toString().startsWith('https://')) |
77 | 77 | // we penalize https only if the current url is http |
78 | 78 | // to allow the user walk through all its servers. |
79 | 79 | penaldy = 500; |
80 | | - } |
81 | 80 |
|
82 | 81 | else if(thisIsHttps === true && url.toString().startsWith('http://')) { |
83 | 82 | error = 'can\'t check'; |
|
90 | 89 | document.getElementById('gotoServerList').innerHTML += '<tr><td style="padding-left: 20px;"><a href="' + finalURL + '" target="_blank">' + url + '</a></td><td style="padding-left: 30px;"><code id="' + guid + '-' + id + '-status">checking...</code></td></tr>'; |
91 | 90 |
|
92 | 91 | NETDATA.registry.hello(url, function(data) { |
93 | | - if (data) { |
| 92 | + if(typeof data !== 'undefined' && data !== null && typeof data.machine_guid === 'string' && data.machine_guid === guid) { |
| 93 | + // console.log('OK ' + id + ' URL: ' + url); |
94 | 94 | document.getElementById(guid + '-' + id + '-status').innerHTML = "OK"; |
95 | 95 |
|
96 | 96 | if(!gotoServerStop) { |
|
101 | 101 | gotoServerMiddleClick = false; |
102 | 102 | 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)'; |
103 | 103 | } |
104 | | - else |
| 104 | + else { |
| 105 | + document.getElementById('gotoServerResponse').innerHTML += 'found it! It is at:<br/><small>' + url + '</small>'; |
105 | 106 | document.location = finalURL; |
| 107 | + } |
106 | 108 | } |
107 | 109 | } |
108 | 110 | else { |
| 111 | + if(typeof data !== 'undefined' && data !== null && typeof data.machine_guid === 'string' && data.machine_guid !== guid) |
| 112 | + error = 'wrong machine'; |
| 113 | + |
109 | 114 | document.getElementById(guid + '-' + id + '-status').innerHTML = error; |
110 | 115 | gotoServerValidateRemaining--; |
111 | 116 | if(gotoServerValidateRemaining <= 0) { |
|
134 | 139 | thisIsHttps = true; |
135 | 140 |
|
136 | 141 | if(machines_array) { |
| 142 | + var guids = {}; |
| 143 | + var checked = {}; |
137 | 144 | var len = machines_array.length; |
| 145 | + var count = 0; |
| 146 | + |
138 | 147 | while(len--) { |
139 | 148 | if(machines_array[len].name === urlOptions.host) { |
140 | 149 | var ulen = machines_array[len].alternate_urls.length; |
| 150 | + var guid = machines_array[len].guid; |
| 151 | + guids[guid] = true; |
| 152 | + |
141 | 153 | gotoServerValidateRemaining = ulen; |
142 | | - while(ulen--) |
143 | | - gotoServerValidateUrl(ulen, machines_array[len].guid, machines_array[len].alternate_urls[ulen]); |
144 | | - return; |
| 154 | + while(ulen--) { |
| 155 | + var url = machines_array[len].alternate_urls[ulen]; |
| 156 | + checked[url] = true; |
| 157 | + gotoServerValidateUrl(count++, guid, url); |
| 158 | + } |
| 159 | + |
| 160 | + setTimeout(function() { |
| 161 | + if(gotoServerStop === false) { |
| 162 | + document.getElementById('gotoServerResponse').innerHTML = '<b>Added all the known URLs for this machine.</b>'; |
| 163 | + var guid; |
| 164 | + for(guid in guids) { |
| 165 | + NETDATA.registry.search(guid, function(data) { |
| 166 | + // console.log(data); |
| 167 | + len = data.urls.length; |
| 168 | + while(len--) { |
| 169 | + var url = data.urls[len][1]; |
| 170 | + // console.log(url); |
| 171 | + if(typeof checked[url] === 'undefined') { |
| 172 | + gotoServerValidateRemaining++; |
| 173 | + checked[url] = true; |
| 174 | + gotoServerValidateUrl(count++, guid, url); |
| 175 | + } |
| 176 | + } |
| 177 | + }); |
| 178 | + } |
| 179 | + } |
| 180 | + }, 2000); |
| 181 | + |
| 182 | + return false; |
145 | 183 | } |
146 | 184 | } |
147 | 185 | } |
|
0 commit comments