p2p/sim: use ipv4

This commit is contained in:
Anton Evangelatov 2018-03-05 10:43:09 +01:00
parent 8c05e9b252
commit 96e374efe5
2 changed files with 20 additions and 10 deletions

View file

@ -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

View file

@ -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{