Browse Source

add to field to all node objects for easier nat stuff

session-estimator
Mathias Buus 4 years ago
parent
commit
0133d5c402
  1. 8
      index.js
  2. 3
      lib/query.js

8
index.js

@ -501,8 +501,8 @@ class DHT extends EventEmitter {
// if the node is indicating that we got a new ip
// make sure to add it again to the sampler. make sure we don't allow the remote node
// to add multiple entries though.
if (oldNode.network !== m.to.host) {
oldNode.network = m.to.host
if (oldNode.to === null || oldNode.to.host !== m.to.host) {
oldNode.to = m.to
// TODO: would be technically better to add to the head of the sample queue, but
// this is prop fine
const s = this._nat.sample(m.from)
@ -527,9 +527,9 @@ class DHT extends EventEmitter {
port: m.from.port,
host: m.from.host,
token: null, // adding this so it has the same "shape" as the query nodes for easier debugging
to: m.to,
added: this._tick,
seen: this._tick,
network: m.to.host,
prev: null,
next: null
})
@ -598,9 +598,9 @@ class DHT extends EventEmitter {
port,
host,
token: null,
to: null,
added: this._tick,
seen: this._tick,
network: null,
prev: null,
next: null
})

3
lib/query.js

@ -162,7 +162,8 @@ module.exports = class Query extends Readable {
id: m.id,
host: m.from.host,
port: m.from.port,
token: m.token
token: m.token,
to: m.to
})
}

Loading…
Cancel
Save