Chore: use absolute path to execute commands on darwin
This commit is contained in:
parent
8c84c8b193
commit
3c07ba6b56
@ -9,7 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func GetAutoDetectInterface() (string, error) {
|
func GetAutoDetectInterface() (string, error) {
|
||||||
return cmd.ExecCmd("bash -c route -n get default | grep 'interface:' | awk -F ' ' 'NR==1{print $2}' | xargs echo -n")
|
return cmd.ExecCmd("/bin/bash -c /sbin/route -n get default | grep 'interface:' | awk -F ' ' 'NR==1{print $2}' | xargs echo -n")
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConfigInterfaceAddress(dev device.Device, addr netip.Prefix, forceMTU int, autoRoute bool) error {
|
func ConfigInterfaceAddress(dev device.Device, addr netip.Prefix, forceMTU int, autoRoute bool) error {
|
||||||
@ -24,14 +24,14 @@ func ConfigInterfaceAddress(dev device.Device, addr netip.Prefix, forceMTU int,
|
|||||||
netmask = ipv4MaskString(addr.Bits())
|
netmask = ipv4MaskString(addr.Bits())
|
||||||
)
|
)
|
||||||
|
|
||||||
cmdStr := fmt.Sprintf("ifconfig %s inet %s netmask %s %s", interfaceName, ip, netmask, gw)
|
cmdStr := fmt.Sprintf("/sbin/ifconfig %s inet %s netmask %s %s", interfaceName, ip, netmask, gw)
|
||||||
|
|
||||||
_, err := cmd.ExecCmd(cmdStr)
|
_, err := cmd.ExecCmd(cmdStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = cmd.ExecCmd(fmt.Sprintf("ipconfig set %s automatic-v6", interfaceName))
|
_, err = cmd.ExecCmd(fmt.Sprintf("/usr/sbin/ipconfig set %s automatic-v6", interfaceName))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -49,7 +49,7 @@ func configInterfaceRouting(interfaceName string, addr netip.Prefix) error {
|
|||||||
)
|
)
|
||||||
|
|
||||||
for _, destination := range routes {
|
for _, destination := range routes {
|
||||||
if _, err := cmd.ExecCmd(fmt.Sprintf("route add -net %s %s", destination, gateway)); err != nil {
|
if _, err := cmd.ExecCmd(fmt.Sprintf("/sbin/route add -net %s %s", destination, gateway)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -60,6 +60,6 @@ func configInterfaceRouting(interfaceName string, addr netip.Prefix) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func execRouterCmd(action, inet, route string, interfaceName string) error {
|
func execRouterCmd(action, inet, route string, interfaceName string) error {
|
||||||
_, err := cmd.ExecCmd(fmt.Sprintf("route %s %s %s -interface %s", action, inet, route, interfaceName))
|
_, err := cmd.ExecCmd(fmt.Sprintf("/sbin/route %s %s %s -interface %s", action, inet, route, interfaceName))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -143,9 +143,9 @@ func setAtLatest(stackType C.TUNStack, devName string) {
|
|||||||
|
|
||||||
switch runtime.GOOS {
|
switch runtime.GOOS {
|
||||||
case "darwin":
|
case "darwin":
|
||||||
// _, _ = cmd.ExecCmd("sysctl -w net.inet.ip.forwarding=1")
|
// _, _ = cmd.ExecCmd("/usr/sbin/sysctl -w net.inet.ip.forwarding=1")
|
||||||
// _, _ = cmd.ExecCmd("sysctl -w net.inet6.ip6.forwarding=1")
|
// _, _ = cmd.ExecCmd("/usr/sbin/sysctl -w net.inet6.ip6.forwarding=1")
|
||||||
_, _ = cmd.ExecCmd("sudo launchctl limit maxfiles 10240 unlimited")
|
_, _ = cmd.ExecCmd("/bin/launchctl limit maxfiles 10240 unlimited")
|
||||||
case "windows":
|
case "windows":
|
||||||
_, _ = cmd.ExecCmd("ipconfig /renew")
|
_, _ = cmd.ExecCmd("ipconfig /renew")
|
||||||
case "linux":
|
case "linux":
|
||||||
|
Reference in New Issue
Block a user