From 06df8c42b3accb8d437523155bb905d711adab47 Mon Sep 17 00:00:00 2001 From: Kagami Hiiragi Date: Thu, 19 Feb 2015 17:16:41 +0300 Subject: [PATCH] Add separate dns-specific bootstrap method --- lib/net/tcp.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/net/tcp.js b/lib/net/tcp.js index 5be58b7..d778de3 100644 --- a/lib/net/tcp.js +++ b/lib/net/tcp.js @@ -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: . - 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.} 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).