Guest User

webserver

a guest
Jun 11th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.21 KB | None | 0 0
  1. local side = 'back' --Define rednet side
  2. local file = fs.open("/blacklist", "r")
  3. local IDblack = file.readLine(1)--All blacklisted IDs
  4. local black = file.readLine(2) --All blacklisted messages
  5.  
  6.  
  7.  
  8.  
  9.  
  10. rednet.open(side) --Open rednet
  11.  
  12.  
  13.  
  14. id, msg = rednet.receive() --Receive the message
  15.  
  16.  
  17. local detected = false  --Define a new variable called detected
  18.  
  19. print("ID = " .. id)
  20. print("msg = " .. msg)
  21.  
  22.  
  23. for i=1,#IDblack do --Do the following block of code Length of IDblack times. i stores the current run.
  24.     print("IDBLACK" .. IDblack[i])  
  25.     if id == IDblack[i] then --If the current run found that IDblack contains an ID then do the following block of code
  26.         for j=1,#black do   --Do the following block of code amount of entries in black times.
  27.             print("black" .. black[j])
  28.             if msg == black[j] then --If current run found that black contains the sent message then
  29.                 detected = true --Set detected to true
  30.                 print("Detected")
  31.                 break --And exit the loop
  32.             end
  33.         end
  34.     end
  35.     if detected == true then
  36.         break
  37.     end
  38. end
  39.  
  40. if detected == true then --Do the alerting only if detected was set to true.
  41. print('Blocked ID: '..id..' Detected... Denying Access')
  42. rednet.send(id, 'You Are Blacklisted!')
  43. end
Advertisement
Add Comment
Please, Sign In to add comment