You don't need an addon to get the IP addresses of your local network
interfaces. WebRTC offers the ability to get what you want from any normal
web page as shown at
https://stackoverflow.com/a/29514292/938089 .
If you're using the addon SDK, create a page-worker and use the getLocalIPs
function from the above link.
If you use WebExtensions, you have to insert a content script in the
current page (or open a new tab) and do your trick there, since WebRTC from
the background page seems to not be supported yet (at least not in Firefox
Nightly (50)).
Here is some sample code using the addon SDK (create the following files,
use jpm run and you'll see your local IP addresses printed in the console):
// index.js
var localIpWorker = require('sdk/page-worker').Page({
contentURL: require('sdk/self').data.url('getlocalips.html'),
});
// Example, get the IP addresses and print it to the console.
localIpWorker.port.once('getlocalips-result', ips => {
console.log('Local IP addresses:\n ' + ips.join('\n '));
});
localIpWorker.port.emit('getlocalips');
getlocalips.html (the page loaded in page-worker):
<script>
// ...put function getLocalIPs from
https://stackoverflow.com/a/29514292/938089 here...
addon.port.on('getlocalips', () => {
getLocalIPs(ips => addon.port.emit('getlocalips-result', ips));
});
</script>
Kind regards,
Rob
https://robwu.nl
> _______________________________________________
> dev-extensions mailing list
>
dev-ext...@lists.mozilla.org
>
https://lists.mozilla.org/listinfo/dev-extensions
>