2022-09-05 09:06:35 +02:00
|
|
|
//go:build !linux
|
|
|
|
// +build !linux
|
|
|
|
|
|
|
|
package routemanager
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/netip"
|
|
|
|
"os/exec"
|
|
|
|
"runtime"
|
2023-04-17 11:15:37 +02:00
|
|
|
|
|
|
|
log "github.com/sirupsen/logrus"
|
2022-09-05 09:06:35 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func addToRouteTable(prefix netip.Prefix, addr string) error {
|
|
|
|
cmd := exec.Command("route", "add", prefix.String(), addr)
|
|
|
|
out, err := cmd.Output()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
log.Debugf(string(out))
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-11-24 11:31:22 +01:00
|
|
|
func removeFromRouteTable(prefix netip.Prefix, addr string) error {
|
|
|
|
args := []string{"delete", prefix.String()}
|
|
|
|
if runtime.GOOS == "darwin" {
|
|
|
|
args = append(args, addr)
|
|
|
|
}
|
|
|
|
cmd := exec.Command("route", args...)
|
2022-09-05 09:06:35 +02:00
|
|
|
out, err := cmd.Output()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
log.Debugf(string(out))
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func enableIPForwarding() error {
|
|
|
|
log.Infof("enable IP forwarding is not implemented on %s", runtime.GOOS)
|
|
|
|
return nil
|
|
|
|
}
|