Software /
code /
prosody
Comparison
core/s2smanager.lua @ 331:830fd67f9378
Quite some changes, to:
- Small logging fix for s2smanager
- Send a stream error if an incoming s2s connection is to an unrecognised hostname (fixes #11)
- init_xmlhandlers now takes a table of callbacks (includes changes to net/xmpp*_listener for this)
- Move sending of unavailable presence to where it should be, sessionmanager.destroy_session
- Fix sending of stream errors to wrong connection
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Tue, 18 Nov 2008 17:52:33 +0000 |
parent | 327:9439362caacc |
child | 333:8d15b073fdbe |
comparison
equal
deleted
inserted
replaced
330:d9d4c1de16ce | 331:830fd67f9378 |
---|---|
50 else | 50 else |
51 (host.log or log)("debug", "going to send stanza to "..to_host.." from "..from_host); | 51 (host.log or log)("debug", "going to send stanza to "..to_host.." from "..from_host); |
52 -- FIXME | 52 -- FIXME |
53 if host.from_host ~= from_host then | 53 if host.from_host ~= from_host then |
54 log("error", "WARNING! This might, possibly, be a bug, but it might not..."); | 54 log("error", "WARNING! This might, possibly, be a bug, but it might not..."); |
55 log("error", "We are going to send from %s instead of %s", host.from_host, from_host); | 55 log("error", "We are going to send from %s instead of %s", tostring(host.from_host), tostring(from_host)); |
56 end | 56 end |
57 host.sends2s(data); | 57 host.sends2s(data); |
58 host.log("debug", "stanza sent over "..host.type); | 58 host.log("debug", "stanza sent over "..host.type); |
59 end | 59 end |
60 else | 60 else |
135 | 135 |
136 session.streamid = uuid_gen(); | 136 session.streamid = uuid_gen(); |
137 print(session, session.from_host, "incoming s2s stream opened"); | 137 print(session, session.from_host, "incoming s2s stream opened"); |
138 send("<?xml version='1.0'?>"); | 138 send("<?xml version='1.0'?>"); |
139 send(stanza("stream:stream", { xmlns='jabber:server', ["xmlns:db"]='jabber:server:dialback', ["xmlns:stream"]='http://etherx.jabber.org/streams', id=session.streamid, from=session.to_host }):top_tag()); | 139 send(stanza("stream:stream", { xmlns='jabber:server', ["xmlns:db"]='jabber:server:dialback', ["xmlns:stream"]='http://etherx.jabber.org/streams', id=session.streamid, from=session.to_host }):top_tag()); |
140 if session.to_host and not hosts[session.to_host] then | |
141 -- Attempting to connect to a host we don't serve | |
142 session:disconnect("host-unknown"); | |
143 return; | |
144 end | |
140 elseif session.direction == "outgoing" then | 145 elseif session.direction == "outgoing" then |
141 -- If we are just using the connection for verifying dialback keys, we won't try and auth it | 146 -- If we are just using the connection for verifying dialback keys, we won't try and auth it |
142 if not attr.id then error("stream response did not give us a streamid!!!"); end | 147 if not attr.id then error("stream response did not give us a streamid!!!"); end |
143 session.streamid = attr.id; | 148 session.streamid = attr.id; |
144 | 149 |
216 end | 221 end |
217 end | 222 end |
218 | 223 |
219 function destroy_session(session) | 224 function destroy_session(session) |
220 (session.log or log)("info", "Destroying "..tostring(session.direction).." session "..tostring(session.from_host).."->"..tostring(session.to_host)); | 225 (session.log or log)("info", "Destroying "..tostring(session.direction).." session "..tostring(session.from_host).."->"..tostring(session.to_host)); |
226 | |
227 -- FIXME: Flush sendq here/report errors to originators | |
228 | |
221 if session.direction == "outgoing" then | 229 if session.direction == "outgoing" then |
222 hosts[session.from_host].s2sout[session.to_host] = nil; | 230 hosts[session.from_host].s2sout[session.to_host] = nil; |
223 end | 231 end |
232 | |
224 session.conn = nil; | 233 session.conn = nil; |
225 session.disconnect = nil; | 234 session.disconnect = nil; |
226 for k in pairs(session) do | 235 for k in pairs(session) do |
227 if k ~= "trace" then | 236 if k ~= "trace" then |
228 session[k] = nil; | 237 session[k] = nil; |