package util import "net" // addrToIP attempts to extract a net.IP from a net.Addr func AddrToIP(addr net.Addr) net.IP { switch v := addr.(type) { case *net.TCPAddr: return v.IP case *net.UDPAddr: return v.IP case *net.IPAddr: return v.IP default: // Handle other potential net.Addr implementations or return nil return nil } }