|
|
@ -87,6 +87,13 @@ func (n *upnp) AddMapping(protocol string, extport, intport int, desc string, li |
|
|
|
protocol = strings.ToUpper(protocol) |
|
|
|
protocol = strings.ToUpper(protocol) |
|
|
|
lifetimeS := uint32(lifetime / time.Second) |
|
|
|
lifetimeS := uint32(lifetime / time.Second) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if extport == 0 { |
|
|
|
|
|
|
|
extport = intport |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
// Only delete port mapping if the external port was already used by geth.
|
|
|
|
|
|
|
|
n.DeleteMapping(protocol, extport, intport) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
err = n.withRateLimit(func() error { |
|
|
|
err = n.withRateLimit(func() error { |
|
|
|
return n.client.AddPortMapping("", uint16(extport), protocol, uint16(intport), ip.String(), true, desc, lifetimeS) |
|
|
|
return n.client.AddPortMapping("", uint16(extport), protocol, uint16(intport), ip.String(), true, desc, lifetimeS) |
|
|
|
}) |
|
|
|
}) |
|
|
|