Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- DNS - Domain Name Server | Programmed by Yosi Yuval.
- -- This Is a test program! (-:
- --
- --
- -- |---------------------------------|
- -- | 33333333 33 3 333333333 |
- -- | 3 3 3 3 3 3 |
- -- | 3 3 3 3 3 3 |
- -- | 3 3 3 3 3 333333333 |
- -- | 3 3 3 3 3 3 |
- -- | 33333333 3 33 333333333 |
- -- |---------------------------------|
- local fFile = ""
- local fFileData = ""
- local statelist = {
- ["top"] = rs.getInput("top"),
- ["front"] = rs.getInput("front"),
- ["left"] = rs.getInput("left"),
- ["right"] = rs.getInput("right"),
- ["back"] = rs.getInput("back"),
- ["bottom"] = rs.getInput("bottom"),
- }
- local domain_wrong_symbols = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "!", "@", "#", "$", "*", "(", ")", "-", "=", "/", "?", ".", "|", "", ":", ";", "~", "`", "<", ">", "{", "}", "[", "]"}
- local domain_extensions = {".com", ".co.il", ".org", ".cc", ".il"}
- function HostServer(domain, host_name)
- if domain == nil or host_name == nil then print("missing parameters") end
- for v,side in pairs(statelist) do rednet.open("back") end
- rednet.host("80", domain)
- os.setComputerLabel(host_name.." | "..domain)
- print("Server Name: "..host_name.." | Domain: "..domain.." |")
- end
- function isServerExist(domain)
- local ServerHost = rednet.lookup("80", domain)
- if ServerHost then return true
- else return false end
- end
- function connectToServer(domain)
- local ServerHost = rednet.lookup("80", domain)
- return ServerHost
- end
- function getDomainServerID(domain)
- return rednet.lookup("80", domain)
- end
- function sendFileFromServer(pid, domain, file_to_send)
- local fileToSend = fs.open(file_to_send, "r")
- --fFileData = fileToGet.readAll()
- FData = fileToSend.readAll()
- fileToSend.close()
- rednet.send(pid, sfileData)
- end
- function getFileFromServer(domain, file_to_get)
- sendFileFromServer(os.getComputerID(), getDomainServerID(domain), file_to_get)
- local id, msg, dis = rednet.receive()
- if id == getDomainServerID(domain) then
- local fileData = msg
- local fileToGet = fs.open(file_to_get, "w")
- fileToGet.writr(fileData)
- fileToGet.close()
- end
- end
- function sendFilesListFromServer(pid)
- local fList = fs.list("")
- rednet.send(pid, fList)
- end
- function getFilesListFromServer(domain_pc)
- local id, msg, dis = rednet.receive()
- if id == getDomainServerID(domain) then
- print("File List from Domain"..d.."("..getDomainServerID(d)..")\n"..msg)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement