Advertisement
TheRockettek

Untitled

Jun 1st, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. print("Finding all domains...")
  2.  
  3. rednet.open("back")
  4. timeout = 0.2
  5. getSearchResults = function()
  6. dnsDatabase = {[1] = {}, [2] = {}}
  7. resultIDs = {}
  8. conflict = {}
  9.  
  10. rednet.broadcast("firewolf.broadcast.dns.list")
  11. local startClock = os.clock()
  12. while os.clock() - startClock < timeout do
  13. local id, i = rednet.receive(timeout)
  14. if id then
  15. if i:sub(1, 14) == "firewolf-site:" then
  16. i = i:sub(15, -1)
  17. if not i:find(" ") and i:len() < 40 then
  18. if not resultIDs[tostring(id)] then
  19. resultIDs[tostring(id)] = 1
  20. else
  21. resultIDs[tostring(id)] = resultIDs[tostring(id)] + 1
  22. end
  23. if not i:find("rdnt://") then
  24. i = ("rdnt://" .. i)
  25. end
  26. local x = false
  27. if conflict[i] then
  28. x = true
  29. table.insert(conflict[i], id)
  30. else
  31. for m, n in pairs(dnsDatabase[1]) do
  32. if n:lower() == i:lower() then
  33. x = true
  34. table.remove(dnsDatabase[1], m)
  35. table.remove(dnsDatabase[2], m)
  36. if conflict[i] then
  37. table.insert(conflict[i], id)
  38. else
  39. conflict[i] = {}
  40. table.insert(conflict[i], id)
  41. end
  42. end
  43. end
  44. end
  45. if not x and resultIDs[tostring(id)] <= 3 then
  46. table.insert(dnsDatabase[1], i)
  47. table.insert(dnsDatabase[2], id)
  48. end
  49. end
  50. end
  51. else
  52. break
  53. end
  54. end
  55. getSearchResults()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement