我试图制作DNS requests(解决和反转)并对结果进行断言。
我连续运行了两个类似的自定义命令,两个执行dns.setServers()功能都能为每个查询设置不同的DNS服务器。
我遇到了这个已知问题:
node: ../deps/cares/src/ares_destroy.c:102: ares__destroy_servers_state: Assertion ares__is_list_empty(&server->queries_to_server)' failed.
因为它似乎无法解决nodejs#894 - > c-ares#41
我正在寻找解决方案,这是代码:
自定义命令 dnsresolve :
var util = require('util');
var events = require('events');
var dns = require ('dns');
var dnsresolve = function() {
events.EventEmitter.call(this);
};
util.inherits(dnsresolve, events.EventEmitter);
dnsresolve.prototype.command = function(server, hostname, rrtype, callback) {
var self = this;
var server = server.split();
dns.resolve(hostname, rrtype, function(err, result) {
dns.setServers(server);
if (result) {
callback(result);
} else {
callback(err.code);
}
self.emit('complete');
});
return this;
};
module.exports = dnsresolve;
自定义命令 dnsreverse :
var util = require('util');
var events = require('events');
var dns = require ('dns');
var dnsreverse = function() {
events.EventEmitter.call(this);
};
util.inherits(dnsreverse, events.EventEmitter);
dnsreverse.prototype.command = function(server, ip, callback) {
var self = this;
var server = server.split();
dns.reverse(ip, function(err, result) {
dns.setServers(server);
if (result) {
callback(result);
} else {
callback(err.code);
}
self.emit('complete');
});
return this;
};
module.exports = dnsreverse;
自定义命令调用:
'Browse' : function (browser) {
browser
.url('http://' + browser.globals.network.interfaces.em0.ip)
.waitForElementVisible('#frameContent', 2000)
.dnsresolve(browser.globals.network.interfaces.em0.ip, 'my.record', 'A', function(result) {
browser.verify.equal(result, '1.1.1.1')
})
.dnsreverse(browser.globals.network.interfaces.em0.ip, '1.1.1.1', function(result) {
browser.verify.equal(result, 'my.record')
})
}
使用其他节点模块不是解决方案。
答案 0 :(得分:0)
我刚刚制作了这些命令,一些自定义断言:
def EasyText(field_class="medium", readonly=False, placeholder='', extras={}, **kwargs):
textarea = forms.CharField(widget=TextareaWidget(attrs={'class':field_class, 'readonly':readonly, 'placeholder': placeholder}))
if extras:
textarea.widget.attrs.update(**extras)
try: textarea.label = kwargs['label']
except KeyError: pass
try: textarea.required = kwargs['required']
except KeyError: textarea.required = False
return textarea
添加' .pause(10)'是技巧,没有找到合适的方法。