myip.js: make everything functions

same issue with v6 :(
This commit is contained in:
Aminda Suomalainen 2015-09-30 08:50:25 +03:00
parent 51f775913d
commit a886bb4f73

View File

@ -3,11 +3,13 @@
// Require the dns module // Require the dns module
var dns = require('dns'); var dns = require('dns');
// Function for IPv4
var myip4 = function () {
// Set DNS servers to OpenDNS IPv4 // Set DNS servers to OpenDNS IPv4
var servers4 = dns.setServers(["208.67.222.222", "208.67.220.220"]) var servers4 = dns.setServers(["208.67.222.222", "208.67.220.220"])
// Check where myip.opendns.com resolves to and I think this is a function // Check where myip.opendns.com resolves to and I think this is a
// that takes arguments err and addresses. // function that takes arguments err and addresses.
dns.resolve4('myip.opendns.com', function (err, addresses) { dns.resolve4('myip.opendns.com', function (err, addresses) {
// if err contains a truthy value, an error has occurred // if err contains a truthy value, an error has occurred
@ -18,15 +20,14 @@ dns.resolve4('myip.opendns.com', function (err, addresses) {
console.log(addresses[0]); console.log(addresses[0]);
}); });
}
// This code makes node codedump for some reason, maybe it has a bug // IPv6 part is broken because of node bug.
// with IPv6 handling or it doesn't like my system not having native // https://github.com/nodejs/node/issues/894
// or not-Teredo IPv6 connectivity.
// node: ../deps/cares/src/ares_destroy.c:102: ares__destroy_servers_state: Assertion `ares__is_list_empty(&server->queries_to_server)' failed.
// zsh: abort (core dumped) ./myip.js
/* /*
// Function for IPv6
var myip6 = function () {
// Set DNS servers to OpenDNS IPv6 // Set DNS servers to OpenDNS IPv6
var servers6 = dns.setServers(["2620:0:ccc::2", "2620:0:ccd::2"]) var servers6 = dns.setServers(["2620:0:ccc::2", "2620:0:ccd::2"])
@ -43,4 +44,9 @@ dns.resolve6('myip.opendns.com', function (err, addresses) {
console.log(addresses[0]); console.log(addresses[0]);
}); });
}
*/ */
// Call the functions
myip4();
//myip6();