(done)
| 292 | let ipCalled = false; // used to prevent multiple accidental calls to getIp |
| 293 | let ispInfo = ""; //used for telemetry |
| 294 | function getIp(done) { |
| 295 | tverb("getIp"); |
| 296 | if (ipCalled) return; |
| 297 | else ipCalled = true; // getIp already called? |
| 298 | let startT = new Date().getTime(); |
| 299 | xhr = new XMLHttpRequest(); |
| 300 | xhr.onload = function() { |
| 301 | tlog("IP: " + xhr.responseText + ", took " + (new Date().getTime() - startT) + "ms"); |
| 302 | try { |
| 303 | const data = JSON.parse(xhr.responseText); |
| 304 | clientIp = data.processedString; |
| 305 | ispInfo = data.rawIspInfo; |
| 306 | } catch (e) { |
| 307 | clientIp = xhr.responseText; |
| 308 | ispInfo = ""; |
| 309 | } |
| 310 | done(); |
| 311 | }; |
| 312 | xhr.onerror = function() { |
| 313 | tlog("getIp failed, took " + (new Date().getTime() - startT) + "ms"); |
| 314 | done(); |
| 315 | }; |
| 316 | xhr.open("GET", settings.url_getIp + url_sep(settings.url_getIp) + (settings.mpot ? "cors=true&" : "") + (settings.getIp_ispInfo ? "isp=true" + (settings.getIp_ispInfo_distance ? "&distance=" + settings.getIp_ispInfo_distance + "&" : "&") : "&") + "r=" + Math.random(), true); |
| 317 | xhr.send(); |
| 318 | } |
| 319 | // download test, calls done function when it's over |
| 320 | let dlCalled = false; // used to prevent multiple accidental calls to dlTest |
| 321 | function dlTest(done) { |
no test coverage detected