mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 01:43:47 +00:00
p2p/sim: use ipv4
This commit is contained in:
parent
8c05e9b252
commit
96e374efe5
2 changed files with 20 additions and 10 deletions
|
|
@ -340,17 +340,27 @@ type execNodeConfig struct {
|
|||
|
||||
// ExternalIP gets an external IP address so that Enode URL is usable
|
||||
func ExternalIP() net.IP {
|
||||
addrs, err := net.InterfaceAddrs()
|
||||
//addrs, err := net.InterfaceAddrs()
|
||||
//if err != nil {
|
||||
//log.Crit("error getting IP address", "err", err)
|
||||
//}
|
||||
//for _, addr := range addrs {
|
||||
//if ip, ok := addr.(*net.IPNet); ok && !ip.IP.IsLoopback() {
|
||||
//return ip.IP
|
||||
//}
|
||||
//}
|
||||
//log.Crit("unable to determine explicit IP address")
|
||||
//return net.IP{127, 0, 0, 1}
|
||||
|
||||
conn, err := net.Dial("udp", "8.8.8.8:80")
|
||||
if err != nil {
|
||||
log.Crit("error getting IP address", "err", err)
|
||||
panic(err)
|
||||
}
|
||||
for _, addr := range addrs {
|
||||
if ip, ok := addr.(*net.IPNet); ok && !ip.IP.IsLoopback() {
|
||||
return ip.IP
|
||||
}
|
||||
}
|
||||
log.Crit("unable to determine explicit IP address")
|
||||
return net.IP{127, 0, 0, 1}
|
||||
defer conn.Close()
|
||||
|
||||
localAddr := conn.LocalAddr().(*net.UDPAddr)
|
||||
|
||||
return localAddr.IP
|
||||
}
|
||||
|
||||
// execP2PNode starts a devp2p node when the current binary is executed with
|
||||
|
|
|
|||
|
|
@ -233,7 +233,7 @@ func discoverySimulation(nodes, conns int, adapter adapters.NodeAdapter) (*simul
|
|||
|
||||
// 64 nodes ~ 1min
|
||||
// 128 nodes ~
|
||||
timeout := 60 * time.Second
|
||||
timeout := 300 * time.Second
|
||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||
defer cancel()
|
||||
result := simulations.NewSimulation(net).Run(ctx, &simulations.Step{
|
||||
|
|
|
|||
Loading…
Reference in a new issue