修订代码;令tun在darwin不给出名称时使用系统指派的名称

This commit is contained in:
e1732a364fed
2000-01-01 00:00:00 +00:00
parent 64aaa6823e
commit eed0784f3e
2 changed files with 34 additions and 6 deletions

View File

@@ -221,12 +221,16 @@ func FromQX(str string) (dc proxy.DialConf) {
dc.Tag = v
case "obfs-uri":
dc.Path = v
case "tls-host":
fallthrough
case "obfs-host":
dc.Host = v
case "udp-relay":
if v == "false" {
dc.Network = "tcp"
}
// case "udp-relay": //vs暂无对应配置
// if v == "false" {
// dc.Network = "tcp"
// }
case "obfs":
switch v {
case "ws":
@@ -237,6 +241,16 @@ func FromQX(str string) (dc proxy.DialConf) {
case "tls", "over-tls":
dc.TLS = true
}
case "over-tls":
dc.TLS = true
case "tls-verification":
if v == "false" {
dc.Insecure = true
}
case "tls13":
dc.Extra = map[string]any{
"tls_minVersion": "1.3",
}
}
}
}
@@ -246,6 +260,11 @@ func FromQX(str string) (dc proxy.DialConf) {
dc.Uuid = "method:" + dc.EncryptAlgo + "\n" + "pass:" + dc.Uuid
}
}
if dc.Extra == nil {
dc.Extra = map[string]any{
"tls_minVersion": "1.2",
}
}
return
}

View File

@@ -4,7 +4,7 @@
使用 ip 配置作为 gateway 的ip
使用 extra.tun_selfip 作为 tun向外拨号的ip
tun device name的默认值约定 mac: utun5, windows: vs_wintun linux: vs_tun
tun device name的默认值约定 mac: 系统指派, windows: vs_wintun linux: vs_tun
*/
package tun
@@ -196,12 +196,14 @@ func (s *Server) Stop() {
// 非阻塞
func (s *Server) StartListen(tcpFunc func(netLayer.TCPRequestInfo), udpFunc func(netLayer.UDPRequestInfo)) io.Closer {
s.stopped = false
autoName := false
if s.devName == "" {
utils.Warn("tun: dev name not given, OS: " + runtime.GOOS)
autoName = true
switch runtime.GOOS {
case "darwin":
s.devName = "utun5"
s.devName = "utun" //根据 wireguard/tun/tun_darwin.go CreateTUN, 如果传入 utun就会系统指派一个可用名称
case "windows":
s.devName = "vs_wintun"
case "linux":
@@ -238,6 +240,13 @@ func (s *Server) StartListen(tcpFunc func(netLayer.TCPRequestInfo), udpFunc func
return nil
}
if autoName {
s.devName = tunDev.Name()
if ce := utils.CanLogInfo("tun dev"); ce != nil {
ce.Write(zap.String("name", s.devName))
}
}
if s.autoRoute && autoRouteFunc != nil {
utils.Info("tun running auto table")
autoRouteFunc(s.devName, s.realIP, s.selfip, s.autoRouteDirectList)