Browse Source

webrtc: add webrtc addresses to host normalizer (#2784)

pull/2792/head
sukun 6 months ago
committed by GitHub
parent
commit
01ce97c730
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 6
      p2p/host/basic/basic_host.go

6
p2p/host/basic/basic_host.go

@ -811,7 +811,11 @@ func (h *BasicHost) Addrs() []ma.Multiaddr {
// NormalizeMultiaddr returns a multiaddr suitable for equality checks. // NormalizeMultiaddr returns a multiaddr suitable for equality checks.
// If the multiaddr is a webtransport component, it removes the certhashes. // If the multiaddr is a webtransport component, it removes the certhashes.
func (h *BasicHost) NormalizeMultiaddr(addr ma.Multiaddr) ma.Multiaddr { func (h *BasicHost) NormalizeMultiaddr(addr ma.Multiaddr) ma.Multiaddr {
if ok, n := libp2pwebtransport.IsWebtransportMultiaddr(addr); ok && n > 0 { ok, n := libp2pwebtransport.IsWebtransportMultiaddr(addr)
if !ok {
ok, n = libp2pwebrtc.IsWebRTCDirectMultiaddr(addr)
}
if ok && n > 0 {
out := addr out := addr
for i := 0; i < n; i++ { for i := 0; i < n; i++ {
out, _ = ma.SplitLast(out) out, _ = ma.SplitLast(out)

Loading…
Cancel
Save