This commit is contained in:
laodaming 2023-10-11 18:37:47 +08:00
parent 394f0c6e46
commit afe8b26eee

View File

@ -129,12 +129,14 @@ func (l *DataTransferLogic) DataTransfer(w http.ResponseWriter, r *http.Request)
return return
} }
//有效token //有效token
if s[0] != "empty_token" { token := strings.Trim(s[0], " ")
r.Header.Set("Authorization", "Bearer "+s[0]) if token != "empty_token" {
r.Header.Set("Authorization", "Bearer "+token)
} }
//有效wid //有效wid
if s[1] != "empty_wid" { wid := strings.Trim(s[1], " ")
oldWid = s[1] if wid != "empty_wid" {
oldWid = wid
} }
//设置Sec-Websocket-Protocol //设置Sec-Websocket-Protocol
upgrader.Subprotocols = []string{secWebsocketProtocol} upgrader.Subprotocols = []string{secWebsocketProtocol}
@ -197,7 +199,7 @@ func (l *DataTransferLogic) setConnPool(conn *websocket.Conn, userInfo *auth.Use
//解析传入的wid是不是属于自己的用户的 //解析传入的wid是不是属于自己的用户的
decryptionWid, err := encryption_decryption.CBCDecrypt(oldWid) decryptionWid, err := encryption_decryption.CBCDecrypt(oldWid)
if err != nil { if err != nil {
logx.Error(err, ":", oldWid) logx.Error(err)
return wsConnectItem{}, errors.New("解码wid失败") return wsConnectItem{}, errors.New("解码wid失败")
} }
lendecryptionWid := len(decryptionWid) lendecryptionWid := len(decryptionWid)