Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getTime()
- time = textutils.formatTime(os.time(), true)
- end
- function getReq()
- getTime()
- write(time)
- print(": Waiting for request")
- id,sessionKeyS = rednet.receive(doorCtrl) --session key sent
- getTime()
- write(time)
- print(": Received request from", id, "with key", sessionKeyS)
- checkCred()
- end
- function checkCred()
- exists = fs.exists("saves/sessionKeys/key1")
- if exists == true then
- file = fs.open("saves/sessionKeys/key1","r")
- sessionKeyR = file.readLine() -- session key read
- clearance = file.readLine()
- file.close()
- if sessionKeyS == sessionKeyR then
- rednet.send(id, "yes", doorCtrl)
- getTime()
- write(time)
- print(": Acess granted with key", sessionKeyR)
- rednet.send(id, "no", doorCtrl) else
- getTime()
- write(time)
- print(": Acess denied")
- end
- end
- end
- multishell.setTitle(multishell.getCurrent(), "DCtrl")
- getTime()
- write(time)
- print(": Booted up Door Control")
- file = fs.open("saves/protocols/doorCtrl", "r")
- doorCtrl = file.readLine()
- file.close()
- getTime()
- while true do
- getReq()
- end
Add Comment
Please, Sign In to add comment