From 509e56a60359f98ec435f8519c6a499641cce212 Mon Sep 17 00:00:00 2001 From: Alex Potsides Date: Mon, 15 Aug 2022 09:20:05 +0100 Subject: [PATCH] fix: prepend connection addr to circuit relay address (#1355) Otherwise the reported remote addr is not valid --- src/circuit/transport.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/circuit/transport.ts b/src/circuit/transport.ts index eaa0f4a988..4fe69480e6 100644 --- a/src/circuit/transport.ts +++ b/src/circuit/transport.ts @@ -132,10 +132,10 @@ export class Circuit implements Transport, Initializable { } if (virtualConnection != null) { - // @ts-expect-error dst peer will not be undefined - const remoteAddr = new Multiaddr(request.dstPeer.addrs[0]) - // @ts-expect-error dst peer will not be undefined - const localAddr = new Multiaddr(request.srcPeer.addrs[0]) + const remoteAddr = connection.remoteAddr + .encapsulate('/p2p-circuit') + .encapsulate(new Multiaddr(request.dstPeer?.addrs[0])) + const localAddr = new Multiaddr(request.srcPeer?.addrs[0]) const maConn = streamToMaConnection({ stream: virtualConnection, remoteAddr,