修复mac手机版客户端重连的问题

This commit is contained in:
bjdgyc
2024-03-12 18:08:05 +08:00
parent 03467e4f06
commit edf33ba4ae
9 changed files with 69 additions and 60 deletions

View File

@@ -32,8 +32,10 @@ func startDtls() {
logf := logging.NewDefaultLoggerFactory()
logf.Writer = base.GetBaseLw()
// logf.DefaultLogLevel = logging.LogLevelTrace
logf.DefaultLogLevel = logging.LogLevelInfo
if base.GetLogLevel() == base.LogLevelTrace {
// logf.DefaultLogLevel = logging.LogLevelTrace
}
// https://github.com/pion/dtls/pull/369
sessStore := &sessionStore{}

View File

@@ -69,13 +69,13 @@ func LinkCstp(conn net.Conn, bufRW *bufio.ReadWriter, cSess *sessdata.ConnSessio
}
case 0x05: // DISCONNECT
cSess.UserLogoutCode = dbdata.UserLogoutClient
base.Debug("DISCONNECT", cSess.Username, cSess.IpAddr, conn.RemoteAddr())
base.Debug("DISCONNECT", cSess.Username, cSess.IpAddr, conn.RemoteAddr(), n, string(pl.Data[9:n]))
sessdata.CloseSess(cSess.Sess.Token, dbdata.UserLogoutClient)
return
case 0x03: // DPD-REQ
base.Trace("recv LinkCstp DPD-REQ", cSess.Username, cSess.IpAddr, conn.RemoteAddr())
base.Trace("recv LinkCstp DPD-REQ", cSess.Username, cSess.IpAddr, conn.RemoteAddr(), n, pl.Data[:n])
pl.PType = 0x04
pl.Data = pl.Data[:n]
// pl.Data = pl.Data[:n]
if payloadOutCstp(cSess, pl) {
return
}
@@ -169,7 +169,7 @@ func cstpWrite(conn net.Conn, bufRW *bufio.ReadWriter, cSess *sessdata.ConnSessi
binary.BigEndian.PutUint16(pl.Data[4:6], uint16(l))
}
} else {
// pl.Data = append(pl.Data[:0], plHeader...)
pl.Data = append(pl.Data[:0], plHeader...)
// 设置头类型
pl.Data[6] = pl.PType
}

View File

@@ -62,8 +62,9 @@ func LinkDtls(conn net.Conn, cSess *sessdata.ConnSession) {
base.Debug("DISCONNECT DTLS", cSess.Username, cSess.IpAddr, conn.RemoteAddr())
return
case 0x03: // DPD-REQ
base.Trace("recv LinkDtls DPD-REQ", cSess.Username, cSess.IpAddr, conn.RemoteAddr())
base.Trace("recv LinkDtls DPD-REQ", cSess.Username, cSess.IpAddr, conn.RemoteAddr(), n, pl.Data[:n])
pl.PType = 0x04
// 从零开始 可以直接赋值
pl.Data = pl.Data[:n]
if payloadOutDtls(cSess, dSess, pl) {
return

View File

@@ -133,7 +133,7 @@ func LinkTunnel(w http.ResponseWriter, r *http.Request) {
}
// 允许的路由
for _, v := range cSess.Group.RouteInclude {
if v.Val == dbdata.All {
if strings.ToLower(v.Val) == dbdata.All {
continue
}
HttpAddHeader(w, "X-CSTP-Split-Include", v.IpMask)
@@ -181,7 +181,7 @@ func LinkTunnel(w http.ResponseWriter, r *http.Request) {
HttpSetHeader(w, "X-CSTP-Quarantine", "false")
HttpSetHeader(w, "X-CSTP-Disable-Always-On-VPN", "false")
HttpSetHeader(w, "X-CSTP-Client-Bypass-Protocol", "false")
HttpSetHeader(w, "X-CSTP-TCP-Keepalive", "false")
HttpSetHeader(w, "X-CSTP-TCP-Keepalive", "true")
// 设置域名拆分隧道(移动端不支持)
if mobile != "mobile" {
SetPostAuthXml(cSess.Group, w)