equal
deleted
inserted
replaced
27 local parse_close = websocket_frames.parse_close; |
27 local parse_close = websocket_frames.parse_close; |
28 |
28 |
29 local t_concat = table.concat; |
29 local t_concat = table.concat; |
30 |
30 |
31 local stanza_size_limit = module:get_option_number("c2s_stanza_size_limit", 10 * 1024 * 1024); |
31 local stanza_size_limit = module:get_option_number("c2s_stanza_size_limit", 10 * 1024 * 1024); |
|
32 local frame_buffer_limit = module:get_option_number("websocket_frame_buffer_limit", 2 * stanza_size_limit); |
32 local frame_fragment_limit = module:get_option_number("websocket_frame_fragment_limit", 8); |
33 local frame_fragment_limit = module:get_option_number("websocket_frame_fragment_limit", 8); |
33 local stream_close_timeout = module:get_option_number("c2s_close_timeout", 5); |
34 local stream_close_timeout = module:get_option_number("c2s_close_timeout", 5); |
34 local consider_websocket_secure = module:get_option_boolean("consider_websocket_secure"); |
35 local consider_websocket_secure = module:get_option_boolean("consider_websocket_secure"); |
35 local cross_domain = module:get_option_set("cross_domain_websocket", {}); |
36 local cross_domain = module:get_option_set("cross_domain_websocket", {}); |
36 if cross_domain:contains("*") or cross_domain:contains(true) then |
37 if cross_domain:contains("*") or cross_domain:contains(true) then |
270 session.websocket_request = request; |
271 session.websocket_request = request; |
271 |
272 |
272 session.open_stream = session_open_stream; |
273 session.open_stream = session_open_stream; |
273 session.close = session_close; |
274 session.close = session_close; |
274 |
275 |
275 -- max frame header is 22 bytes |
276 local frameBuffer = dbuffer.new(frame_buffer_limit, frame_fragment_limit); |
276 local frameBuffer = dbuffer.new(stanza_size_limit + 22, frame_fragment_limit); |
|
277 add_filter(session, "bytes/in", function(data) |
277 add_filter(session, "bytes/in", function(data) |
278 if not frameBuffer:write(data) then |
278 if not frameBuffer:write(data) then |
279 session.log("warn", "websocket frame buffer full - terminating session"); |
279 session.log("warn", "websocket frame buffer full - terminating session"); |
280 session:close({ condition = "resource-constraint", text = "frame buffer exceeded" }); |
280 session:close({ condition = "resource-constraint", text = "frame buffer exceeded" }); |
281 return; |
281 return; |