2017-09-01 09:07:07 +10:00
|
|
|
tA = {...}
|
2017-09-10 03:14:46 +10:00
|
|
|
local h,p = tA[1], tonumber(tA[2]) or 23
|
2017-09-01 09:07:07 +10:00
|
|
|
local function nshcw(h,p)
|
|
|
|
while true do
|
|
|
|
local sI = os.getenv("sI")
|
|
|
|
local ev = {event.pull()}
|
2017-09-05 19:09:07 +10:00
|
|
|
if ev[1] == "net_msg" and ev[2] == h and ev[3] == p and ev[4]:sub(1,1) == "d" then
|
|
|
|
write(ev[4]:sub(2))
|
|
|
|
elseif ev[1] == "net_msg" and ev[2] == h and ev[3] == p and ev[4]:sub(1,1) == "\27" then
|
|
|
|
break
|
2017-09-01 09:07:07 +10:00
|
|
|
elseif ev[1] == "key" and ev[2] == sI then
|
|
|
|
net.send(h,p,string.char(ev[3],ev[4]))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-09-10 03:14:46 +10:00
|
|
|
net.send(h,p,"initnsh2")
|
2017-09-10 15:23:46 +10:00
|
|
|
local bt = computer.uptime()
|
2017-09-01 09:07:07 +10:00
|
|
|
local tp,src,port,msg
|
|
|
|
repeat
|
|
|
|
tp, src, port, msg = event.pull()
|
2017-09-10 15:23:46 +10:00
|
|
|
until (tp == "net_msg" and src == h and port == p) or computer.uptime() > bt+16
|
2017-09-01 09:07:07 +10:00
|
|
|
if tp == "net_msg" then
|
|
|
|
nshcw(h,tonumber(msg))
|
|
|
|
else
|
|
|
|
print("timeout.")
|
|
|
|
end
|