Add separate dns-specific bootstrap method
This commit is contained in:
parent
e52e226662
commit
06df8c42b3
|
@ -220,19 +220,28 @@ function resolveDnsSeed(seed) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TcpTransport.prototype.bootstrap = function() {
|
TcpTransport.prototype.bootstrap = function() {
|
||||||
var promises = this.dnsSeeds.map(resolveDnsSeed);
|
|
||||||
var hardcodedNodes = this.seeds;
|
var hardcodedNodes = this.seeds;
|
||||||
// FIXME(Kagami): Filter incorrect/private IP range nodes?
|
// FIXME(Kagami): Filter incorrect/private IP range nodes?
|
||||||
// See also: <https://github.com/Bitmessage/PyBitmessage/issues/768>.
|
// See also: <https://github.com/Bitmessage/PyBitmessage/issues/768>.
|
||||||
return PPromise.all(promises).then(function(dnsNodes) {
|
return this.bootstrapDns().then(function(dnsNodes) {
|
||||||
// Flatten array of arrays.
|
|
||||||
dnsNodes = Array.prototype.concat.apply([], dnsNodes);
|
|
||||||
// Add hardcoded nodes to the end of list because DNS nodes should
|
// Add hardcoded nodes to the end of list because DNS nodes should
|
||||||
// be more up-to-date.
|
// be more up-to-date.
|
||||||
return dnsNodes.concat(hardcodedNodes);
|
return dnsNodes.concat(hardcodedNodes);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do only DNS-specific bootstrap.
|
||||||
|
* @return {Promise.<Array>} Discovered seed nodes.
|
||||||
|
*/
|
||||||
|
TcpTransport.prototype.bootstrapDns = function() {
|
||||||
|
var promises = this.dnsSeeds.map(resolveDnsSeed);
|
||||||
|
return PPromise.all(promises).then(function(dnsNodes) {
|
||||||
|
// Flatten array of arrays.
|
||||||
|
return Array.prototype.concat.apply([], dnsNodes);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connect to a TCP node. Connection arguments are the same as for
|
* Connect to a TCP node. Connection arguments are the same as for
|
||||||
* [net.connect](http://nodejs.org/api/net.html#net_net_connect_port_host_connectlistener).
|
* [net.connect](http://nodejs.org/api/net.html#net_net_connect_port_host_connectlistener).
|
||||||
|
|
Loading…
Reference in New Issue
Block a user