mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-12 06:53:46 +00:00
p2p/nat: fix to ensure the newly assigned port from AddAnyPortMapping is returned
This commit is contained in:
parent
a14b8eca04
commit
7befd0ef47
1 changed files with 8 additions and 2 deletions
|
|
@ -95,13 +95,19 @@ func (n *upnp) AddMapping(protocol string, extport, intport int, desc string, li
|
||||||
return uint16(extport), nil
|
return uint16(extport), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return uint16(extport), n.withRateLimit(func() error {
|
var newExtport uint16
|
||||||
|
err = n.withRateLimit(func() error {
|
||||||
p, err := n.addAnyPortMapping(protocol, extport, intport, ip, desc, lifetimeS)
|
p, err := n.addAnyPortMapping(protocol, extport, intport, ip, desc, lifetimeS)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
extport = int(p)
|
newExtport = p
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return uint16(extport), err
|
||||||
|
}
|
||||||
|
return newExtport, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *upnp) addAnyPortMapping(protocol string, extport, intport int, ip net.IP, desc string, lifetimeS uint32) (uint16, error) {
|
func (n *upnp) addAnyPortMapping(protocol string, extport, intport int, ip net.IP, desc string, lifetimeS uint32) (uint16, error) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue