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'}; |