diff --git a/configs/everything-debug.cfg b/configs/everything-debug.cfg index 28426c8..25ca671 100644 --- a/configs/everything-debug.cfg +++ b/configs/everything-debug.cfg @@ -6,6 +6,8 @@ library/print.lua library/fs-min.lua library/fs-std.lua library/fs-util.lua +library/buffer.lua +library/io.lua util/fs-automount.lua drivers/tty.lua drivers/kbd.lua @@ -17,10 +19,11 @@ library/base64.lua library/chauth.lua library/fs-ext.lua library/readline.lua -applications/nshd.lua -applications/nshc.lua -applications/nshd-auth.lua -applications/nshc-auth.lua +net/nshd.lua +net/nshc.lua +net/nshd-auth.lua +net/nshc-auth.lua +applications/inshc.lua applications/shutil.lua applications/skex2.lua applications/luash.lua diff --git a/configs/everything-noinit.cfg b/configs/everything-noinit.cfg index 5c00589..97ccab4 100644 --- a/configs/everything-noinit.cfg +++ b/configs/everything-noinit.cfg @@ -15,10 +15,10 @@ library/base64.lua library/chauth.lua library/fs-ext.lua library/readline.lua -applications/nshd.lua -applications/nshc.lua -applications/nshd-auth.lua -applications/nshc-auth.lua +net/nshd.lua +net/nshc.lua +net/nshd-auth.lua +net/nshc-auth.lua applications/shutil.lua applications/skex2.lua applications/luash.lua diff --git a/configs/everything.cfg b/configs/everything.cfg index b89a40c..47d95e2 100644 --- a/configs/everything.cfg +++ b/configs/everything.cfg @@ -13,8 +13,8 @@ net/ping.lua library/base64.lua library/fs-ext.lua library/readline.lua -applications/nshd.lua -applications/nshc.lua +net/nshd.lua +net/nshc.lua applications/shutil.lua applications/skex2.lua applications/luash.lua diff --git a/configs/headless.cfg b/configs/headless.cfg index 4848e64..4a5d740 100644 --- a/configs/headless.cfg +++ b/configs/headless.cfg @@ -2,7 +2,7 @@ base/header.lua library/print.lua library/net.lua library/readline.lua -applications/nshd.lua +net/nshd.lua applications/luash.lua applications/shutil.lua library/fs-min.lua diff --git a/configs/network-terminal.cfg b/configs/network-terminal.cfg index 734d11b..6008c34 100644 --- a/configs/network-terminal.cfg +++ b/configs/network-terminal.cfg @@ -5,7 +5,7 @@ drivers/kbd.lua util/autogpu.lua library/net.lua library/readline.lua -applications/nshc.lua +net/nshc.lua applications/luash.lua applications/autoluash.lua util/loadeeprom.lua diff --git a/configs/virt.lua b/configs/virt.lua new file mode 100644 index 0000000..6182861 --- /dev/null +++ b/configs/virt.lua @@ -0,0 +1,3 @@ +base/header.lua +base/virt.lua +base/footer.lua diff --git a/modules/net/nshc-auth.lua b/modules/net/nshc-auth.lua new file mode 100644 index 0000000..f44f545 --- /dev/null +++ b/modules/net/nshc-auth.lua @@ -0,0 +1,33 @@ +function nshcs_w(evPP,nid,pW) + local sI = E().sI or 1 + chauthc(nid,evPP,pW) + while true do + if ev[1] == "net_msg" then + local V,msg=false,tostring(ev[4]) + if ev[3] == evPP and ev[2] == nid then + if msg:sub(1,3) == "dis" then + write(msg:sub(4)) + end + end + elseif ev[1] == "key" and ev[2] == sI and ev[3] == 29 and ev[4] == 27 then + break + elseif ev[1] == "key" and ev[2] == sI then + ns(nid,evPP,"key"..tostring(ev[3])) + end + C.yield() + end + ns(nid,evPP,"exit") +end + +function nshcs(P,nid,pW) + ns(nid,P,"initnsh") + while true do + if ev[1] == "net_msg" and ev[2] == nid and ev[3] == P then + break + elseif ev[1] == "key" and ev[2] == sI and ev[3] == 29 and ev[4] == 27 then + break + end + C.yield() + end + nshcs_w(ev[4],nid,pW) +end diff --git a/modules/net/nshc.lua b/modules/net/nshc.lua new file mode 100644 index 0000000..95ac96b --- /dev/null +++ b/modules/net/nshc.lua @@ -0,0 +1,32 @@ +function nshc_w(evPP,nid) + local sI = E().sI or 1 + while true do + if ev[1] == "net_msg" then + local V,msg=false,tostring(ev[4]) + if ev[3] == evPP and ev[2] == nid then + if msg:sub(1,3) == "dis" then + write(msg:sub(4)) + end + end + elseif ev[1] == "key" and ev[2] == sI and ev[3] == 29 and ev[4] == 27 then + break + elseif ev[1] == "key" and ev[2] == sI then + ns(nid,evPP,"key"..tostring(ev[3])) + end + C.yield() + end + ns(nid,evPP,"exit") +end + +function nshc(P,nid) + ns(nid,P,"initnsh") + while true do + if ev[1] == "net_msg" and ev[2] == nid and ev[3] == P then + break + elseif ev[1] == "key" and ev[2] == sI and ev[3] == 29 and ev[4] == 27 then + break + end + C.yield() + end + nshc_w(ev[4],nid) +end diff --git a/modules/net/nshd-auth.lua b/modules/net/nshd-auth.lua new file mode 100644 index 0000000..ce52385 --- /dev/null +++ b/modules/net/nshd-auth.lua @@ -0,0 +1,38 @@ +function nshds_w(evPP,cA,sI,pW) +s("nshds - "..tostring(sI),function() + chauths(cA,evPP,pW) + luash({["sI"]=sI}) + while true do + if ev[1] == "net_msg" then + local msg=tostring(ev[4]) + if ev[3] == evPP and ev[2] == cA then + if msg:sub(1,3) == "key" then + h("key",tT[cT][3].sI,tonumber(msg:sub(4)),0) + elseif msg == "exit" then pcall(killsession,sI) break + end + end + elseif ev[1] == "display" and ev[3] == tT[cT][3].sI then + ns(cA,evPP,"dis"..tostring(ev[2])) + end + C.yield() + end +end,{["sI"]=sI}) +end + +function nshds(P,pW) + s("nshds",function() + local Cc=1 + while true do + if ev[1] == "net_msg" and ev[3] == P then + if ev[4] == "initnsh" then + nnID="nsh-"..tostring(Cc) + Cc=Cc+1 + ns(ev[2],P,nnID) + nshds_w(nnID,ev[2],nnID,pW) + print("[nshds]Spawned "..nnID.." for "..tostring(ev[2])) + end + end + C.yield() + end + end,{["sI"]="log"}) +end diff --git a/modules/net/nshd.lua b/modules/net/nshd.lua new file mode 100644 index 0000000..0206c85 --- /dev/null +++ b/modules/net/nshd.lua @@ -0,0 +1,37 @@ +function nshd_w(evPP,cA,sI) +s("nshd - "..tostring(sI),function() + luash({["sI"]=sI}) + while true do + if ev[1] == "net_msg" then + local msg=tostring(ev[4]) + if ev[3] == evPP and ev[2] == cA then + if msg:sub(1,3) == "key" then + h("key",tT[cT][3].sI,tonumber(msg:sub(4)),0) + elseif msg == "exit" then pcall(killsession,sI) break + end + end + elseif ev[1] == "display" and ev[3] == tT[cT][3].sI then + ns(cA,evPP,"dis"..tostring(ev[2])) + end + C.yield() + end +end,{["sI"]=sI}) +end + +function nshd(P) + s("nshd",function() + local Cc=1 + while true do + if ev[1] == "net_msg" and ev[3] == P then + if ev[4] == "initnsh" then + nnID="nsh-"..tostring(Cc) + Cc=Cc+1 + ns(ev[2],P,nnID) + nshd_w(nnID,ev[2],nnID) + print("[nshd]Spawned "..nnID.." for "..tostring(ev[2])) + end + end + C.yield() + end + end,{["sI"]="log"}) +end