From 02a38328dd8e3cf9e69052c269eabc5461cb3e6d Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sun, 30 May 2010 21:34:24 +0000 Subject: added quit and ping command to debug shell --- src/debug_shell.lua | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3