This repository has been archived on 2025-04-12. You can view files and clone it, but cannot push or open issues or pull requests.
Nexus/pkg/nex/net.go
2024-10-20 19:04:41 +08:00

16 lines
254 B
Go

package nex
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
}