Skip to content

Commit

Permalink
remove mapping.teardown
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed Sep 25, 2021
1 parent 1ce83db commit 5e8e3d8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
11 changes: 5 additions & 6 deletions p2p/net/nat/mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
7 changes: 3 additions & 4 deletions p2p/net/nat/nat.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 5e8e3d8

Please sign in to comment.