Commit 79e5c481 authored by Phil Hagelberg's avatar Phil Hagelberg

Fix logout.

parent 6188e812
......@@ -49,7 +49,7 @@ bind("ssh", "ctrl-d", function()
ship:activate_mode("console")
ship.editor.set_prompt("> ")
local send = editor.get_prop("ssh_send")
send(nil) -- sending "EOF" is how you log out
send("logout")
print("Logged out.")
else
editor.delete_forwards()
......
......@@ -34,8 +34,6 @@ local function send(channel, session, get_distance, range, data)
else
table.insert(queue, 1, data)
end
elseif(data == nil) then
channel:push({op="kill", session=session})
elseif(type(data) == "string") then
send(channel, session, get_distance, range,
{op="stdin", stdin=data, session=session})
......@@ -54,7 +52,7 @@ local function recv(ship, port, channel, blocking)
elseif(msg.op == "rpc") then
local resp = {rpcs[msg.fn](ship, port, unpack(msg.args or {}))}
dbg(">", require("serpent").block(resp))
msg.chan:push(resp)
if(msg.chan) then msg.chan:push(resp) end
end
return msg
elseif(blocking) then
......
......@@ -13,5 +13,8 @@ return {
local ok, err = pcall(fs.init_if_needed, hostname)
if(not ok) then print("auth err", err) return false end
return shell.auth(username, password)
end
end,
-- This will only kill threads that are smash sessions; ugh.
kill = function(session) session.stdin:push("logout") end,
}
......@@ -23,7 +23,11 @@ while true do
local msg = input:demand()
-- TODO: range check
dbg(">", require("lume").serialize(msg))
if(msg.op == "kill") then return
if(msg.op == "kill") then
for _,session in pairs(sessions) do
if(os.kill) then os.kill(session) end
end
return
elseif(msg.op == "login") then
local handle = function() print(debug.traceback()) end
if(not xpcall(new_session, handle, msg.username, msg.password)) then
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment