basichost: avoid modifying slice returned by AddrsFactory (#3068)

This commit is contained in:
Ivan Shvedunov
2024-11-28 20:32:47 +04:00
committed by GitHub
parent f421202456
commit 8423de3a64
2 changed files with 4 additions and 6 deletions

View File

@@ -582,7 +582,7 @@ func (cfg *Config) addAutoNAT(h *bhost.BasicHost) error {
if cfg.AddrsFactory != nil {
addrFunc = func() []ma.Multiaddr {
return slices.DeleteFunc(
cfg.AddrsFactory(h.AllAddrs()),
slices.Clone(cfg.AddrsFactory(h.AllAddrs())),
func(a ma.Multiaddr) bool { return !manet.IsPublicAddr(a) })
}
}