mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
p2p/nat: simplify
This commit is contained in:
parent
7befd0ef47
commit
85e6606d4d
1 changed files with 3 additions and 8 deletions
|
|
@ -94,21 +94,16 @@ func (n *upnp) AddMapping(protocol string, extport, intport int, desc string, li
|
|||
if err == nil {
|
||||
return uint16(extport), nil
|
||||
}
|
||||
|
||||
var newExtport uint16
|
||||
// Try addAnyPortMapping if mapping specified port didn't work.
|
||||
err = n.withRateLimit(func() error {
|
||||
p, err := n.addAnyPortMapping(protocol, extport, intport, ip, desc, lifetimeS)
|
||||
if err == nil {
|
||||
newExtport = p
|
||||
extport = int(p)
|
||||
}
|
||||
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) {
|
||||
if client, ok := n.client.(*internetgateway2.WANIPConnection2); ok {
|
||||
|
|
|
|||
Loading…
Reference in a new issue