node/test/mjsunit/disabled/test_dns.js

30 lines
882 B
JavaScript
Raw Normal View History

2009-10-30 06:59:35 +08:00
process.mixin(require("../common.js"));
2009-10-29 06:02:52 +08:00
var dns = require("/dns.js");
2009-10-30 06:59:35 +08:00
for (var i = 2; i < process.ARGV.length; i++) {
var name = process.ARGV[i]
puts("looking up " + name);
2009-10-29 06:02:52 +08:00
var resolution = dns.resolve4(name);
resolution.addCallback(function (addresses, ttl, cname) {
puts("addresses: " + JSON.stringify(addresses));
puts("ttl: " + JSON.stringify(ttl));
puts("cname: " + JSON.stringify(cname));
for (var i = 0; i < addresses.length; i++) {
var a = addresses[i];
2009-10-29 06:02:52 +08:00
var reversing = dns.reverse(a);
reversing.addCallback( function (domains, ttl, cname) {
puts("reverse for " + a + ": " + JSON.stringify(domains));
});
reversing.addErrback( function (code, msg) {
puts("reverse for " + a + " failed: " + msg);
});
}
});
resolution.addErrback(function (code, msg) {
puts("error: " + msg);
});
}