mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-25 12:43:09 +00:00
read 'x-real-ip' header from nginx in websocket lib. (#1665)
* read 'x-real-ip' header from nginx in websocket lib. * change default real_ip value to nil
This commit is contained in:
@@ -139,6 +139,9 @@ local function read_handshake(self, upgrade_ops)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- read 'x-real-ip' header from nginx
|
||||||
|
self.real_ip = header["x-real-ip"]
|
||||||
|
|
||||||
-- response handshake
|
-- response handshake
|
||||||
local accept = crypt.base64encode(crypt.sha1(sw_key .. self.guid))
|
local accept = crypt.base64encode(crypt.sha1(sw_key .. self.guid))
|
||||||
local resp = "HTTP/1.1 101 Switching Protocols\r\n"..
|
local resp = "HTTP/1.1 101 Switching Protocols\r\n"..
|
||||||
@@ -497,6 +500,11 @@ function M.addrinfo(id)
|
|||||||
return ws_obj.addr
|
return ws_obj.addr
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function M.real_ip(id)
|
||||||
|
local ws_obj = assert(ws_pool[id])
|
||||||
|
return ws_obj.real_ip
|
||||||
|
end
|
||||||
|
|
||||||
function M.close(id, code ,reason)
|
function M.close(id, code ,reason)
|
||||||
local ws_obj = ws_pool[id]
|
local ws_obj = ws_pool[id]
|
||||||
if not ws_obj then
|
if not ws_obj then
|
||||||
|
|||||||
Reference in New Issue
Block a user