mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-10-01 01:36:09 -04: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
|
||
|
}
|