Software /
code /
prosody
Comparison
core/sessionmanager.lua @ 1076:ba3639692493
sessionmanager: Miscellaneous logging improvements, changing levels, improving messages and using session loggers where possible
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 30 Apr 2009 02:45:10 +0100 |
parent | 970:5516f9e66482 |
child | 1213:de66fa750daf |
comparison
equal
deleted
inserted
replaced
1075:831c84cbf5fa | 1076:ba3639692493 |
---|---|
43 if true then | 43 if true then |
44 session.trace = newproxy(true); | 44 session.trace = newproxy(true); |
45 getmetatable(session.trace).__gc = function () open_sessions = open_sessions - 1; end; | 45 getmetatable(session.trace).__gc = function () open_sessions = open_sessions - 1; end; |
46 end | 46 end |
47 open_sessions = open_sessions + 1; | 47 open_sessions = open_sessions + 1; |
48 log("info", "open sessions now: ".. open_sessions); | 48 log("debug", "open sessions now: ".. open_sessions); |
49 local w = conn.write; | 49 local w = conn.write; |
50 session.send = function (t) w(tostring(t)); end | 50 session.send = function (t) w(tostring(t)); end |
51 session.ip = conn.ip(); | 51 session.ip = conn.ip(); |
52 return session; | 52 return session; |
53 end | 53 end |
54 | 54 |
55 function destroy_session(session, err) | 55 function destroy_session(session, err) |
56 (session.log or log)("info", "Destroying session"); | 56 (session.log or log)("info", "Destroying session for %s (%s@%s)", session.full_jid or "(unknown)", session.username or "(unknown)", session.host or "(unknown)"); |
57 | 57 |
58 -- Send unavailable presence | 58 -- Send unavailable presence |
59 if session.presence then | 59 if session.presence then |
60 local pres = st.presence{ type = "unavailable" }; | 60 local pres = st.presence{ type = "unavailable" }; |
61 if (not err) or err == "closed" then err = "connection closed"; end | 61 if (not err) or err == "closed" then err = "connection closed"; end |
92 function make_authenticated(session, username) | 92 function make_authenticated(session, username) |
93 session.username = username; | 93 session.username = username; |
94 if session.type == "c2s_unauthed" then | 94 if session.type == "c2s_unauthed" then |
95 session.type = "c2s"; | 95 session.type = "c2s"; |
96 end | 96 end |
97 session.log("info", "Authenticated as %s@%s", username or "(unknown)", session.host or "(unknown)"); | |
97 return true; | 98 return true; |
98 end | 99 end |
99 | 100 |
100 -- returns true, nil on success | 101 -- returns true, nil on success |
101 -- returns nil, err_type, err, err_message on failure | 102 -- returns nil, err_type, err, err_message on failure |
174 local features = st.stanza("stream:features"); | 175 local features = st.stanza("stream:features"); |
175 fire_event("stream-features", session, features); | 176 fire_event("stream-features", session, features); |
176 | 177 |
177 send(features); | 178 send(features); |
178 | 179 |
179 (session.log or log)("info", "Sent reply <stream:stream> to client"); | 180 (session.log or log)("debug", "Sent reply <stream:stream> to client"); |
180 session.notopen = nil; | 181 session.notopen = nil; |
181 end | 182 end |
182 | 183 |
183 function streamclosed(session) | 184 function streamclosed(session) |
184 session.send("</stream:stream>"); | 185 session.send("</stream:stream>"); |