Skip to content

Commit

Permalink
webrtc: add webrtc addresses to host normalizer
Browse files Browse the repository at this point in the history
  • Loading branch information
sukunrt committed May 5, 2024
1 parent 0385ec9 commit 51879ec
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion p2p/host/basic/basic_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 51879ec

Please sign in to comment.