2022-02-04 08:55:12 +08:00
|
|
|
package local
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net"
|
|
|
|
|
|
|
|
"github.com/gravitl/netmaker/netclient/ncutils"
|
|
|
|
)
|
|
|
|
|
|
|
|
func setRoute(iface string, addr *net.IPNet, address string) error {
|
|
|
|
var err error
|
2022-02-06 04:00:26 +08:00
|
|
|
_, _ = ncutils.RunCmd("route add -net "+addr.String()+" -interface "+iface, false)
|
2022-02-04 08:55:12 +08:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
func deleteRoute(iface string, addr *net.IPNet, address string) error {
|
|
|
|
var err error
|
2022-02-08 00:29:10 +08:00
|
|
|
_, _ = ncutils.RunCmd("route delete -net "+addr.String()+" -interface "+iface, false)
|
2022-02-04 08:55:12 +08:00
|
|
|
return err
|
|
|
|
}
|
2022-02-06 03:20:50 +08:00
|
|
|
|
|
|
|
func setCidr(iface, address string, addr *net.IPNet) {
|
2022-02-06 04:00:26 +08:00
|
|
|
ncutils.RunCmd("route add -net "+addr.String()+" -interface "+iface, false)
|
|
|
|
}
|
|
|
|
|
|
|
|
func removeCidr(iface string, addr *net.IPNet, address string) {
|
|
|
|
ncutils.RunCmd("route delete -net "+addr.String()+" -interface "+iface, false)
|
2022-02-06 03:20:50 +08:00
|
|
|
}
|