z3ntu

Password Server

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