Add separate dns-specific bootstrap method

This commit is contained in:
Kagami Hiiragi 2015-02-19 17:16:41 +03:00
parent e52e226662
commit 06df8c42b3

View File

@ -220,19 +220,28 @@ function resolveDnsSeed(seed) {
}
TcpTransport.prototype.bootstrap = function() {
var promises = this.dnsSeeds.map(resolveDnsSeed);
var hardcodedNodes = this.seeds;
// FIXME(Kagami): Filter incorrect/private IP range nodes?
// See also: <https://github.com/Bitmessage/PyBitmessage/issues/768>.
return PPromise.all(promises).then(function(dnsNodes) {
// Flatten array of arrays.
dnsNodes = Array.prototype.concat.apply([], dnsNodes);
return this.bootstrapDns().then(function(dnsNodes) {
// Add hardcoded nodes to the end of list because DNS nodes should
// be more up-to-date.
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
* [net.connect](http://nodejs.org/api/net.html#net_net_connect_port_host_connectlistener).