267 if not sid then |
267 if not sid then |
268 -- New session request |
268 -- New session request |
269 context.notopen = nil; -- Signals that we accept this opening tag |
269 context.notopen = nil; -- Signals that we accept this opening tag |
270 |
270 |
271 local to_host = nameprep(attr.to); |
271 local to_host = nameprep(attr.to); |
272 local wait = tonumber(attr.wait); |
|
273 if not to_host then |
272 if not to_host then |
274 log("debug", "BOSH client tried to connect to invalid host: %s", tostring(attr.to)); |
273 log("debug", "BOSH client tried to connect to invalid host: %s", tostring(attr.to)); |
275 local close_reply = st.stanza("body", { xmlns = xmlns_bosh, type = "terminate", |
274 local close_reply = st.stanza("body", { xmlns = xmlns_bosh, type = "terminate", |
276 ["xmlns:stream"] = xmlns_streams, condition = "improper-addressing" }); |
275 ["xmlns:stream"] = xmlns_streams, condition = "improper-addressing" }); |
277 response:send(tostring(close_reply)); |
276 response:send(tostring(close_reply)); |
278 return; |
277 return; |
279 end |
278 end |
|
279 |
|
280 local wait = tonumber(attr.wait); |
280 if not rid or (not attr.wait or not wait or wait < 0 or wait % 1 ~= 0) then |
281 if not rid or (not attr.wait or not wait or wait < 0 or wait % 1 ~= 0) then |
281 log("debug", "BOSH client sent invalid rid or wait attributes: rid=%s, wait=%s", tostring(attr.rid), tostring(attr.wait)); |
282 log("debug", "BOSH client sent invalid rid or wait attributes: rid=%s, wait=%s", tostring(attr.rid), tostring(attr.wait)); |
282 local close_reply = st.stanza("body", { xmlns = xmlns_bosh, type = "terminate", |
283 local close_reply = st.stanza("body", { xmlns = xmlns_bosh, type = "terminate", |
283 ["xmlns:stream"] = xmlns_streams, condition = "bad-request" }); |
284 ["xmlns:stream"] = xmlns_streams, condition = "bad-request" }); |
284 response:send(tostring(close_reply)); |
285 response:send(tostring(close_reply)); |