mirror of
https://github.com/net-byte/vtun
synced 2024-03-14 10:50:03 +08:00
fix cmd
This commit is contained in:
parent
1101ef030d
commit
4d5bfbb59e
@ -160,12 +160,7 @@ func ExecCmd(c string, args ...string) string {
|
||||
}
|
||||
|
||||
func GetLinuxDefaultGateway() string {
|
||||
gateway := ExecCmd("sh", "-c", "netstat -r | grep 'default' | awk '{print $2}'")
|
||||
if net.ParseIP(gateway) != nil {
|
||||
return gateway
|
||||
}
|
||||
nslookup := "nslookup " + gateway + " | awk '/^Address: / { print $2 ; exit }'"
|
||||
return ExecCmd("sh", "-c", nslookup)
|
||||
return ExecCmd("sh", "-c", "route -n | grep 'UG[ \t]' | awk '{print $2}'")
|
||||
}
|
||||
|
||||
func GetMacDefaultGateway() string {
|
||||
|
@ -41,7 +41,6 @@ func configTun(config config.Config, iface *water.Interface) {
|
||||
netutil.ExecCmd("/sbin/ip", "route", "add", "128.0.0.0/1", "dev", iface.Name())
|
||||
netutil.ExecCmd("/sbin/ip", "route", "add", "8.8.8.8/32", "via", config.DefaultGateway, "dev", physicalIface)
|
||||
netutil.ExecCmd("/sbin/ip", "route", "add", strings.Join([]string{serverIP, "32"}, "/"), "via", config.DefaultGateway, "dev", physicalIface)
|
||||
//netutil.ExecCmd("/sbin/ip", "route", "add", strings.Join([]string{config.DefaultDNS, "32"}, "/"), "via", config.DefaultGateway, "dev", physicalIface)
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,7 +52,6 @@ func configTun(config config.Config, iface *water.Interface) {
|
||||
serverIP := netutil.LookupIP(strings.Split(config.ServerAddr, ":")[0])
|
||||
if physicalIface != "" && serverIP != "" {
|
||||
netutil.ExecCmd("route", "add", serverIP, config.DefaultGateway)
|
||||
//netutil.ExecCmd("route", "add", config.DefaultDNS, config.DefaultGateway)
|
||||
netutil.ExecCmd("route", "add", "8.8.8.8", config.DefaultGateway)
|
||||
netutil.ExecCmd("route", "add", "0.0.0.0/1", "-interface", iface.Name())
|
||||
netutil.ExecCmd("route", "add", "128.0.0.0/1", "-interface", iface.Name())
|
||||
|
Loading…
Reference in New Issue
Block a user