mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-12-27 00:19:36 -05:00
18 lines
254 B
Go
18 lines
254 B
Go
|
package util
|
||
|
|
||
|
import (
|
||
|
"net"
|
||
|
)
|
||
|
|
||
|
func GetIPAddr() (string, error) {
|
||
|
conn, err := net.Dial("udp", "8.8.8.8:80")
|
||
|
if err != nil {
|
||
|
return "", err
|
||
|
}
|
||
|
defer conn.Close()
|
||
|
|
||
|
localAddr := conn.LocalAddr().(*net.UDPAddr)
|
||
|
|
||
|
return localAddr.IP.String(), nil
|
||
|
}
|