diff --git a/nodejs/myip.js b/nodejs/myip.js index 328c788..eff6da4 100755 --- a/nodejs/myip.js +++ b/nodejs/myip.js @@ -3,12 +3,14 @@ // Require the dns module var dns = require('dns'); -// Set DNS servers to OpenDNS IPv4 -var servers4 = dns.setServers(["208.67.222.222", "208.67.220.220"]) +// Function for IPv4 +var myip4 = function () { + // Set DNS servers to OpenDNS IPv4 + 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 -// that takes arguments err and addresses. -dns.resolve4('myip.opendns.com', function (err, addresses) { + // Check where myip.opendns.com resolves to and I think this is a + // function that takes arguments err and addresses. + dns.resolve4('myip.opendns.com', function (err, addresses) { // if err contains a truthy value, an error has occurred if (err) throw err; @@ -17,23 +19,22 @@ dns.resolve4('myip.opendns.com', function (err, addresses) { // address. console.log(addresses[0]); -}); + }); +} -// This code makes node codedump for some reason, maybe it has a bug -// with IPv6 handling or it doesn't like my system not having native -// 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 +// IPv6 part is broken because of node bug. +// https://github.com/nodejs/node/issues/894 /* +// Function for IPv6 +var myip6 = function () { -// Set DNS servers to OpenDNS IPv6 -var servers6 = dns.setServers(["2620:0:ccc::2", "2620:0:ccd::2"]) + // Set DNS servers to OpenDNS IPv6 + var servers6 = dns.setServers(["2620:0:ccc::2", "2620:0:ccd::2"]) -// Check where myip.opendns.com resolves to and I think this is a function -// that takes arguments err and addresses. -dns.resolve6('myip.opendns.com', function (err, addresses) { + // Check where myip.opendns.com resolves to and I think this is a function + // that takes arguments err and addresses. + dns.resolve6('myip.opendns.com', function (err, addresses) { // if err contains a truthy value, an error has occurred if (err) throw err; @@ -42,5 +43,10 @@ dns.resolve6('myip.opendns.com', function (err, addresses) { // address. console.log(addresses[0]); -}); + }); +} */ + +// Call the functions +myip4(); +//myip6();