OpenShift:使用nodejs实现DNS客户端时出错

时间:2016-12-03 11:26:52

标签: node.js openshift

我正在使用Nodejs在OpenShift上实现DNS Lookup客户端,而“native-dns”是npm模块。但是,每当我尝试使用8.8.8.8作为DNS服务器IP查找域的DNS记录时,我都会收到以下提到的错误。

  

events.js:72           扔掉//未处理的'错误'事件                 ^错误:绑定EACCES       在errnoException(dgram.js:458:11)       在dgram.js:211:28       在dns.js:72:18       at process._tickCallback(node.js:442:13)

该功能的代码如下

function DNS_Domain_Lookup_function(dns,domain_name,rbl, ns_ip, record_type ,DNS_cb) {
    var dns_response = '';
    var question = dns.Question({
        name: domain_name + rbl,
        type: record_type,
    });

    var req = dns.Request({
        question: question,
        server: { address: ns_ip, port: 53, type: 'udp' },
        timeout: 4000,
    });
    req.on('timeout', function () {
        if (rbl === '') {
            rbl='query'
        }
        dns_response = { question: [ { name: domain_name + ',' + rbl} ], answer: [ { name: rbl, address: 'timeout' } ]};//Clean(2)
        DNS_cb(dns_response); //work on this to get the exact output
    });
    req.on('message', function (err, answer) {
        rbl !== '' ? (answer.question[0].name = domain_name + ',' + rbl) : (answer.question[0].name = domain_name);
        DNS_cb(answer);
    });
    req.on('end', function () {
    });
    req.send();
}

0 个答案:

没有答案