Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local version = 1.0
- local filename = "server"
- local paste = "aHyjJDrb"
- local function update()
- local url = "http://pastebin.com/raw.php?i="..paste
- local temp = http.get(url)
- local ver = temp.readLine()
- if tonumber(string.sub(ver, 17)) ~= version then
- fs.delete(filename)
- shell.run("pastebin get "..paste.." "..filename)
- shell.run(filename)
- return true
- end
- return false
- end
- local test = update()
- if test == true then
- error()
- end
- rednet.open("top")
- local cName = "bluemond" --put the cloud's name here (also used to connect)
- cName = cName:lower()
- local takePass = true
- local pass = "1234" --put the password here
- local request = "$CONNECT$?:"..cName
- local file = "Cloud_Dir" --put the cloud directory here
- shell.run("clear")
- print("Hosting Server: "..cName)
- local function sendFiles(pl)
- local files = fs.list(file)
- local out = "$FILES$"
- if #files == 0 then
- rednet.send(pl,"$FILES$:$NONE$")
- else
- for x=1,#files do
- out = out..":"..files[x]
- end
- rednet.send(pl,out)
- end
- end
- local function start()
- while true do
- id,msg = rednet.receive()
- --connection handshake
- if msg == request then
- if takePass then
- rednet.send(id,"$CONNECT$Y:"..cName)
- else
- rednet.send(id,"$CONNECT$N:"..cName)
- end
- end
- --password check
- if string.sub(msg,1,11) == "$PASSCHECK$" then
- if string.sub(msg,13,#msg) == pass then
- rednet.send(id,"$PASSCHECK$:TRUE")
- else
- rednet.send(id,"$PASSCHECK$:FALSE")
- end
- end
- --file request
- if string.sub(msg,1,7) == "$FILES$" then
- if string.sub(msg,9,#msg) == pass then
- sendFiles(id)
- elseif takePass == false then
- sendFiles(id)
- end
- end
- end
- end
- if not fs.exists(file) then
- fs.makeDir(file)
- shell.run("clear")
- print("~Cloud Directory Created~")
- print("Please re-run the server.")
- else
- start()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement