Mercurial > prosody-hg
comparison plugins/mod_console.lua @ 1085:1ac11fb753ca
mod_console: Add s2s:show() command to list s2s connections
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Sat, 02 May 2009 16:59:37 +0100 |
| parents | 3806173670f2 |
| children | 397b6e9c1568 |
comparison
equal
deleted
inserted
replaced
| 1084:422be8f8911c | 1085:1ac11fb753ca |
|---|---|
| 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 | 196 |
| 197 def_env.s2s = {}; | |
| 198 function def_env.s2s:show() | |
| 199 local _print = self.session.print; | |
| 200 local print = self.session.print; | |
| 201 for host, host_session in pairs(hosts) do | |
| 202 print = function (...) _print(host); _print(...); print = _print; end | |
| 203 for remotehost, session in pairs(host_session.s2sout) do | |
| 204 print(" "..host.." -> "..remotehost); | |
| 205 if session.sendq then | |
| 206 print(" There are "..#session.sendq.." queued outgoing stanzas for this connection"); | |
| 207 end | |
| 208 if session.type == "s2sout_unauthed" then | |
| 209 if session.connecting then | |
| 210 print(" Connection not yet established"); | |
| 211 if not session.srv_hosts then | |
| 212 if not session.conn then | |
| 213 print(" We do not yet have a DNS answer for this host's SRV records"); | |
| 214 else | |
| 215 print(" This host has no SRV records, using A record instead"); | |
| 216 end | |
| 217 elseif session.srv_choice then | |
| 218 print(" We are on SRV record "..session.srv_choice.." of "..#session.srv_hosts); | |
| 219 local srv_choice = session.srv_hosts[session.srv_choice]; | |
| 220 print(" Using "..(srv_choice.target or ".")..":"..(srv_choice.port or 5269)); | |
| 221 end | |
| 222 elseif session.notopen then | |
| 223 print(" The <stream> has not yet been opened"); | |
| 224 elseif not session.dialback_key then | |
| 225 print(" Dialback has not been initiated yet"); | |
| 226 elseif session.dialback_key then | |
| 227 print(" Dialback has been requested, but no result received"); | |
| 228 end | |
| 229 end | |
| 230 end | |
| 231 | |
| 232 for session in pairs(incoming_s2s) do | |
| 233 if session.to_host == host then | |
| 234 print(" "..host.." <- "..(session.from_host or "(unknown)")); | |
| 235 if session.type == "s2sin_unauthed" then | |
| 236 print(" Connection not yet authenticated"); | |
| 237 end | |
| 238 for name in pairs(session.hosts) do | |
| 239 if name ~= session.from_host then | |
| 240 print(" also hosts "..tostring(name)); | |
| 241 end | |
| 242 end | |
| 243 end | |
| 244 end | |
| 245 print = _print; | |
| 246 end | |
| 247 for session in pairs(incoming_s2s) do | |
| 248 if not session.to_host then | |
| 249 print("Other incoming s2s connections"); | |
| 250 print(" (unknown) <- "..(session.from_host or "(unknown)")); | |
| 251 end | |
| 252 end | |
| 253 end | |
| 254 | |
| 197 ------------- | 255 ------------- |
| 198 | 256 |
| 199 function printbanner(session) | 257 function printbanner(session) |
| 200 session.print [[ | 258 session.print [[ |
| 201 ____ \ / _ | 259 ____ \ / _ |
