I am working on a chrome extension which is supposed to discover and then communicate with other devices in a local network. To discover them it needs to find out its own IP
see http://developer.chrome.com/extensions/webRequest.html for detail, my code example:
// get IP using webRequest
var currentIPList = {};
chrome.webRequest.onCompleted.addListener(
function(info) {
currentIPList[info.url] = info.ip;
currentIPList[info.tabId] = currentIPList[info.tabId] || [];
currentIPList[info.tabId].push(info);
return;
},
{
urls: [],
types: []
},
[]
);