34 lines
958 B
Lua
34 lines
958 B
Lua
|
local tA = {...}
|
||
|
local nport = tA[1] or "23"
|
||
|
function nshdw(h,p,s)
|
||
|
spawn("nshdw["..tostring(s).."]",function() print(pcall(function()
|
||
|
while true do
|
||
|
local sI = os.getenv("sI")
|
||
|
local ev = {event.pull()}
|
||
|
if ev[1] == "net_msg" and ev[2] == h and ev[3] == p then
|
||
|
event.push("key",sI,string.byte(ev[4]:sub(1,1)),string.byte(ev[4]:sub(2,2)))
|
||
|
elseif ev[1] == "display" and ev[2] == sI then
|
||
|
if ev[3]:len() < 1024 then
|
||
|
net.send(h,p,ev[3])
|
||
|
else
|
||
|
for i = 1, ev[3]:len(), 1024 do
|
||
|
net.send(h,p,ev[3]:sub(i,i+1023))
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end)) end,{sI=s})
|
||
|
end
|
||
|
spawn("nshd["..tostring(nport).."]",function() print(pcall(function()
|
||
|
while true do
|
||
|
local _, src, port, msg = event.pull("net_msg")
|
||
|
if port == nport and msg == "initnsh2" then
|
||
|
local cport = math.random(65535-1024,65535)
|
||
|
local ns = "nsh-"..tostring(cport)
|
||
|
net.send(src,port,tostring(cport))
|
||
|
luash(ns)
|
||
|
nshdw(src,cport,ns)
|
||
|
end
|
||
|
end
|
||
|
end)) end)
|