From e8fe7048c3dd550b31bbfbf5a18fe3dbec8ab8bd Mon Sep 17 00:00:00 2001 From: e1732a364fed <75717694+e1732a364fed@users.noreply.github.com> Date: Sat, 1 Jan 2000 00:00:00 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- proxy/tun/route_linux.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/proxy/tun/route_linux.go b/proxy/tun/route_linux.go index b260b62..4f3df2f 100644 --- a/proxy/tun/route_linux.go +++ b/proxy/tun/route_linux.go @@ -11,6 +11,7 @@ import ( "os" "strconv" "strings" + "time" "github.com/e1732a364fed/v2ray_simple/utils" "go.uber.org/zap" @@ -93,8 +94,8 @@ func init() { } var strs = []string{ - "ip route del default", - "ip route add default via " + rememberedRouterIP, + //"ip route del default", + //"ip route add default via " + rememberedRouterIP, "ip link set dev " + tunDevName + " down", "ip tuntap del mode tun dev " + tunDevName, @@ -107,7 +108,16 @@ func init() { if manualRoute { promptManual(strs) } else { - if e := utils.LogExecCmdList(strs); e != nil { + if e := utils.LogExecCmdList(strs[:1]); e != nil { + if ce := utils.CanLogErr("recover auto route failed"); ce != nil { + ce.Write(zap.Error(e)) + } + return + + } + time.Sleep(time.Second) //似乎不能太快紧接着 down 执行ip tuntap del + + if e := utils.LogExecCmdList(strs[1:]); e != nil { if ce := utils.CanLogErr("recover auto route failed"); ce != nil { ce.Write(zap.Error(e)) }