Advertisement
Guest User

Untitled

a guest
Jan 18th, 2020
86
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 = "top" -- change to the side of the computer your modem is on
  9. local valid = false
  10. users = {"root", "username2" } --make sure users and passwords line up
  11. passwords = {"root", "password2" }
  12. senders = { 51, 52, 53, 54 } -- 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. valid = true
  33. password = passwords[i]
  34. break
  35. else
  36. valid = false
  37. end
  38. end
  39. if valid then
  40. rednet.send(senderId, password, true)
  41. else
  42. rednet.send(senderId, "Not Valid", true)
  43. end
  44. end
  45. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement