Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于websocket模块bug #1163

Closed
Fanrncho opened this issue Mar 25, 2020 · 0 comments
Closed

关于websocket模块bug #1163

Fanrncho opened this issue Mar 25, 2020 · 0 comments

Comments

@Fanrncho
Copy link
Contributor

接收客户端发过来的请求信息如下:

GET / HTTP/1.1
Host: 127.0.0.1:8080
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:63.0) Gecko/20100101 Firefox/63.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Sec-WebSocket-Version: 13
Origin: http://localhost:63342
Sec-WebSocket-Extensions: permessage-deflate
Sec-WebSocket-Key: lOfBaOFgUccUfIKUDD5Bxw==
Connection: keep-alive, Upgrade
Pragma: no-cache
Cache-Control: no-cache
Upgrade: websocket

而skynet的websocket.lua模块的101~103行校验header头部信息代码如下:

if not header["connection"] or header["connection"]:lower() ~= "upgrade" then
        return 400, "Connection must Upgrade"
    end

从客户端发过来的请求头部信息来看,“Connection”参数的值为“keep-alive, Upgrade”,而websoket.lua模块的校验条件判断是“if not header["connection"] or header["connection"]:lower() ~= "upgrade" then”,也就是说客户端发过来的消息请求头部的“Connection”参数的值为“keep-alive, Upgrade”就不可能通过这个条件判断,因为这个条件判断是header["connection"]:lower() ~= "upgrade" 。
希望官方修复下这个问题,不然可能导致有些websocket客户端连接在握手时失败。
目前我这边的做法是把if not header["connection"] or header["connection"]:lower() ~= "upgrade" then判断条件改成了:if not header["connection"] or not header["connection"]:lower():find("upgrade", 1,true) then
@cloudwu @lvzixun @shuax

Fanrncho referenced this issue in Fanrncho/skynet Mar 27, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@Fanrncho Fanrncho closed this as completed Jun 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant