Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protocols.rdnt = {}
- protocols.http = {}
- protocols.rdnt.getSearchResults = function()
- dnsDatabase = {[1] = {}, [2] = {}}
- local resultIDs = {}
- local conflict = {}
- rednet.broadcast("firewolf.broadcast.dns.list")
- local startClock = os.clock()
- while os.clock() - startClock < timeout do
- local id, i = rednet.receive(timeout)
- if id then
- if i:sub(1, 14) == "firewolf-site:" then
- i = i:sub(15, -1)
- local bl, wl = verifyBlacklist(id), verifyWhitelist(id, i)
- if not i:find(" ") and i:len() < 40 and (not bl or (bl and wl)) then
- if not resultIDs[tostring(id)] then resultIDs[tostring(id)] = 1
- else resultIDs[tostring(id)] = resultIDs[tostring(id)] + 1 end
- if not i:find("rdnt://") then i = ("rdnt://" .. i) end
- local x = false
- if conflict[i] then
- x = true
- table.insert(conflict[i], id)
- else
- for m, n in pairs(dnsDatabase[1]) do
- if n:lower() == i:lower() then
- x = true
- table.remove(dnsDatabase[1], m)
- table.remove(dnsDatabase[2], m)
- if conflict[i] then table.insert(conflict[i], id)
- else conflict[i] = {} table.insert(conflict[i], id) end
- break
- end
- end
- end
- if not x and resultIDs[tostring(id)] <= 3 then
- table.insert(dnsDatabase[1], i)
- table.insert(dnsDatabase[2], id)
- end
- end
- end
- else break end
- end
- for k, v in pairs(conflict) do
- table.sort(v)
- table.insert(dnsDatabase[1], k)
- table.insert(dnsDatabase[2], v[1])
- end
- end
- protocols.rdnt.getWebsite = function(site)
- local id, content, status = nil, nil, nil
- local clock = os.clock()
- local websiteID = nil
- for k, v in pairs(dnsDatabase[1]) do
- local web = site:gsub("rdnt://", "")
- if web:find("/") then web = web:sub(1, web:find("/") - 1) end
- if web == v:gsub("rdnt://", "") then websiteID = dnsDatabase[2][k] break end
- end
- if not websiteID then return nil, nil, nil end
- sleep(timeout)
- rednet.send(websiteID, site)
- clock = os.clock()
- while os.clock() - clock < timeout do
- id, content = rednet.receive(timeout)
- if id and id == websiteID then
- local bl, wl = verifyBlacklist(id), verifyWhitelist(id, site)
- status = nil
- if (bl and not wl) or site == "" or site == "." or site == ".." then
- -- Ignore
- elseif wl then status = "whitelist" break
- else status = "safe" break end
- end
- end
- return id, content, status
- end
- protocols.http.getSearchResults = function()
- dnsDatabase = {[1] = {}, [2] = {}}
- end
- protocols.http.getWebsite = function(site)
- return nil, nil, nil
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement