summaryrefslogtreecommitdiff
path: root/src/debug_shell.lua
diff options
context:
space:
mode:
Diffstat (limited to 'src/debug_shell.lua')
-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