Browse Source

remove mapping.teardown

merge-nat
Marten Seemann 3 years ago
parent
commit
5e8e3d8385
  1. 11
      p2p/net/nat/mapping.go
  2. 7
      p2p/net/nat/nat.go

11
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
}

7
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()

Loading…
Cancel
Save