Mercurial > prosody-hg
comparison plugins/mod_admin_telnet.lua @ 4977:7006ccbf22a9
Merge with Zash
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Sun, 22 Jul 2012 18:47:40 +0100 |
| parents | bfc52b9137c8 1574f18b0ca4 |
| children | 5614bbc163e0 |
comparison
equal
deleted
inserted
replaced
| 4971:bfc52b9137c8 | 4977:7006ccbf22a9 |
|---|---|
| 185 print [[]] | 185 print [[]] |
| 186 print [[c2s - Commands to manage local client-to-server sessions]] | 186 print [[c2s - Commands to manage local client-to-server sessions]] |
| 187 print [[s2s - Commands to manage sessions between this server and others]] | 187 print [[s2s - Commands to manage sessions between this server and others]] |
| 188 print [[module - Commands to load/reload/unload modules/plugins]] | 188 print [[module - Commands to load/reload/unload modules/plugins]] |
| 189 print [[host - Commands to activate, deactivate and list virtual hosts]] | 189 print [[host - Commands to activate, deactivate and list virtual hosts]] |
| 190 print [[user - Commands to create and delete users, and change their passwords]] | |
| 190 print [[server - Uptime, version, shutting down, etc.]] | 191 print [[server - Uptime, version, shutting down, etc.]] |
| 191 print [[config - Reloading the configuration, etc.]] | 192 print [[config - Reloading the configuration, etc.]] |
| 192 print [[console - Help regarding the console itself]] | 193 print [[console - Help regarding the console itself]] |
| 193 elseif section == "c2s" then | 194 elseif section == "c2s" then |
| 194 print [[c2s:show(jid) - Show all client sessions with the specified JID (or all if no JID given)]] | 195 print [[c2s:show(jid) - Show all client sessions with the specified JID (or all if no JID given)]] |
| 205 print [[module:list(host) - List the modules loaded on the specified host]] | 206 print [[module:list(host) - List the modules loaded on the specified host]] |
| 206 elseif section == "host" then | 207 elseif section == "host" then |
| 207 print [[host:activate(hostname) - Activates the specified host]] | 208 print [[host:activate(hostname) - Activates the specified host]] |
| 208 print [[host:deactivate(hostname) - Disconnects all clients on this host and deactivates]] | 209 print [[host:deactivate(hostname) - Disconnects all clients on this host and deactivates]] |
| 209 print [[host:list() - List the currently-activated hosts]] | 210 print [[host:list() - List the currently-activated hosts]] |
| 211 elseif section == "user" then | |
| 212 print [[user:create(jid, password) - Create the specified user account]] | |
| 213 print [[user:password(jid, password) - Set the password for the specified user account]] | |
| 214 print [[user:delete(jid, password) - Permanently remove the specified user account]] | |
| 210 elseif section == "server" then | 215 elseif section == "server" then |
| 211 print [[server:version() - Show the server's version number]] | 216 print [[server:version() - Show the server's version number]] |
| 212 print [[server:uptime() - Show how long the server has been running]] | 217 print [[server:uptime() - Show how long the server has been running]] |
| 213 print [[server:shutdown(reason) - Shut down the server, with an optional reason to be broadcast to all connections]] | 218 print [[server:shutdown(reason) - Shut down the server, with an optional reason to be broadcast to all connections]] |
| 214 elseif section == "config" then | 219 elseif section == "config" then |
| 854 return nil, "No such room: "..room_jid; | 859 return nil, "No such room: "..room_jid; |
| 855 end | 860 end |
| 856 return setmetatable({ room = room_obj }, console_room_mt); | 861 return setmetatable({ room = room_obj }, console_room_mt); |
| 857 end | 862 end |
| 858 | 863 |
| 864 def_env.user = {}; | |
| 865 function def_env.user:create(jid, password) | |
| 866 local username, host = jid_split(jid); | |
| 867 local ok, err = um.create_user(username, password, host); | |
| 868 if ok then | |
| 869 return true, "User created"; | |
| 870 else | |
| 871 return nil, "Could not create user: "..err; | |
| 872 end | |
| 873 end | |
| 874 | |
| 875 function def_env.user:delete(jid) | |
| 876 local username, host = jid_split(jid); | |
| 877 local ok, err = um.delete_user(username, host); | |
| 878 if ok then | |
| 879 return true, "User deleted"; | |
| 880 else | |
| 881 return nil, "Could not delete user: "..err; | |
| 882 end | |
| 883 end | |
| 884 | |
| 885 function def_env.user:passwd(jid, password) | |
| 886 local username, host = jid_split(jid); | |
| 887 local ok, err = um.set_password(username, password, host); | |
| 888 if ok then | |
| 889 return true, "User created"; | |
| 890 else | |
| 891 return nil, "Could not change password for user: "..err; | |
| 892 end | |
| 893 end | |
| 894 | |
| 859 ------------- | 895 ------------- |
| 860 | 896 |
| 861 function printbanner(session) | 897 function printbanner(session) |
| 862 local option = config.get("*", "core", "console_banner"); | 898 local option = config.get("*", "core", "console_banner"); |
| 863 if option == nil or option == "full" or option == "graphic" then | 899 if option == nil or option == "full" or option == "graphic" then |
