48 lines
899 B
Go
48 lines
899 B
Go
package sprigx
|
|
|
|
import (
|
|
`net`
|
|
`net/netip`
|
|
|
|
`go4.org/netipx`
|
|
)
|
|
|
|
// netipxFromStdAddr wraps go4.org/netipx.FromStdAddr to comply with Go template requirements.
|
|
func netipxFromStdAddr(ip net.IP, port int, zone string) (addrPort netip.AddrPort, err error) {
|
|
|
|
var ok bool
|
|
|
|
if addrPort, ok = netipx.FromStdAddr(ip, port, zone); !ok {
|
|
err = ErrBadAddrPort
|
|
return
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// netipxFromIp wraps go4.org/netipx.FromStdIP to comply with Go template requirements.
|
|
func netipxFromIp(ip net.IP) (addr netip.Addr, err error) {
|
|
|
|
var ok bool
|
|
|
|
if addr, ok = netipx.FromStdIP(ip); !ok {
|
|
err = ErrBadAddr
|
|
return
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
// netipxFromIpNet wraps go4.org/netipx.FromStdIPNet to comply with Go template requirements.
|
|
func netipxFromIpNet(ipnet *net.IPNet) (pfx netip.Prefix, err error) {
|
|
|
|
var ok bool
|
|
|
|
if pfx, ok = netipx.FromStdIPNet(ipnet); !ok {
|
|
err = ErrBadNet
|
|
return
|
|
}
|
|
|
|
return
|
|
}
|