From f350479824c7d6ffcf6238e9bdef27e9629bc4bb Mon Sep 17 00:00:00 2001 From: Ludovic Chenut Date: Tue, 24 Oct 2023 17:20:27 +0200 Subject: [PATCH] update pinned + fixes --- .pinned | 2 +- libp2p/transports/webrtctransport.nim | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.pinned b/.pinned index 661f150e5..c42587ec1 100644 --- a/.pinned +++ b/.pinned @@ -15,6 +15,6 @@ serialization;https://github.com/status-im/nim-serialization@#4bdbc29e54fe540499 stew;https://github.com/status-im/nim-stew@#3159137d9a3110edb4024145ce0ba778975de40e testutils;https://github.com/status-im/nim-testutils@#dfc4c1b39f9ded9baf6365014de2b4bfb4dafc34 unittest2;https://github.com/status-im/nim-unittest2@#2300fa9924a76e6c96bc4ea79d043e3a0f27120c -webrtc;https://github.com/status-im/nim-webrtc.git@#0504d863407c1d14bf39478ba2335d299caac6ef +webrtc;https://github.com/status-im/nim-webrtc.git@#a36708a5a0103f7dbbca85f7021eab864cc6cca0 websock;https://github.com/status-im/nim-websock@#f8ed9b40a5ff27ad02a3c237c4905b0924e3f982 zlib;https://github.com/status-im/nim-zlib@#a2f44bb7f65571a894227ff6fde9298a104e03a5 diff --git a/libp2p/transports/webrtctransport.nim b/libp2p/transports/webrtctransport.nim index 4e673e871..529fbc176 100644 --- a/libp2p/transports/webrtctransport.nim +++ b/libp2p/transports/webrtctransport.nim @@ -19,6 +19,8 @@ import transport, ../errors, ../wire, ../multicodec, + ../multihash, + ../multibase, ../protobuf/minprotobuf, ../connmanager, ../muxers/muxer, @@ -28,7 +30,7 @@ import transport, ../protocols/secure/noise, ../utility -import webrtc/webrtc, webrtc/datachannel +import webrtc/webrtc, webrtc/datachannel, webrtc/dtls/dtls logScope: topics = "libp2p webrtctransport" @@ -345,10 +347,12 @@ method start*( self.servers &= server let - cert = server.dtlsLocalCertificate() + cert = server.dtls.localCertificate() certHash = MultiHash.digest("sha2-256", cert).get().data.buffer encodedCertHash = MultiBase.encode("base64", certHash).get() - self.addrs[i] = (MultiAddress.init(server.udp.laddr, IPPROTO_UDP).tryGet() & MultiAddress.init(multiCodec("webrtc-direct")).tryGet() & MultiAddress.init(multiCodec("cert-hash"), encodedCertHash).tryGet()).tryGet() + self.addrs[i] = MultiAddress.init(server.udp.laddr, IPPROTO_UDP).tryGet() & + MultiAddress.init(multiCodec("webrtc-direct")).tryGet() & + MultiAddress.init(multiCodec("certhash"), certHash).tryGet() trace "Listening on", address = self.addrs[i] @@ -377,17 +381,14 @@ proc connHandler(self: WebRtcTransport, for f in futs: if not f.finished: await f.cancelAndWait() # cancel outstanding join() - trace "Cleaning up client", addrs = $client.remoteAddress, - conn + trace "Cleaning up client"# TODO ?: , addrs = $client.remoteAddress, + # conn self.clients[dir].keepItIf( it != client ) #TODO #await allFuturesThrowing( # conn.close(), client.closeWait()) - trace "Cleaned up client", addrs = $client.remoteAddress, - conn - except CatchableError as exc: let useExc {.used.} = exc debug "Error cleaning up client", errMsg = exc.msg, conn