MCPcopy Create free account
hub / github.com/encodeous/nylon / PrefixToMaskString

Function PrefixToMaskString

core/sys_darwin.go:42–61  ·  view source on GitHub ↗
(p netip.Prefix)

Source from the content-addressed store, hash-verified

40}
41
42func PrefixToMaskString(p netip.Prefix) string {
43 if !p.IsValid() {
44 return "Invalid Prefix"
45 }
46
47 bits := p.Bits()
48 var mask net.IPMask
49
50 if p.Addr().Is4() {
51 mask = net.CIDRMask(bits, 32)
52 } else if p.Addr().Is6() {
53 mask = net.CIDRMask(bits, 128)
54 } else {
55 // Should not happen for a valid prefix
56 return "Unknown IP version"
57 }
58
59 // Cast the net.IPMask (a []byte) to net.IP to use its String() method
60 return net.IP(mask).String()
61}
62
63func ConfigureRoute(logger *slog.Logger, dev tun.Device, itfName string, route netip.Prefix) error {
64 if route.Addr().Is6() {

Callers 2

ConfigureRouteFunction · 0.85
RemoveRouteFunction · 0.85

Calls 2

AddrMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected