Browse Source

remove mapping.teardown

master
Marten Seemann 3 months ago
parent
commit
4baa99626d
2 changed files with 8 additions and 10 deletions
  1. +5
    -6
      mapping.go
  2. +3
    -4
      nat.go

+ 5
- 6
mapping.go View File

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

+ 3
- 4
nat.go View File

@ -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