From 23646982146e245e23aa68fbfcc207d08194d15c Mon Sep 17 00:00:00 2001 From: Diego Date: Fri, 3 Nov 2023 17:33:36 +0100 Subject: [PATCH] add ping --- hole-punch-interop/impl/nim/hole_punching.nim | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hole-punch-interop/impl/nim/hole_punching.nim b/hole-punch-interop/impl/nim/hole_punching.nim index ddd7ff4f5..ea5fa0f9f 100644 --- a/hole-punch-interop/impl/nim/hole_punching.nim +++ b/hole-punch-interop/impl/nim/hole_punching.nim @@ -11,10 +11,12 @@ import libp2p/[builders, protocols/connectivity/autonat/service] import libp2p/protocols/connectivity/relay/client as rclient import tests/stubs/autonatclientstub +import libp2p/protocols/ping proc createSwitch(r: Relay = nil, hpService: Service = nil): Switch = + let rng = newRng() var builder = SwitchBuilder.new() - .withRng(newRng()) + .withRng(rng) .withAddresses(@[ MultiAddress.init("/ip4/0.0.0.0/tcp/0").tryGet() ]) .withObservedAddrManager(ObservedAddrManager.new(minCount = 1)) .withTcpTransport() @@ -28,7 +30,9 @@ proc createSwitch(r: Relay = nil, hpService: Service = nil): Switch = if r != nil: builder = builder.withCircuitRelay(r) - return builder.build() + let s = builder.build() + s.mount(Ping.new(rng=rng)) + return s proc main() {.async.} = let relayClient = RelayClient.new()