Comparison

plugins/mod_admin_telnet.lua @ 5567:c4ab25b35a55

mod_admin_telnet: Add some DNS commands.
author Kim Alvefur <zash@zash.se>
date Tue, 07 May 2013 17:17:32 +0200
parent 5520:75230be5be58
child 5579:e449e6342e36
child 5596:73fea1a87afd
comparison
equal deleted inserted replaced
5566:74ae3e7e8779 5567:c4ab25b35a55
205 print [[module - Commands to load/reload/unload modules/plugins]] 205 print [[module - Commands to load/reload/unload modules/plugins]]
206 print [[host - Commands to activate, deactivate and list virtual hosts]] 206 print [[host - Commands to activate, deactivate and list virtual hosts]]
207 print [[user - Commands to create and delete users, and change their passwords]] 207 print [[user - Commands to create and delete users, and change their passwords]]
208 print [[server - Uptime, version, shutting down, etc.]] 208 print [[server - Uptime, version, shutting down, etc.]]
209 print [[port - Commands to manage ports the server is listening on]] 209 print [[port - Commands to manage ports the server is listening on]]
210 print [[dns - Commands to manage and inspect the internal DNS resolver]]
210 print [[config - Reloading the configuration, etc.]] 211 print [[config - Reloading the configuration, etc.]]
211 print [[console - Help regarding the console itself]] 212 print [[console - Help regarding the console itself]]
212 elseif section == "c2s" then 213 elseif section == "c2s" then
213 print [[c2s:show(jid) - Show all client sessions with the specified JID (or all if no JID given)]] 214 print [[c2s:show(jid) - Show all client sessions with the specified JID (or all if no JID given)]]
214 print [[c2s:show_insecure() - Show all unencrypted client connections]] 215 print [[c2s:show_insecure() - Show all unencrypted client connections]]
237 print [[server:uptime() - Show how long the server has been running]] 238 print [[server:uptime() - Show how long the server has been running]]
238 print [[server:shutdown(reason) - Shut down the server, with an optional reason to be broadcast to all connections]] 239 print [[server:shutdown(reason) - Shut down the server, with an optional reason to be broadcast to all connections]]
239 elseif section == "port" then 240 elseif section == "port" then
240 print [[port:list() - Lists all network ports prosody currently listens on]] 241 print [[port:list() - Lists all network ports prosody currently listens on]]
241 print [[port:close(port, interface) - Close a port]] 242 print [[port:close(port, interface) - Close a port]]
243 elseif section == "dns" then
244 print [[dns:lookup(name, type, class) - Do a DNS lookup]]
245 print [[dns:addnameserver(nameserver) - Add a nameserver to the list]]
246 print [[dns:setnameserver(nameserver) - Replace the list of name servers with the supplied one]]
247 print [[dns:purge() - Clear the DNS cache]]
248 print [[dns:cache() - Show cached records]]
242 elseif section == "config" then 249 elseif section == "config" then
243 print [[config:reload() - Reload the server configuration. Modules may need to be reloaded for changes to take effect.]] 250 print [[config:reload() - Reload the server configuration. Modules may need to be reloaded for changes to take effect.]]
244 elseif section == "console" then 251 elseif section == "console" then
245 print [[Hey! Welcome to Prosody's admin console.]] 252 print [[Hey! Welcome to Prosody's admin console.]]
246 print [[First thing, if you're ever wondering how to get out, simply type 'quit'.]] 253 print [[First thing, if you're ever wondering how to get out, simply type 'quit'.]]
999 else 1006 else
1000 return nil, "No such host"; 1007 return nil, "No such host";
1001 end 1008 end
1002 end 1009 end
1003 1010
1011 def_env.dns = {};
1012 local adns = require"net.adns";
1013 local dns = require"net.dns";
1014
1015 function def_env.dns:lookup(name, typ, class)
1016 local ret = "Query sent";
1017 local print = self.session.print;
1018 local function handler(...)
1019 ret = "Got response";
1020 print(...);
1021 end
1022 adns.lookup(handler, name, typ, class);
1023 return true, ret;
1024 end
1025
1026 function def_env.dns:addnameserver(...)
1027 dns.addnameserver(...)
1028 return true
1029 end
1030
1031 function def_env.dns:setnameserver(...)
1032 dns.setnameserver(...)
1033 return true
1034 end
1035
1036 function def_env.dns:purge()
1037 dns.purge()
1038 return true
1039 end
1040
1041 function def_env.dns:cache()
1042 return true, "Cache:\n"..tostring(dns.cache())
1043 end
1044
1004 ------------- 1045 -------------
1005 1046
1006 function printbanner(session) 1047 function printbanner(session)
1007 local option = module:get_option("console_banner"); 1048 local option = module:get_option("console_banner");
1008 if option == nil or option == "full" or option == "graphic" then 1049 if option == nil or option == "full" or option == "graphic" then