From 51879ecc8e3ad597e6b5ec6e090467f44b3fb8ce Mon Sep 17 00:00:00 2001 From: sukun Date: Sun, 5 May 2024 20:36:27 +0530 Subject: [PATCH] webrtc: add webrtc addresses to host normalizer --- p2p/host/basic/basic_host.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/p2p/host/basic/basic_host.go b/p2p/host/basic/basic_host.go index 367fca05f2..9aa8d0fe1f 100644 --- a/p2p/host/basic/basic_host.go +++ b/p2p/host/basic/basic_host.go @@ -809,7 +809,17 @@ func (h *BasicHost) Addrs() []ma.Multiaddr { // NormalizeMultiaddr returns a multiaddr suitable for equality checks. // If the multiaddr is a webtransport component, it removes the certhashes. func (h *BasicHost) NormalizeMultiaddr(addr ma.Multiaddr) ma.Multiaddr { - if ok, n := libp2pwebtransport.IsWebtransportMultiaddr(addr); ok && n > 0 { + var n int + wtOK, wtN := libp2pwebtransport.IsWebtransportMultiaddr(addr) + if wtOK { + n = wtN + } else { + webrtcOK, webrtcN := libp2pwebrtc.IsWebRTCDirectMultiaddr(addr) + if webrtcOK { + n = webrtcN + } + } + if n > 0 { out := addr for i := 0; i < n; i++ { out, _ = ma.SplitLast(out)