Software / code / prosody
Comparison
plugins/mod_c2s.lua @ 5668:5a9318ac92f6
mod_c2s: Become a shared module and allow being disabled on some virtualhosts
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Tue, 11 Jun 2013 21:18:51 +0200 |
| parent | 5638:c5b7f4858014 |
| child | 5669:9345c161481f |
comparison
equal
deleted
inserted
replaced
| 5667:0bf1cdea43f6 | 5668:5a9318ac92f6 |
|---|---|
| 48 end | 48 end |
| 49 session.version = tonumber(attr.version) or 0; | 49 session.version = tonumber(attr.version) or 0; |
| 50 session.streamid = uuid_generate(); | 50 session.streamid = uuid_generate(); |
| 51 (session.log or session)("debug", "Client sent opening <stream:stream> to %s", session.host); | 51 (session.log or session)("debug", "Client sent opening <stream:stream> to %s", session.host); |
| 52 | 52 |
| 53 if not hosts[session.host] then | 53 if not hosts[session.host] or not hosts[session.host].modules.c2s then |
| 54 -- We don't serve this host... | 54 -- We don't serve this host... |
| 55 session:close{ condition = "host-unknown", text = "This server does not serve "..tostring(session.host)}; | 55 session:close{ condition = "host-unknown", text = "This server does not serve "..tostring(session.host)}; |
| 56 return; | 56 return; |
| 57 end | 57 end |
| 58 | 58 |
| 271 | 271 |
| 272 function listener.associate_session(conn, session) | 272 function listener.associate_session(conn, session) |
| 273 sessions[conn] = session; | 273 sessions[conn] = session; |
| 274 end | 274 end |
| 275 | 275 |
| 276 function module.add_host() end | |
| 277 | |
| 276 module:hook("server-stopping", function(event) | 278 module:hook("server-stopping", function(event) |
| 277 local reason = event.reason; | 279 local reason = event.reason; |
| 278 for _, session in pairs(sessions) do | 280 for _, session in pairs(sessions) do |
| 279 session:close{ condition = "system-shutdown", text = reason }; | 281 session:close{ condition = "system-shutdown", text = reason }; |
| 280 end | 282 end |