A bunch of programs for computercraft
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
572 B

conf = fs.open('/etc/ftpd.conf','r')
export_path = conf.readLine()
while 1 do
local senderId, message, distance = rednet.receive()
query=textutils.unserialize(message)
if query[1] == 'FTP' then
print('Got request for '..query[2]..' from '..senderId)
if fs.exists(export_path..query[2]) then
local reply_file = fs.open(export_path..query[2],'r')
reply_file=reply_file.readAll()
reply = textutils.serialize({'FTP',1,reply_file})
rednet.send(senderId,reply)
else
reply=textutils.serialize({'FTP',0})
rednet.send(senderId,reply)
end
end
end