some stuff had to get merged into it due to circular dependencies so I guess what is in onions now is all onions.
22 lines
356 B
Go
22 lines
356 B
Go
package engine
|
|
|
|
import (
|
|
"net"
|
|
"net/netip"
|
|
)
|
|
|
|
func GetNetworkFromAddrPort(addr string) (nw string, u *net.UDPAddr,
|
|
e error) {
|
|
|
|
nw = "udp"
|
|
var ap netip.AddrPort
|
|
if ap, e = netip.ParseAddrPort(addr); fails(e) {
|
|
return
|
|
}
|
|
u = &net.UDPAddr{IP: net.ParseIP(ap.Addr().String()), Port: int(ap.Port())}
|
|
if u.IP.To4() != nil {
|
|
nw = "udp4"
|
|
}
|
|
return
|
|
}
|