Software /
code /
prosody
Comparison
plugins/mod_console.lua @ 1241:9c53fb182044
mod_console: c2s:show(), c2s:show_secure(), c2s:show_insecure()
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 30 May 2009 15:25:27 +0100 |
parent | 1240:397b6e9c1568 |
child | 1315:bfcd3f0a49df |
comparison
equal
deleted
inserted
replaced
1240:397b6e9c1568 | 1241:9c53fb182044 |
---|---|
191 return true, "Done"; | 191 return true, "Done"; |
192 end | 192 end |
193 | 193 |
194 function def_env.hosts:add(name) | 194 function def_env.hosts:add(name) |
195 end | 195 end |
196 | |
197 def_env.c2s = {}; | |
198 | |
199 local function show_c2s(callback) | |
200 for hostname, host in pairs(hosts) do | |
201 for username, user in pairs(host.sessions or {}) do | |
202 for resource, session in pairs(user.sessions or {}) do | |
203 local jid = username.."@"..hostname.."/"..resource; | |
204 callback(jid, session); | |
205 end | |
206 end | |
207 end | |
208 end | |
209 | |
210 function def_env.c2s:show(match_jid) | |
211 local print, count = self.session.print, 0; | |
212 show_c2s(function (jid) | |
213 if (not match_jid) or jid:match(match_jid) then | |
214 count = count + 1; | |
215 print(jid); | |
216 end | |
217 end); | |
218 return true, "Total: "..count.." clients"; | |
219 end | |
220 | |
221 function def_env.c2s:show_insecure(match_jid) | |
222 local print, count = self.session.print, 0; | |
223 show_c2s(function (jid, session) | |
224 if ((not match_jid) or jid:match(match_jid)) and not session.secure then | |
225 count = count + 1; | |
226 print(jid); | |
227 end | |
228 end); | |
229 return true, "Total: "..count.." insecure client connections"; | |
230 end | |
231 | |
232 function def_env.c2s:show_secure(match_jid) | |
233 local print, count = self.session.print, 0; | |
234 show_c2s(function (jid, session) | |
235 if ((not match_jid) or jid:match(match_jid)) and session.secure then | |
236 count = count + 1; | |
237 print(jid); | |
238 end | |
239 end); | |
240 return true, "Total: "..count.." secure client connections"; | |
241 end | |
242 | |
196 | 243 |
197 def_env.s2s = {}; | 244 def_env.s2s = {}; |
198 function def_env.s2s:show(match_jid) | 245 function def_env.s2s:show(match_jid) |
199 local _print = self.session.print; | 246 local _print = self.session.print; |
200 local print = self.session.print; | 247 local print = self.session.print; |