Files
pmomusic/netutils/ip_detect.go

18 lines
327 B
Go
Raw Normal View History

2025-09-06 17:45:28 +02:00
package netutils
import (
"net"
)
// Fonction helper (remplace votre netutils.GuessLocalIP)
func GuessLocalIP() (string, error) {
conn, err := net.Dial("udp", "8.8.8.8:80")
if err != nil {
return "127.0.0.1", nil
}
defer conn.Close()
localAddr := conn.LocalAddr().(*net.UDPAddr)
return localAddr.IP.String(), nil
}