Software / code / prosody
Comparison
plugins/mod_component.lua @ 3616:95ae7af2c82b
mod_component: Rearranged the code a little.
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Fri, 12 Nov 2010 23:32:51 +0500 |
| parent | 3615:c72d24c2d97b |
| child | 3617:26c9ba8f309c |
comparison
equal
deleted
inserted
replaced
| 3615:c72d24c2d97b | 3616:95ae7af2c82b |
|---|---|
| 81 log("info", "Component for %s authentication failed", session.host); | 81 log("info", "Component for %s authentication failed", session.host); |
| 82 session:close{ condition = "not-authorized", text = "Given token does not match calculated token" }; | 82 session:close{ condition = "not-authorized", text = "Given token does not match calculated token" }; |
| 83 return true; | 83 return true; |
| 84 end | 84 end |
| 85 | 85 |
| 86 | |
| 87 -- Authenticated now | 86 -- Authenticated now |
| 88 log("info", "Component authenticated: %s", session.host); | 87 log("info", "Component authenticated: %s", session.host); |
| 89 | 88 |
| 90 session.component_validate_from = module:get_option_boolean("validate_from_addresses") ~= false; | 89 session.component_validate_from = module:get_option_boolean("validate_from_addresses") ~= false; |
| 91 | 90 |
| 93 if not main_session then | 92 if not main_session then |
| 94 send = session.send; | 93 send = session.send; |
| 95 main_session = session; | 94 main_session = session; |
| 96 session.on_destroy = on_destroy; | 95 session.on_destroy = on_destroy; |
| 97 log("info", "Component successfully registered"); | 96 log("info", "Component successfully registered"); |
| 97 session.send(st.stanza("handshake")); | |
| 98 else | 98 else |
| 99 log("error", "Multiple components bound to the same address, first one wins (TODO: Implement stanza distribution)"); | 99 log("error", "Multiple components bound to the same address, first one wins (TODO: Implement stanza distribution)"); |
| 100 session:close{ condition = "conflict", text = "Component already connected" }; | 100 session:close{ condition = "conflict", text = "Component already connected" }; |
| 101 return true; | |
| 102 end | 101 end |
| 103 | 102 |
| 104 -- Signal successful authentication | |
| 105 session.send(st.stanza("handshake")); | |
| 106 return true; | 103 return true; |
| 107 end | 104 end |
| 108 | 105 |
| 109 module:hook("stanza/jabber:component:accept:handshake", handle_component_auth); | 106 module:hook("stanza/jabber:component:accept:handshake", handle_component_auth); |