fix(relay): fix data-race in relayFinder (#3258)

`relayFinder.relays` should only be accessed with the `relayMx` held
This commit is contained in:
b00f
2025-03-31 22:20:49 +08:00
committed by GitHub
parent 17fd61051d
commit 88b1a70f24

View File

@@ -251,6 +251,9 @@ func (rf *relayFinder) updateAddrs() {
// This function returns the p2p-circuit addrs for the host.
// The returned addresses are of the form <relay's-addr>/p2p/<relay's-id>/p2p-circuit.
func (rf *relayFinder) getCircuitAddrs() []ma.Multiaddr {
rf.relayMx.Lock()
defer rf.relayMx.Unlock()
raddrs := make([]ma.Multiaddr, 0, 4*len(rf.relays)+4)
for p := range rf.relays {
addrs := cleanupAddressSet(rf.host.Peerstore().Addrs(p))