1
0
mirror of https://github.com/ShadowKatStudios/OC-Minitel.git synced 2024-11-23 10:38:05 +11:00

implemented the rev1 FRequest protocol in the bundled programs

This commit is contained in:
Izaya 2018-02-19 22:49:23 +11:00
parent 884c868d9b
commit 3d45735361
2 changed files with 42 additions and 15 deletions

View File

@ -20,12 +20,22 @@ function start()
buffer=s:read(1024)
local nl = buffer:find("\n")
if nl then
local path=prefix .. "/" .. buffer:sub(1,nl-1)
local rt = buffer:sub(1,1)
local path=prefix .. "/" .. buffer:sub(2,nl-1)
dprint(path)
if path:find("%.%./") then
s:write("f to pay respects")
s:close()
return
end
if fs.exists(path) then
if rt == "t" then
if fs.isDirectory(path) then
s:write("d")
if fs.exists(path.."/index") then
local f=io.open(path.."/index","rb")
s:write(f:read("*a"))
f:close()
end
local dbuffer = ""
for f in fs.list(path) do
@ -35,14 +45,19 @@ function start()
s:write(dbuffer)
s:close()
else
s:write("y")
local f = io.open(path,"rb")
s:write(f:read("*a"))
f:close()
s:close()
end
else
s:write(tostring(fs.size(path)))
s:close()
end
else
dprint("404")
s:write("file not found")
s:write("not found")
s:close()
end
end

View File

@ -12,7 +12,19 @@ if sep then
end
local socket = net.open(host,port)
socket:write(path.."\n")
socket:write("t"..path.."\n")
local c = socket:read(1)
repeat
c = socket:read(1)
os.sleep(0.5)
until c ~= ""
if c == "n" then
print(path..": Not found.")
elseif c == "f" then
print("Failure: ")
elseif c == "d" then
print("Directory listing for "..path)
end
repeat
l = socket:read(1024)
io.write(l)