plugins/mod_console.lua

changeset 1616
80ea744f2643
parent 1575
ca39f78de3c8
child 1618
ba2a92230b77
child 1798
4c8f3fa9d926
equal deleted inserted replaced
1615:0e3eacf135f2 1616:80ea744f2643
152 end 152 end
153 session.print("!> "..res); 153 session.print("!> "..res);
154 return console_listener.listener(session.conn, res); 154 return console_listener.listener(session.conn, res);
155 end 155 end
156 session.print("Sorry, not sure what you want"); 156 session.print("Sorry, not sure what you want");
157 end
158
159 function commands.help(session, data)
160 local print = session.print;
161 local section = data:match("^help (%w+)");
162 if not section then
163 print [[Commands are divided into multiple sections. For help on a particular section, ]]
164 print [[type: help SECTION (for example, 'help c2s'). Sections are: ]]
165 print [[]]
166 print [[c2s - Commands to manage local client-to-server sessions]]
167 print [[s2s - Commands to manage sessions between this server and others]]
168 print [[module - Commands to load/reload/unload modules/plugins]]
169 print [[server - Uptime, version, shutting down, etc.]]
170 print [[console - Help regarding the console itself]]
171 elseif section == "c2s" then
172 print [[c2s:show(jid) - Show all client sessions with the specified JID (or all if no JID given)]]
173 print [[c2s:show_insecure() - Show all unencrypted client connections]]
174 print [[c2s:show_secure() - Show all encrypted client connections]]
175 print [[c2s:close(jid) - Close all sessions for the specified JID]]
176 elseif section == "s2s" then
177 print [[s2s:show(domain) - Show all s2s connections for the given domain (or all if no domain given)]]
178 print [[s2s:close(from, to) - Close a connection from one domain to another]]
179 elseif section == "module" then
180 print [[module:load(module, host) - Load the specified module on the specified host (or all hosts if none given)]]
181 print [[module:reload(module, host) - The same, but unloads and loads the module (saving state if the module supports it)]]
182 print [[module:unload(module, host) - The same, but just unloads the module from memory]]
183 elseif section == "server" then
184 print [[server:version() - Show the server's version number]]
185 print [[server:uptime() - Show how long the server has been running]]
186 --print [[server:shutdown(reason) - Shut down the server, with an optional reason to be broadcast to all connections]]
187 elseif section == "console" then
188 print [[Hey! Welcome to Prosody's admin console.]]
189 print [[First thing, if you're ever wondering how to get out, simply type 'quit'.]]
190 print [[Secondly, note that we don't support the full telnet protocol yet (it's coming)]]
191 print [[so you may have trouble using the arrow keys, etc. depending on your system.]]
192 print [[]]
193 print [[For now we offer a couple of handy shortcuts:]]
194 print [[!! - Repeat the last command]]
195 print [[!old!new! - repeat the last command, but with 'old' replaced by 'new']]
196 print [[]]
197 print [[For those well-versed in Prosody's internals, or taking instruction from those who are,]]
198 print [[you can prefix a command with > to escape the console sandbox, and access everything in]]
199 print [[the running server. Great fun, but be careful not to break anything :)]]
200 end
201 print [[]]
157 end 202 end
158 203
159 -- Session environment -- 204 -- Session environment --
160 -- Anything in def_env will be accessible within the session as a global variable 205 -- Anything in def_env will be accessible within the session as a global variable
161 206

mercurial