Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. os.pullEvent = os.pullEventRaw
  2. term.clear()
  3. term.setCursorPos(1,1)
  4. print("This is a password server. There is no user interaction here.")
  5. print("Please find a computer and login there.")
  6. local firstCycle = true
  7. local validSender = false
  8. local modemSide = "left" -- change to the side of the computer your modem is on
  9. local valid = false
  10. users = {"username1", "username2" } --make sure users and passwords line up
  11. passwords = {"password1", "password2" }
  12. senders = { 1, 2, 3, 4 } -- computer ID's of the computers you want to accept requests from
  13. function bootUp()
  14. rednet.open(modemSide)
  15. end
  16. while true do
  17. validSender = false
  18. if firstCycle then
  19. bootUp()
  20. firstCycle = false
  21. end
  22. senderId, message, distance = rednet.receive()
  23. for i,v in ipairs(senders) do
  24. if v == senderId then
  25. validSender = true
  26. break
  27. end
  28. end
  29. if validSender then
  30. for i,v in ipairs(users) do
  31. if message == v then
  32. password = passwords[i]
  33. valid = true
  34. else
  35. valid = false
  36. end
  37. end
  38. if valid then
  39. rednet.send(senderId, password, true)
  40. else
  41. rednet.send(senderId, "Not Valid", true)
  42. end
  43. end
  44. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement