Software /
code /
prosody
Comparison
plugins/mod_console.lua @ 1322:33d103b0283f
mod_console: Show total incoming/outgoing s2s connections
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 06 Jun 2009 21:29:34 +0100 |
parent | 1317:f6e56a555c37 |
child | 1340:f707d0957155 |
comparison
equal
deleted
inserted
replaced
1321:0698d0d39b35 | 1322:33d103b0283f |
---|---|
316 | 316 |
317 def_env.s2s = {}; | 317 def_env.s2s = {}; |
318 function def_env.s2s:show(match_jid) | 318 function def_env.s2s:show(match_jid) |
319 local _print = self.session.print; | 319 local _print = self.session.print; |
320 local print = self.session.print; | 320 local print = self.session.print; |
321 | |
322 local count_in, count_out = 0,0; | |
323 | |
321 for host, host_session in pairs(hosts) do | 324 for host, host_session in pairs(hosts) do |
322 print = function (...) _print(host); _print(...); print = _print; end | 325 print = function (...) _print(host); _print(...); print = _print; end |
323 for remotehost, session in pairs(host_session.s2sout) do | 326 for remotehost, session in pairs(host_session.s2sout) do |
324 if (not match_jid) or remotehost:match(match_jid) or host:match(match_jid) then | 327 if (not match_jid) or remotehost:match(match_jid) or host:match(match_jid) then |
328 count_out = count_out + 1; | |
325 print(" "..host.." -> "..remotehost); | 329 print(" "..host.." -> "..remotehost); |
326 if session.sendq then | 330 if session.sendq then |
327 print(" There are "..#session.sendq.." queued outgoing stanzas for this connection"); | 331 print(" There are "..#session.sendq.." queued outgoing stanzas for this connection"); |
328 end | 332 end |
329 if session.type == "s2sout_unauthed" then | 333 if session.type == "s2sout_unauthed" then |
352 end | 356 end |
353 | 357 |
354 for session in pairs(incoming_s2s) do | 358 for session in pairs(incoming_s2s) do |
355 if session.to_host == host and ((not match_jid) or host:match(match_jid) | 359 if session.to_host == host and ((not match_jid) or host:match(match_jid) |
356 or (session.from_host and session.from_host:match(match_jid))) then | 360 or (session.from_host and session.from_host:match(match_jid))) then |
361 count_in = count_in + 1; | |
357 print(" "..host.." <- "..(session.from_host or "(unknown)")); | 362 print(" "..host.." <- "..(session.from_host or "(unknown)")); |
358 if session.type == "s2sin_unauthed" then | 363 if session.type == "s2sin_unauthed" then |
359 print(" Connection not yet authenticated"); | 364 print(" Connection not yet authenticated"); |
360 end | 365 end |
361 for name in pairs(session.hosts) do | 366 for name in pairs(session.hosts) do |
369 print = _print; | 374 print = _print; |
370 end | 375 end |
371 | 376 |
372 for session in pairs(incoming_s2s) do | 377 for session in pairs(incoming_s2s) do |
373 if not session.to_host and ((not match_jid) or session.from_host and session.from_host:match(match_jid)) then | 378 if not session.to_host and ((not match_jid) or session.from_host and session.from_host:match(match_jid)) then |
379 count_in = count_in + 1; | |
374 print("Other incoming s2s connections"); | 380 print("Other incoming s2s connections"); |
375 print(" (unknown) <- "..(session.from_host or "(unknown)")); | 381 print(" (unknown) <- "..(session.from_host or "(unknown)")); |
376 end | 382 end |
377 end | 383 end |
384 | |
385 return true, "Total: "..count_out.." outgoing, "..count_in.." incoming connections"; | |
378 end | 386 end |
379 | 387 |
380 ------------- | 388 ------------- |
381 | 389 |
382 function printbanner(session) | 390 function printbanner(session) |