net/xmppcomponent_listener.lua

changeset 3315
f4d2de6ac22e
parent 2925
692b3c6c5bd2
child 3316
6122a6270773
equal deleted inserted replaced
3314:4019ad5c61e2 3315:f4d2de6ac22e
97 function stream_callbacks.handlestanza(session, stanza) 97 function stream_callbacks.handlestanza(session, stanza)
98 -- Namespaces are icky. 98 -- Namespaces are icky.
99 if not stanza.attr.xmlns and stanza.name == "handshake" then 99 if not stanza.attr.xmlns and stanza.name == "handshake" then
100 stanza.attr.xmlns = xmlns_component; 100 stanza.attr.xmlns = xmlns_component;
101 end 101 end
102 local from = stanza.attr.from;
103 if from then
104 if session.component_validate_from then
105 local _, domain = jid_split(stanza.attr.from);
106 if domain ~= session.host then
107 -- Return error
108 session:close{
109 condition = "invalid-from";
110 text = "Component tried to send from address <"..tostring(from)
111 .."> which is not in domain <"..tostring(session.host)..">";
112 };
113 return;
114 end
115 end
116 else
117 stanza.attr.from = session.host;
118 end
119 if not stanza.attr.to then
120 session.send(st.error_reply(stanza, "modify", "bad-request", "Components MUST specify a 'to' address on stanzas"));
121 return;
122 end
102 return core_process_stanza(session, stanza); 123 return core_process_stanza(session, stanza);
103 end 124 end
104 125
105 --- Closing a component connection 126 --- Closing a component connection
106 local stream_xmlns_attr = {xmlns='urn:ietf:params:xml:ns:xmpp-streams'}; 127 local stream_xmlns_attr = {xmlns='urn:ietf:params:xml:ns:xmpp-streams'};

mercurial