p2p/nat: addAnyPortMapping now replaces addPortMapping

The default of addAnyPortMapping is what addPortMapping does, so
no need to call it separately.

Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
Csaba Kiraly 2025-04-01 22:08:46 +02:00
parent 12c17e344d
commit 343277d9a1
No known key found for this signature in database
GPG key ID: 0FE274EE8C95166E

View file

@ -94,13 +94,7 @@ func (n *upnp) AddMapping(protocol string, extport, intport int, desc string, li
n.DeleteMapping(protocol, extport, intport)
}
err = n.withRateLimit(func() error {
return n.client.AddPortMapping("", uint16(extport), protocol, uint16(intport), ip.String(), true, desc, lifetimeS)
})
if err == nil {
return uint16(extport), nil
}
// Try addAnyPortMapping if mapping specified port didn't work.
// Try to add port mapping, preferring the specified external port.
err = n.withRateLimit(func() error {
p, err := n.addAnyPortMapping(protocol, extport, intport, ip, desc, lifetimeS)
if err == nil {