修订代码

This commit is contained in:
e1732a364fed
2000-01-01 00:00:00 +00:00
parent 983908e2bc
commit d7f0c51ece
2 changed files with 10 additions and 3 deletions

View File

@@ -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 {

View File

@@ -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
}