package utils

import "net"

func GetRealIp() (string, error) {
	conn, err := net.Dial("udp", "8.8.8.8:8")
	if err != nil {
		panic(err)
	}
	defer conn.Close()
	localAddr := conn.LocalAddr().(*net.UDPAddr)
	address := localAddr.String()
	ipAddress, _, err := net.SplitHostPort(address)
	if err != nil {
		return "", err
	}
	return ipAddress, nil
}
