Software /
code /
prosody-modules
Diff
mod_websocket/mod_websocket.lua @ 1193:bbe278a56b0a
mod_websocket: Add consider_websocket_secure option
author | Florian Zeitz <florob@babelmonkeys.de> |
---|---|
date | Wed, 18 Sep 2013 00:57:06 +0200 |
parent | 1029:9d85aded2fb6 |
child | 1272:717a08403b26 |
line wrap: on
line diff
--- a/mod_websocket/mod_websocket.lua Tue Sep 17 16:02:33 2013 +0200 +++ b/mod_websocket/mod_websocket.lua Wed Sep 18 00:57:06 2013 +0200 @@ -25,6 +25,7 @@ local s_byte = string.byte; local s_char= string.char; +local consider_websocket_secure = module:get_option_boolean("consider_websocket_secure"); local cross_domain = module:get_option("cross_domain_websocket"); if cross_domain then if cross_domain == true then @@ -240,8 +241,12 @@ conn:setlistener(c2s_listener); c2s_listener.onconnect(conn); + local session = sessions[conn]; + + session.secure = consider_websocket_secure or session.secure; + local frameBuffer = ""; - add_filter(sessions[conn], "bytes/in", function(data) + add_filter(session, "bytes/in", function(data) local cache = {}; frameBuffer = frameBuffer .. data; local frame, length = parse_frame(frameBuffer); @@ -256,7 +261,7 @@ return t_concat(cache, ""); end); - add_filter(sessions[conn], "bytes/out", function(data) + add_filter(session, "bytes/out", function(data) return build_frame({ FIN = true, opcode = 0x01, data = tostring(data)}); end);