Advertisement
rg443

speedsmart ping

Apr 19th, 2017
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. fetch("http://speedsmart.net/resources/serversJSON.php").then(function(r){return r.json()}).then(function(d){
  2. var sl=d.serverList.reverse(),i=0,l=sl.length;
  3. sl=sl.filter(function(a){return a.serverID!="31" && a.serverID!="32" });l=sl.length-1;
  4. function ping(_s) {
  5.    // console.log(_s);
  6.    var t1=new Date();
  7.    fetch(_s.ping_url, {method: 'HEAD', redirect: 'follow',mode:'no-cors', cache:'no-cache' }).then(function(r){if (r.ok) { return r.text()} else {return 'failed'}}).then(function(d){
  8.    console.log([i,new Date()-t1,_s.serverName, _s.ping_url.split('/')[2],_s.distance].join("\t"));
  9.    if (i<l) {i++;ping(sl[i])  }
  10.    }).catch(function(err) {
  11.     console.log(i,_s.serverName,'failed: '+ err,_s.serverID);
  12.     // console.log(err);
  13.     if (i<l) {i++;ping(sl[i])}
  14.   })
  15.      
  16.      
  17.  
  18.  
  19. }
  20. ping(sl[i]);
  21.  
  22. })
  23.  
  24. // http://speedsmart.net/resources/startupJSON.php  user_isp user_address closestServer
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement