From 159679e5ebd1b7f6280af11ddc34520d7f7b8e3d Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Thu, 25 Aug 2016 18:35:03 -0700 Subject: [PATCH] pool: keep hostname on net addr. --- lib/net/packets.js | 7 +++++++ lib/net/pool.js | 2 ++ 2 files changed, 9 insertions(+) diff --git a/lib/net/packets.js b/lib/net/packets.js index 4222ea45..1f086f43 100644 --- a/lib/net/packets.js +++ b/lib/net/packets.js @@ -794,6 +794,7 @@ function NetworkAddress(options) { this.port = 0; this.services = 0; this.ts = 0; + this.hostname = '0.0.0.0:0'; if (options) this.fromOptions(options); @@ -835,6 +836,8 @@ NetworkAddress.prototype.fromOptions = function fromOptions(options) { this.ts = options.ts; } + this.hostname = IP.hostname(this.host, this.port); + return this; }; @@ -926,6 +929,8 @@ NetworkAddress.prototype.fromHostname = function fromHostname(hostname, network) | constants.services.WITNESS; this.ts = bcoin.now(); + this.hostname = IP.hostname(this.host, this.port); + return this; }; @@ -961,6 +966,8 @@ NetworkAddress.prototype.fromRaw = function fromRaw(data, full) { if (this.ts <= 100000000 || this.ts > now + 10 * 60) this.ts = now - 5 * 24 * 60 * 60; + this.hostname = IP.hostname(this.host, this.port); + return this; }; diff --git a/lib/net/pool.js b/lib/net/pool.js index 60c0aaf1..43df8be3 100644 --- a/lib/net/pool.js +++ b/lib/net/pool.js @@ -171,6 +171,7 @@ Pool.prototype._initOptions = function _initOptions() { this.address.ts = utils.now(); this.address.services = this.services; this.address.port = this.port; + this.address.hostname = IP.hostname(this.address.host, this.port); if (this.options.maxPeers != null) this.maxPeers = this.options.maxPeers; @@ -320,6 +321,7 @@ Pool.prototype._open = function _open(callback) { if (ip) { self.address.host = ip; + self.address.hostname = IP.hostname(ip, self.address.port); self.logger.info('External IP found: %s.', ip); }