status-go/server/ips.go

23 lines
330 B
Go

package server
import (
"net"
)
var (
defaultIP = net.IP{127, 0, 0, 1}
localhost = "localhost"
)
func GetOutboundIP() (net.IP, error) {
conn, err := net.Dial("udp", "255.255.255.255:8080")
if err != nil {
return nil, err
}
defer conn.Close()
localAddr := conn.LocalAddr().(*net.UDPAddr)
return localAddr.IP, nil
}