Browse Source

move to version 2 to avoid utp clashes fully (utp uses 1)

session-estimator
Mathias Buus 4 years ago
parent
commit
3f199cf981
  1. 4
      index.js
  2. 6
      lib/messages.js

4
index.js

@ -140,7 +140,7 @@ class DHT extends EventEmitter {
const token = to.token || (opts && opts.token) || null const token = to.token || (opts && opts.token) || null
return this.rpc.request({ return this.rpc.request({
version: 1, version: 2,
tid: 0, tid: 0,
from: null, from: null,
to, to,
@ -608,7 +608,7 @@ class DHT extends EventEmitter {
const closerNodes = target ? this.table.closest(target) : null const closerNodes = target ? this.table.closest(target) : null
const ephemeral = socket !== this.rpc.socket || this.ephemeral const ephemeral = socket !== this.rpc.socket || this.ephemeral
const reply = { const reply = {
version: 1, version: 2,
tid, tid,
from: null, from: null,
to, to,

6
lib/messages.js

@ -66,7 +66,7 @@ exports.message = {
(m.target ? HAS_TARGET : 0) | (m.target ? HAS_TARGET : 0) |
(m.command ? IS_REQUEST : 0) (m.command ? IS_REQUEST : 0)
state.buffer[state.start++] = 1 state.buffer[state.start++] = 2
state.buffer[state.start++] = flags state.buffer[state.start++] = flags
cenc.uint16.encode(state, m.tid) cenc.uint16.encode(state, m.tid)
@ -84,14 +84,14 @@ exports.message = {
decode (state) { decode (state) {
const version = state.buffer[state.start++] const version = state.buffer[state.start++]
if (version !== 1) { if (version !== 2) {
throw new Error('Incompatible version') throw new Error('Incompatible version')
} }
const flags = cenc.uint.decode(state) const flags = cenc.uint.decode(state)
return { return {
version: 1, version: 2,
tid: cenc.uint16.decode(state), tid: cenc.uint16.decode(state),
from: null, // populated in caller from: null, // populated in caller
to: peerIPv4.decode(state), to: peerIPv4.decode(state),

Loading…
Cancel
Save