summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anylike.org>2010-05-30 21:34:24 +0000
committerChristian Pointner <equinox@anylike.org>2010-05-30 21:34:24 +0000
commit02a38328dd8e3cf9e69052c269eabc5461cb3e6d (patch)
treed7a054002ad0780f281e29e8496af96367b79aa5
parentadded debug shell (not finished yet) (diff)
added quit and ping command to debug shell
-rw-r--r--src/debug_shell.lua18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/debug_shell.lua b/src/debug_shell.lua
index 2589552..c9bc98c 100644
--- a/src/debug_shell.lua
+++ b/src/debug_shell.lua
@@ -75,6 +75,7 @@ debug_shell.close = function()
end
debug_shell.handle = function(sock)
+ local ret = 0
if(sock == debug_shell.socks[1]) then
local newclient, err = debug_shell.socks[1]:accept()
if(newclient == nil) then
@@ -106,10 +107,25 @@ debug_shell.handle = function(sock)
end
else
debug_shell.buffer = debug_shell.buffer .. data
- log.printf(log.DEBUG, "debug shell: received string: '%s'", debug_shell.buffer)
+ ret = debug_shell.exec_cmd()
debug_shell.buffer = ""
end
end
+ return ret
+end
+
+debug_shell.exec_cmd = function()
+ log.printf(log.DEBUG, "debug shell: received string: '%s'", debug_shell.buffer)
+ local cmd, sep, param = string.match(debug_shell.buffer, "^(%w+)(.?)(.*)$");
+
+ if(cmd == 'quit') then
+ if(sep and sep ~= "") then return 0 end
+ log.printf(log.NOTICE, "debug shell: quit command received")
+ return 2
+ elseif(cmd == 'ping') then
+ if(sep == ' ') then debug_shell.socks[2]:send("pong " .. (param or "") .. "\n")
+ else debug_shell.socks[2]:send("pong\n") end
+ end
return 0
end