Comparison

plugins/mod_websocket.lua @ 11108:fa1821b56f75 0.11

mod_websocket: handle full frame buffer and raise stream error
author Matthew Wild <mwild1@gmail.com>
date Thu, 17 Sep 2020 16:41:48 +0100
parent 11107:ddd0007e0f1b
child 11109:7ec7dba7ba8b
comparison
equal deleted inserted replaced
11107:ddd0007e0f1b 11108:fa1821b56f75
273 session.close = session_close; 273 session.close = session_close;
274 274
275 -- max frame header is 22 bytes 275 -- max frame header is 22 bytes
276 local frameBuffer = dbuffer.new(stanza_size_limit + 22, 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 frameBuffer:write(data); 278 if not frameBuffer:write(data) then
279 session.log("warn", "websocket frame buffer full - terminating session");
280 session:close({ condition = "resource-constraint", text = "frame buffer exceeded" });
281 return;
282 end
279 283
280 local cache = {}; 284 local cache = {};
281 local frame, length = parse_frame(frameBuffer); 285 local frame, length = parse_frame(frameBuffer);
282 286
283 while frame do 287 while frame do