mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 09:23:48 +00:00
p2p/server_nat: set stun IP to localnode
This commit is contained in:
parent
8daefeb890
commit
ea8e272e1a
2 changed files with 5 additions and 3 deletions
|
|
@ -36,6 +36,9 @@ const requestLimit = 3
|
|||
|
||||
var errSTUNFailed = errors.New("STUN requests failed")
|
||||
|
||||
type STUN struct {
|
||||
stun
|
||||
}
|
||||
type stun struct {
|
||||
serverList []string
|
||||
}
|
||||
|
|
@ -77,7 +80,7 @@ func (stun) DeleteMapping(string, int, int) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (s *stun) ExternalIP() (net.IP, error) {
|
||||
func (s stun) ExternalIP() (net.IP, error) {
|
||||
for _, server := range s.randomServers(requestLimit) {
|
||||
ip, err := s.externalIP(server)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -57,8 +57,7 @@ func (srv *Server) setupPortMapping() {
|
|||
// No NAT interface configured.
|
||||
srv.loopWG.Add(1)
|
||||
go srv.consumePortMappingRequests()
|
||||
|
||||
case nat.ExtIP:
|
||||
case nat.ExtIP, nat.STUN:
|
||||
// ExtIP doesn't block, set the IP right away.
|
||||
ip, _ := srv.NAT.ExternalIP()
|
||||
srv.localnode.SetStaticIP(ip)
|
||||
|
|
|
|||
Loading…
Reference in a new issue