route changes + primary addr on node

This commit is contained in:
0xdcarns
2022-04-19 16:18:03 -04:00
parent 8e976d1f55
commit dc12b1e418
16 changed files with 169 additions and 63 deletions

View File

@@ -19,6 +19,14 @@ func deleteRoute(iface string, addr *net.IPNet, address string) error {
}
func setCidr(iface, address string, addr *net.IPNet) {
cidr := ipaddr.NewIPAddressString(addr.String()).GetAddress()
if cidr.IsIPv4() {
ncutils.RunCmd("route add -net "+addr.String()+" -interface "+iface, false)
} else if cidr.IsIPv6() {
ncutils.RunCmd("route add -net -inet6 "+addr.String()+" -interface "+iface, false)
} else {
logger.Log(1, "could not parse address: "+addr.String())
}
ncutils.RunCmd("route add -net "+addr.String()+" -interface "+iface, false)
}