aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_admin_telnet.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2012-07-22 18:00:59 +0100
committerMatthew Wild <mwild1@gmail.com>2012-07-22 18:00:59 +0100
commitf07fe41db1238eaef4efe905f9b136c2d293609e (patch)
tree9fc2d4861256dd1ffc2385de52cc54df94e1fd0b /plugins/mod_admin_telnet.lua
parent8a965123f5c38071e14ee2f43fd203706ab56f95 (diff)
downloadprosody-f07fe41db1238eaef4efe905f9b136c2d293609e.tar.gz
prosody-f07fe41db1238eaef4efe905f9b136c2d293609e.zip
mod_admin_telnet: Replace anonymous function with loop (saves a closure)
Diffstat (limited to 'plugins/mod_admin_telnet.lua')
-rw-r--r--plugins/mod_admin_telnet.lua22
1 files changed, 11 insertions, 11 deletions
diff --git a/plugins/mod_admin_telnet.lua b/plugins/mod_admin_telnet.lua
index b56f9291..0b966f16 100644
--- a/plugins/mod_admin_telnet.lua
+++ b/plugins/mod_admin_telnet.lua
@@ -76,22 +76,22 @@ end
function console_listener.onincoming(conn, data)
local session = sessions[conn];
- -- Handle data
- (function(session, data)
+ -- Handle data (loop allows us to break to add \0 after response)
+ repeat
local useglobalenv;
-
+
if data:match("^>") then
data = data:gsub("^>", "");
useglobalenv = true;
elseif data == "\004" then
commands["bye"](session, data);
- return;
+ break;
else
local command = data:lower();
command = data:match("^%w+") or data:match("%p");
if commands[command] then
commands[command](session, data);
- return;
+ break;
end
end
@@ -106,7 +106,7 @@ function console_listener.onincoming(conn, data)
err = err:gsub("^:%d+: ", "");
err = err:gsub("'<eof>'", "the end of the line");
session.print("Sorry, I couldn't understand that... "..err);
- return;
+ break;
end
end
@@ -116,26 +116,26 @@ function console_listener.onincoming(conn, data)
if not (ranok or message or useglobalenv) and commands[data:lower()] then
commands[data:lower()](session, data);
- return;
+ break;
end
if not ranok then
session.print("Fatal error while running command, it did not complete");
session.print("Error: "..taskok);
- return;
+ break;
end
if not message then
session.print("Result: "..tostring(taskok));
- return;
+ break;
elseif (not taskok) and message then
session.print("Command completed with a problem");
session.print("Message: "..tostring(message));
- return;
+ break;
end
session.print("OK: "..tostring(message));
- end)(session, data);
+ until true
session.send(string.char(0));
end