2015-04-18 47 views
0

我在Node.js 0.12.2上。Node.js - 无法获取DNS SOA记录

当我打电话给dns.resolve('example.com', 'SOA', function() {})时,我收到一个错误“Unknown type SOA”。
当我拨打dns.resolveSoa()时会发生同样的情况。

除了这个以外,其他所有记录类型都有效。

它只是我或为什么不工作?

回答

0

这不仅仅是你。即使文档清楚地声明支持SOA记录,我也遇到了同样的错误。谢天谢地,我找到了一个替代品:native-dns。这是一个应该让你走上正确轨道的例子。第一:

$ npm install native-dns 

然后,在节点:

var dns = require('native-dns'); 

var question = dns.Question({ 
    name: 'www.google.com', 
    type: 'SOA', 
}); 

var req = dns.Request({ 
    question: question, 
    server: { address: '8.8.8.8', port: 53, type: 'udp' }, 
    timeout: 1000, 
}); 

req.on('timeout', function() { 
    console.log('Timeout in making request'); 
}); 

req.on('message', function (err, answer) { 
    if (err) { throw err; } 
    console.log(answer); 
}); 

req.on('end', function() { 
    console.log('Finished processing request'); 
}); 

req.send();