Software / code / prosody
Comparison
plugins/mod_bosh.lua @ 11123:0f4260f99ea2 0.11
mod_bosh: Pick out the 'wait' before checking it instead of earlier
Going to add more host related checks, so to keep the wait variable
closer to the related checks
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sat, 03 Oct 2020 14:59:11 +0200 |
| parent | 9777:2e07d2f71599 |
| child | 11124:1aea75b63d0a |
comparison
equal
deleted
inserted
replaced
| 11119:68df52bf08d5 | 11123:0f4260f99ea2 |
|---|---|
| 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)); |