Software / code / prosody
Comparison
core/sessionmanager.lua @ 1929:b8e6764ffefd
sessionmanager: Mark client streams as opened sooner to avoid wrapping errors in unnecessary stream tags
| author | Paul Aurich <paul@darkrain42.org> |
|---|---|
| date | Tue, 06 Oct 2009 11:15:55 +0100 |
| parent | 1873:3b770710a1ee |
| child | 2103:0e0bc74c64a0 |
| child | 2140:94b7ba39787d |
comparison
equal
deleted
inserted
replaced
| 1928:d11f07ca0b75 | 1929:b8e6764ffefd |
|---|---|
| 167 session.host = attr.to or error("Client failed to specify destination hostname"); | 167 session.host = attr.to or error("Client failed to specify destination hostname"); |
| 168 session.host = nameprep(session.host); | 168 session.host = nameprep(session.host); |
| 169 session.version = tonumber(attr.version) or 0; | 169 session.version = tonumber(attr.version) or 0; |
| 170 session.streamid = uuid_generate(); | 170 session.streamid = uuid_generate(); |
| 171 (session.log or session)("debug", "Client sent opening <stream:stream> to %s", session.host); | 171 (session.log or session)("debug", "Client sent opening <stream:stream> to %s", session.host); |
| 172 | |
| 173 send("<?xml version='1.0'?>"); | |
| 174 send(format("<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='%s' from='%s' version='1.0' xml:lang='en'>", session.streamid, session.host)); | |
| 175 | 172 |
| 176 if not hosts[session.host] then | 173 if not hosts[session.host] then |
| 177 -- We don't serve this host... | 174 -- We don't serve this host... |
| 178 session:close{ condition = "host-unknown", text = "This server does not serve "..tostring(session.host)}; | 175 session:close{ condition = "host-unknown", text = "This server does not serve "..tostring(session.host)}; |
| 179 return; | 176 return; |
| 180 end | 177 end |
| 181 | 178 |
| 179 send("<?xml version='1.0'?>"); | |
| 180 send(format("<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='%s' from='%s' version='1.0' xml:lang='en'>", session.streamid, session.host)); | |
| 181 | |
| 182 (session.log or log)("debug", "Sent reply <stream:stream> to client"); | |
| 183 session.notopen = nil; | |
| 184 | |
| 182 -- If session.secure is *false* (not nil) then it means we /were/ encrypting | 185 -- If session.secure is *false* (not nil) then it means we /were/ encrypting |
| 183 -- since we now have a new stream header, session is secured | 186 -- since we now have a new stream header, session is secured |
| 184 if session.secure == false then | 187 if session.secure == false then |
| 185 session.secure = true; | 188 session.secure = true; |
| 186 end | 189 end |
| 187 | 190 |
| 188 local features = st.stanza("stream:features"); | 191 local features = st.stanza("stream:features"); |
| 189 fire_event("stream-features", session, features); | 192 fire_event("stream-features", session, features); |
| 190 | 193 |
| 191 send(features); | 194 send(features); |
| 192 | 195 |
| 193 (session.log or log)("debug", "Sent reply <stream:stream> to client"); | |
| 194 session.notopen = nil; | |
| 195 end | 196 end |
| 196 | 197 |
| 197 function streamclosed(session) | 198 function streamclosed(session) |
| 198 session.send("</stream:stream>"); | 199 session.send("</stream:stream>"); |
| 199 session.notopen = true; | 200 session.notopen = true; |