Dealer/pkg/internal/gap/net.go

16 lines
254 B
Go
Raw Normal View History

2024-07-14 12:25:30 +00:00
package gap
import "net"
func GetOutboundIP() (net.IP, error) {
conn, err := net.Dial("udp", "1.1.1.1:80")
if err != nil {
return nil, err
} else {
defer conn.Close()
}
localAddr := conn.LocalAddr().(*net.UDPAddr)
return localAddr.IP, nil
}