diff --git a/configs/everything-noinit.cfg b/configs/everything-noinit.cfg index ba25f93..41fde5c 100644 --- a/configs/everything-noinit.cfg +++ b/configs/everything-noinit.cfg @@ -23,6 +23,8 @@ net/nshc.lua net/nshd-auth.lua net/nshc-auth.lua net/pxesrv.lua +net/fget.lua +net/fgetd.lua applications/shutil.lua applications/skex2.lua applications/luash-login.lua diff --git a/configs/headless-server.cfg b/configs/headless-server.cfg index f7cdcca..a60e74b 100644 --- a/configs/headless-server.cfg +++ b/configs/headless-server.cfg @@ -2,11 +2,12 @@ base/header.lua library/print.lua library/net.lua library/readline.lua -net/nshd.lua library/crc32.lua library/chauth.lua net/nshd.lua net/nshd-auth.lua +net/fgetd.lua +net/fget.lua applications/luash-login.lua applications/shutil.lua library/fs-min.lua diff --git a/modules/net/fget.lua b/modules/net/fget.lua new file mode 100644 index 0000000..2e2ba9b --- /dev/null +++ b/modules/net/fget.lua @@ -0,0 +1,15 @@ +function fget(addr,path,port) + local port,S = port or "fget","" + ns(addr,port,path) + while true do + if ev[1] == "net_msg" and ev[2] == addr and ev[3] == port then + if ev[4] == "." then + break + else + S=S..ev[4] + end + end + C.yield() + end + return S +end diff --git a/modules/net/fgetd.lua b/modules/net/fgetd.lua new file mode 100644 index 0000000..dbf409e --- /dev/null +++ b/modules/net/fgetd.lua @@ -0,0 +1,35 @@ +function fgetd_w(evPP,nid,pth) + local c,S = "",false + if pth:sub(-1) == "/" then + local ft=flist(pth) + if ft then + for k,v in ipairs(ft) do c=c..v.."\n" end S=true + else + c="failed to open dir" + end + else + local f=io.open(pth) + if f then + c=f:read("*a") + f:close() + S=true + else + c="failed to open file" + end + end + print(c) + for i = 1, c:len(), 2048 do + ns(nid,evPP,c:sub(i,i+2047)) + C.yield() + end + ns(nid,evPP,".") + return S +end +function fgetd(evPP,preP) + while true do + if ev[1] == "net_msg" and ev[3] == evPP then -- f,p,m + print("[fget] "..TS(ev[4])..": "..tostring(fgetd_w(ev[3],ev[2],preP.."/"..ev[4]))) + end + C.yield() + end +end