From 5e8e3d8385f24e8a839dcf29efaebb98bef45daa Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Sat, 25 Sep 2021 14:50:47 +0100 Subject: [PATCH] remove mapping.teardown --- p2p/net/nat/mapping.go | 11 +++++------ p2p/net/nat/nat.go | 7 +++---- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/p2p/net/nat/mapping.go b/p2p/net/nat/mapping.go index 4ab636d40..f9b508e4e 100644 --- a/p2p/net/nat/mapping.go +++ b/p2p/net/nat/mapping.go @@ -36,11 +36,10 @@ type Mapping interface { type mapping struct { sync.Mutex // guards all fields - nat *NAT - proto string - intport int - extport int - teardown func(*mapping) + nat *NAT + proto string + intport int + extport int cached net.IP cacheTime time.Time @@ -115,6 +114,6 @@ func (m *mapping) ExternalAddr() (net.Addr, error) { } func (m *mapping) Close() error { - m.teardown(m) + m.nat.removeMapping(m) return nil } diff --git a/p2p/net/nat/nat.go b/p2p/net/nat/nat.go index cad873cca..dad3226b4 100644 --- a/p2p/net/nat/nat.go +++ b/p2p/net/nat/nat.go @@ -112,10 +112,9 @@ func (nat *NAT) NewMapping(protocol string, port int) (Mapping, error) { } m := &mapping{ - intport: port, - nat: nat, - proto: protocol, - teardown: nat.removeMapping, + intport: port, + nat: nat, + proto: protocol, } nat.mappingmu.Lock()