diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index b539ae6dfb..f079df83b9 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -760,7 +760,7 @@ var ( } NATFlag = &cli.StringFlag{ Name: "nat", - Usage: "NAT port mapping mechanism (any|none|upnp|pmp|pmp:|extip:|stun:default|stun:)", + Usage: "NAT port mapping mechanism (any|none|upnp|pmp|pmp:|extip:|stun:)", Value: "any", Category: flags.NetworkingCategory, } diff --git a/p2p/nat/nat.go b/p2p/nat/nat.go index 659f424f7b..5f7af7424d 100644 --- a/p2p/nat/nat.go +++ b/p2p/nat/nat.go @@ -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 ( diff --git a/p2p/nat/stun.go b/p2p/nat/stun.go index 17e5d9b2d8..36d54398b5 100644 --- a/p2p/nat/stun.go +++ b/p2p/nat/stun.go @@ -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) diff --git a/p2p/nat/stun_test.go b/p2p/nat/stun_test.go index fe16ecdeb3..b5f429986c 100644 --- a/p2p/nat/stun_test.go +++ b/p2p/nat/stun_test.go @@ -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 . + 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)