mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 09:23:48 +00:00
p2p/nat: remove the "default" string
This commit is contained in:
parent
fa76319cd0
commit
ab6d1d291e
4 changed files with 21 additions and 5 deletions
|
|
@ -760,7 +760,7 @@ var (
|
|||
}
|
||||
NATFlag = &cli.StringFlag{
|
||||
Name: "nat",
|
||||
Usage: "NAT port mapping mechanism (any|none|upnp|pmp|pmp:<IP>|extip:<IP>|stun:default|stun:<IP:PORT>)",
|
||||
Usage: "NAT port mapping mechanism (any|none|upnp|pmp|pmp:<IP>|extip:<IP>|stun:<IP:PORT>)",
|
||||
Value: "any",
|
||||
Category: flags.NetworkingCategory,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ type Interface interface {
|
|||
// "upnp" uses the Universal Plug and Play protocol
|
||||
// "pmp" uses NAT-PMP with an auto-detected gateway address
|
||||
// "pmp:192.168.0.1" uses NAT-PMP with the given gateway address
|
||||
// "stun:default" uses stun protocol with default stun server
|
||||
// "stun" uses stun protocol with default stun server
|
||||
// "stun:192.168.0.1:1234" uses stun protocol with stun server address 192.168.0.1:1234
|
||||
func Parse(spec string) (Interface, error) {
|
||||
var (
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright 2024 The go-ethereum Authors
|
||||
// Copyright 2025 The go-ethereum Authors
|
||||
// This file is part of the go-ethereum library.
|
||||
//
|
||||
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||
|
|
@ -42,7 +42,7 @@ type stun struct {
|
|||
|
||||
func newSTUN(serverAddr string) (Interface, error) {
|
||||
s := new(stun)
|
||||
if serverAddr == "default" || serverAddr == "" {
|
||||
if serverAddr == "" {
|
||||
s.serverList = strings.Split(stunDefaultServers, "\n")
|
||||
} else {
|
||||
_, err := net.ResolveUDPAddr("udp4", serverAddr)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,19 @@
|
|||
// Copyright 2025 The go-ethereum Authors
|
||||
// This file is part of the go-ethereum library.
|
||||
//
|
||||
// The go-ethereum library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// The go-ethereum library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package nat
|
||||
|
||||
import (
|
||||
|
|
@ -7,7 +23,7 @@ import (
|
|||
)
|
||||
|
||||
func TestNatStun(t *testing.T) {
|
||||
nat, err := newSTUN("default")
|
||||
nat, err := newSTUN("")
|
||||
assert.NoError(t, err)
|
||||
_, err = nat.ExternalIP()
|
||||
assert.NoError(t, err)
|
||||
|
|
|
|||
Loading…
Reference in a new issue