From b0f66e34ca2a4ea7ae23475224451c8c9a569826 Mon Sep 17 00:00:00 2001 From: dknopik <107140945+dknopik@users.noreply.github.com> Date: Sat, 27 Jul 2024 10:18:05 +0200 Subject: [PATCH] p2p/nat: return correct port for ExtIP NAT (#30234) Return the actually requested external port instead of 0 in the AddMapping implementation for `--nat extip:`. --- p2p/nat/nat.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/p2p/nat/nat.go b/p2p/nat/nat.go index 2aa1f85585..c656044268 100644 --- a/p2p/nat/nat.go +++ b/p2p/nat/nat.go @@ -138,8 +138,10 @@ func (n ExtIP) String() string { return fmt.Sprintf("ExtIP(%v)", ne // These do nothing. -func (ExtIP) AddMapping(string, int, int, string, time.Duration) (uint16, error) { return 0, nil } -func (ExtIP) DeleteMapping(string, int, int) error { return nil } +func (ExtIP) AddMapping(protocol string, extport, intport int, name string, lifetime time.Duration) (uint16, error) { + return uint16(extport), nil +} +func (ExtIP) DeleteMapping(string, int, int) error { return nil } // Any returns a port mapper that tries to discover any supported // mechanism on the local network.