Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.pullEvent = os.pullEventRaw
- term.clear()
- term.setCursorPos(1,1)
- print("This is a password server. There is no user interaction here.")
- print("Please find a computer and login there.")
- local firstCycle = true
- local validSender = false
- local modemSide = "left" -- change to the side of the computer your modem is on
- local valid = false
- users = {"username1", "username2" } --make sure users and passwords line up
- passwords = {"password1", "password2" }
- senders = { 1, 2, 3, 4 } -- computer ID's of the computers you want to accept requests from
- function bootUp()
- rednet.open(modemSide)
- end
- while true do
- validSender = false
- if firstCycle then
- bootUp()
- firstCycle = false
- end
- senderId, message, distance = rednet.receive()
- for i,v in ipairs(senders) do
- if v == senderId then
- validSender = true
- break
- end
- end
- if validSender then
- for i,v in ipairs(users) do
- if message == v then
- valid = true
- password = passwords[i]
- break
- else
- valid = false
- end
- end
- if valid then
- rednet.send(senderId, password, true)
- else
- rednet.send(senderId, "Not Valid", true)
- end
- end
- end
Add Comment
Please, Sign In to add comment