Such webservices like whatismyip.com uses javascript to determine your local ip address. Following is the code extracted from the site you mentioned above:
function checkLocal() {
window.RTCPeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection; //compatibility for firefox and chrome
var pc = new RTCPeerConnection({iceServers: []}), noop = function () {
};
pc.createDataChannel(""); //create a bogus data channel
pc.createOffer(pc.setLocalDescription.bind(pc), noop); // create offer and set local description
pc.onicecandidate = function (ice) { //listen for candidate events
if (!ice || !ice.candidate || !ice.candidate.candidate) return;
//reads out local ip
var myIP = /([0-9]{1,3}(\.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})/.exec(ice.candidate.candidate)[1];
jQuery(document).ready(function () {
jQuery("#local-ip").append("Your Local IP is: " + myIP);
jQuery("#local-ip").show("slow");
});
pc.onicecandidate = noop;
};
}
The code binds to your pc (pc is self refering), but with the interface you are capable of reading out the socket details and that includes the local ip under which your computer is known in your local area network. That's a common practice to get your local ip address. It's new to me that can be done with javascript.
For more information about the RTCPeerConnection
js API: https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection