diff --git a/lib/connect.js b/lib/connect.js index 218e98fa..bde333c5 100644 --- a/lib/connect.js +++ b/lib/connect.js @@ -322,7 +322,7 @@ async function connectThroughNode (c, address, socket) { const hs = c.handshake.final() - if (c.relayThrough) { + if (c.relayThrough || payload.relayThrough) { // TODO } diff --git a/lib/server.js b/lib/server.js index 8b27ac9a..7966e6c4 100644 --- a/lib/server.js +++ b/lib/server.js @@ -26,6 +26,7 @@ module.exports = class Server extends EventEmitter { this.closed = false this.firewall = opts.firewall || (() => false) this.holepunch = opts.holepunch || (() => true) + this.relayThrough = opts.relayThrough || null this.createHandshake = opts.createHandshake || defaultCreateHandshake this.createSecretStream = opts.createSecretStream || defaultCreateSecretStream @@ -234,7 +235,8 @@ module.exports = class Server extends EventEmitter { id: hs.rawStream ? hs.rawStream.id : 0, seq: 0 }, - secretStream: {} + secretStream: {}, + relayThrough: this.relayThrough?.remotePublicKey || null }) } catch (err) { safetyCatch(err) @@ -255,7 +257,7 @@ module.exports = class Server extends EventEmitter { return hs } - if (remotePayload.relayThrough) { + if (this.relayThrough || remotePayload.relayThrough) { // TODO }