mirror of
https://github.com/kepler155c/opus
synced 2025-10-19 09:47:39 +00:00
socket improvement
This commit is contained in:
@@ -101,7 +101,7 @@ process:newThread('discovery_server', function()
|
||||
while true do
|
||||
local e, s, sport, id, info, distance = os.pullEvent('modem_message')
|
||||
|
||||
if sport == 999 then
|
||||
if sport == 999 and tonumber(id) and type(info) == 'table' then
|
||||
if not network[id] then
|
||||
network[id] = { }
|
||||
end
|
||||
|
@@ -40,7 +40,7 @@ local function telnetHost(socket, termInfo)
|
||||
socket:close()
|
||||
end)
|
||||
|
||||
local queueThread = process:newThread('telnet_read', function()
|
||||
process:newThread('telnet_read', function()
|
||||
while true do
|
||||
local data = socket:read()
|
||||
if not data then
|
||||
@@ -49,7 +49,6 @@ local function telnetHost(socket, termInfo)
|
||||
|
||||
if data.type == 'shellRemote' then
|
||||
local event = table.remove(data.event, 1)
|
||||
|
||||
shellThread:resume(event, unpack(data.event))
|
||||
end
|
||||
end
|
||||
@@ -65,7 +64,10 @@ local function telnetHost(socket, termInfo)
|
||||
break
|
||||
end
|
||||
if socket.queue then
|
||||
socket:write(socket.queue)
|
||||
if not socket:write(socket.queue) then
|
||||
print('telnet: connection lost to ' .. socket.dhost)
|
||||
break
|
||||
end
|
||||
socket.queue = nil
|
||||
end
|
||||
end
|
||||
|
@@ -17,9 +17,9 @@ process:newThread('trust_server', function()
|
||||
socket:write('No password has been set')
|
||||
else
|
||||
data = Crypto.decrypt(data, password)
|
||||
if data and data.pk then
|
||||
if data and data.pk and data.dh then
|
||||
local trustList = Util.readTable('.known_hosts') or { }
|
||||
trustList[socket.dhost] = data.pk
|
||||
trustList[data.dh] = data.pk
|
||||
Util.writeTable('.known_hosts', trustList)
|
||||
|
||||
socket:write('Trust accepted')
|
||||
|
Reference in New Issue
Block a user