server: add periodic renewal of port forwarding

The check prevented the creation of port forwardings which were assumed
to be present already. After this change the port forwardings which
might have been removed from the NAT device can be re-created.
This commit is contained in:
Robert Habermann committed 2019-04-13 13:49:31 +00:00
1 parent b07499f227
commit a27ac66eed
3 files changed
+15 -8

No files matched your search

-4
View File
@@ -65,10 +65,6 @@ func (p *PMP) AddPortMapping(port uint16) error {
p.forwardedPortsMtx.Lock()
defer p.forwardedPortsMtx.Unlock()
if _, exists := p.forwardedPorts[port]; exists {
return nil
}
_, err := p.client.AddPortMapping("tcp", int(port), int(port), 0)
if err != nil {
return err
-4
View File
@@ -62,10 +62,6 @@ func (u *UPnP) AddPortMapping(port uint16) error {
u.forwardedPortsMtx.Lock()
defer u.forwardedPortsMtx.Unlock()
if _, exists := u.forwardedPorts[port]; exists {
return nil
}
if err := u.device.Forward(port, ""); err != nil {
return err
}