From 343277d9a15ff0f1e341a7487a90ba550f2e21af Mon Sep 17 00:00:00 2001 From: Csaba Kiraly Date: Tue, 1 Apr 2025 22:08:46 +0200 Subject: [PATCH] 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 --- p2p/nat/natupnp.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/p2p/nat/natupnp.go b/p2p/nat/natupnp.go index 59322bd813..ed00b8eeb6 100644 --- a/p2p/nat/natupnp.go +++ b/p2p/nat/natupnp.go @@ -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 {