Created
February 19, 2013 10:26
-
-
Save clarif/4984688 to your computer and use it in GitHub Desktop.
Script used for the IPv6 Observatory study to monitor IPv6 on web clients.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* IPv6 observatory - Monitoring the worldwide deployment of IPv6 | |
* http://v6demon.ipv6observatory.eu - http://www.ipv6observatory.eu | |
* | |
* This script aims at measuring the actual deployemnt of IPv6 and is placed on various | |
* websites to check the IPv6 connectivity of web browsers. | |
* | |
* How its works: the script tries to access a remote image through 3 distincts URLs (IPv4 only, | |
* IPv6 only and IPv4/IPv6). The script is executed only once daily for each web client on a given website. | |
* | |
* For any request, please contact the IPv6 Observatory team through the contact | |
* form on the study website: http://www.ipv6observatory.eu/contact/ | |
* | |
* (c) inno TSD - 2013 - http://www.inno-group.com/ - http://www.ipv6observatory.eu/ | |
* | |
*/ | |
var IPv6Obs = { | |
uuid: function() { | |
// http://stackoverflow.com/a/2117523/243958 | |
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { | |
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8); | |
return v.toString(16); | |
}); | |
}, | |
imageUrl: function(prefix, uuid) { | |
// prefix: v4|v6|v4-v6 | |
return "http://demon-" + prefix + ".ipv6observatory.eu/" + (new Date).getTime() + "/1x1.gif?uuid=" + uuid + "&sid=" + "ABCDEFGH" ; | |
}, | |
performTest: function(url) { | |
var img = new Image(); | |
img.src = url; | |
}, | |
setCookie: function() { | |
var date = new Date(); | |
date.setTime(date.getTime()+(24*60*60*1000)); | |
var expires = "; expires="+date.toGMTString(); | |
document.cookie = "ipv6obsv8=1"+expires+"; path=/"; | |
}, | |
checkCookie: function() { | |
var cookies = document.cookie.split(';'); | |
for(var i=0;i < cookies.length;i++) { | |
var c = cookies[i]; | |
while (c.charAt(0)==' ') c = c.substring(1,c.length); | |
if (c.indexOf("ipv6obsv8=") == 0) return true; | |
} | |
return false; | |
}, | |
start: function() { | |
if (IPv6Obs.checkCookie() == false) { | |
IPv6Obs.setCookie(); | |
uuid = IPv6Obs.uuid(); | |
tests = ["v4", "v6", "v4-v6"]; | |
for (var i=0;i<tests.length;i++) { | |
IPv6Obs.performTest(IPv6Obs.imageUrl(tests[i], uuid)); | |
} | |
} | |
} | |
} | |
IPv6Obs.start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment