mirror of
https://github.com/libp2p/go-libp2p.git
synced 2025-10-06 00:27:07 +08:00
fix autonat race
fix #7947 move `BasicHost.AutoNat` to a private field (it has no public method and shouldn't be accessed afaik. Instead add a setter for config that sets it while holding the address mutex to prevent reads of the field at the same time.
This commit is contained in:
@@ -203,7 +203,7 @@ func TestHostAddrsFactory(t *testing.T) {
|
||||
}
|
||||
|
||||
var err error
|
||||
h.AutoNat, err = autonat.New(ctx, h, autonat.WithReachability(network.ReachabilityPublic))
|
||||
h.autoNat, err = autonat.New(ctx, h, autonat.WithReachability(network.ReachabilityPublic))
|
||||
if err != nil {
|
||||
t.Fatalf("should be able to attach autonat: %v", err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user