eBlogzilla
Showing posts with label IP address. Show all posts
Showing posts with label IP address. Show all posts

Saturday, September 12, 2009

How to get local IP address

Some time ago I was need to detect local IP address of the machine where my Firefox add-on is installed. I've not found complete example. Finally, I've found the next solution:

var dnsService = Components.classes["@mozilla.org/network/dns-service;1"].
getService(Components.interfaces.nsIDNSService);
var ip = dnsService.resolve(dnsService.myHostName, false).getNextAddrAsString();

Nothing difficult!