comparison mod_tcpproxy/mod_tcpproxy.lua @ 4853:3804332c204e

mod_tcpproxy: Reject missing or non-number block-size, as per XEP-0047
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 07 Jan 2022 19:55:03 +0100
parents db8b256f51ff
children
comparison
equal deleted inserted replaced
4852:810b0e17d3aa 4853:3804332c204e
42 end 42 end
43 43
44 if ibb_tag.name == "open" then 44 if ibb_tag.name == "open" then
45 -- Starting a new stream 45 -- Starting a new stream
46 local to_host, to_port = ibb_tag.attr[host_attr], ibb_tag.attr[port_attr]; 46 local to_host, to_port = ibb_tag.attr[host_attr], ibb_tag.attr[port_attr];
47 local jid, sid = stanza.attr.from, ibb_tag.attr.sid; 47 local jid, sid, block_size = stanza.attr.from, ibb_tag.attr.sid, ibb_tag.attr["block-size"];
48 if not (to_host and to_port) then 48 if not (to_host and to_port) then
49 origin.send(st.error_reply(stanza, "modify", "bad-request", "No host/port specified")); 49 origin.send(st.error_reply(stanza, "modify", "bad-request", "No host/port specified"));
50 return true; 50 return true;
51 elseif not sid or sid == "" then 51 elseif not sid or sid == "" then
52 origin.send(st.error_reply(stanza, "modify", "bad-request", "No sid specified")); 52 origin.send(st.error_reply(stanza, "modify", "bad-request", "No sid specified"));
53 return true;
54 elseif not block_size or not tonumber(block_size) then
55 origin.send(st.error_reply(stanza, "modify", "bad-request", "Bad block-size attribute"));
53 return true; 56 return true;
54 elseif ibb_tag.attr.stanza ~= "message" then 57 elseif ibb_tag.attr.stanza ~= "message" then
55 origin.send(st.error_reply(stanza, "modify", "bad-request", "Only 'message' stanza transport is supported")); 58 origin.send(st.error_reply(stanza, "modify", "bad-request", "Only 'message' stanza transport is supported"));
56 return true; 59 return true;
57 end 60 end