Skip to content

Commit

Permalink
basichost: use byte representation of WebTransport multiaddr as map k…
Browse files Browse the repository at this point in the history
…ey (#2494)
  • Loading branch information
Jorropo authored Aug 16, 2023
1 parent 457f84a commit d46e631
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions p2p/host/basic/basic_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -942,17 +942,17 @@ func inferWebtransportAddrsFromQuic(in []ma.Multiaddr) []ma.Multiaddr {
// Remove certhashes
addr, _ = ma.SplitLast(addr)
}
webtransportAddrs[addr.String()] = struct{}{}
webtransportAddrs[string(addr.Bytes())] = struct{}{}
// Remove webtransport component, now it's a multiaddr that ends in /quic-v1
addr, _ = ma.SplitLast(addr)
}

if _, lastComponent := ma.SplitLast(addr); lastComponent.Protocol().Code == ma.P_QUIC_V1 {
addrStr := addr.String()
if _, ok := quicOrWebtransportAddrs[addrStr]; ok {
bytes := addr.Bytes()
if _, ok := quicOrWebtransportAddrs[string(bytes)]; ok {
foundSameListeningAddr = true
} else {
quicOrWebtransportAddrs[addrStr] = struct{}{}
quicOrWebtransportAddrs[string(bytes)] = struct{}{}
}
}
}
Expand All @@ -974,7 +974,7 @@ func inferWebtransportAddrsFromQuic(in []ma.Multiaddr) []ma.Multiaddr {
if _, lastComponent := ma.SplitLast(addr); lastComponent.Protocol().Code == ma.P_QUIC_V1 {
// Convert quic to webtransport
addr = addr.Encapsulate(wtComponent)
if _, ok := webtransportAddrs[addr.String()]; ok {
if _, ok := webtransportAddrs[string(addr.Bytes())]; ok {
// We already have this address
continue
}
Expand Down

0 comments on commit d46e631

Please sign in to comment.