mirror of
https://github.com/e1732a364fed/v2ray_simple.git
synced 2025-12-24 13:27:56 +08:00
修订代码
This commit is contained in:
@@ -14,7 +14,7 @@ var rememberedRouterIP string
|
||||
func init() {
|
||||
autoRouteFunc = func(tunDevName, tunGateway, tunIP string, directList []string) {
|
||||
|
||||
params := fmt.Sprintf(`interface ip set address name="%s" source=static addr=%s mask=255.255.255.0 gateway=none`, tunDevName, tunIP)
|
||||
params := fmt.Sprintf(`interface ip set address name="%s" source=static addr=%s mask=255.255.255.0 gateway=%s`, tunDevName, tunIP, tunGateway)
|
||||
_, err := exec.Command("netsh", strings.Split(params, " ")...).Output()
|
||||
if err != nil {
|
||||
if ce := utils.CanLogErr("auto route failed"); ce != nil {
|
||||
|
||||
@@ -166,14 +166,21 @@ func (s *Server) Stop() {
|
||||
func (s *Server) StartListen(tcpRequestChan chan<- netLayer.TCPRequestInfo, udpRequestChan chan<- netLayer.UDPRequestInfo) io.Closer {
|
||||
s.stopped = false
|
||||
//log.Println(s.devName, s.selfip, s.realIP, s.mask)
|
||||
if s.devName == "" && runtime.GOOS == "darwin" {
|
||||
s.devName = "utun5"
|
||||
if s.devName == "" {
|
||||
switch runtime.GOOS {
|
||||
case "darwin":
|
||||
s.devName = "utun5"
|
||||
case "windows":
|
||||
s.devName = "vs_wintun"
|
||||
|
||||
}
|
||||
}
|
||||
tunDev, err := tun.Open(s.devName)
|
||||
if err != nil {
|
||||
if ce := utils.CanLogErr("tun open failed"); ce != nil {
|
||||
ce.Write(zap.Error(err))
|
||||
}
|
||||
s.stopped = true
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user