<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>You might find <a class="moz-txt-link-freetext" href="https://github.com/thommay/blocklister">https://github.com/thommay/blocklister</a> useful.
This script takes lists of domains - in the common adblock format
- and compiles them into a lua file, performing sorting and
deduplication as it goes.<br>
</p>
<p><br>
</p>
<div class="moz-cite-prefix">On 05/03/2023 10:28, Clifford Dsouza
via Pdns-users wrote:<br>
</div>
<blockquote type="cite"
cite="mid:BM1PR01MB39376BEB067837280C19DF9D8BB19@BM1PR01MB3937.INDPRD01.PROD.OUTLOOK.COM">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css" style="display:none;">P {margin-top:0;margin-bottom:0;}</style>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255,
255, 255);" class="elementToProof">
Hi</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255,
255, 255);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255,
255, 255);" class="elementToProof">
I've configured Powerdns to block certain domain using lua..</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255,
255, 255);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255,
255, 255);" class="elementToProof">
The lua file the recursor.conf refers to has the below code</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255,
255, 255);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255,
255, 255);" class="elementToProof ContentPasted0">
-----------------------------------------------------</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255,
255, 255);" class="elementToProof ContentPasted0">
blocked_domains=newDS()
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0"> blocked_domains:add(dofile("/etc/pdns-recursor/blocklist.lua"))</div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0">function preresolve(dq)</div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0"> if(not
blocked_domains:check(dq.qname) or (dq.qtype ~= pdns.A and
dq.qtype ~= pdns.AAAA)) then</div>
<div class="ContentPasted0"> return false</div>
<div class="ContentPasted0"> else</div>
<div><br class="ContentPasted0">
</div>
<div> dq:addAnswer(pdns.A, "182.X.X.X", 60, "blockpage.co.in")<br>
</div>
<div class="ContentPasted0">return true</div>
<div class="ContentPasted0">end</div>
<div class="ContentPasted0"> end</div>
-----------------------------------------------------</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255,
255, 255);" class="elementToProof">
the code references the block list file that has the below
format</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255,
255, 255);" class="elementToProof">
-----------------------------------------------------</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255,
255, 255);" class="elementToProof ContentPasted1">
return {
<div class="ContentPasted1">"site1.tobeblocked.com",</div>
<div class="ContentPasted1">"<span
style="background-color:rgb(255, 255, 255);display:inline
!important">site2.tobeblocked.com</span>",</div>
<div class="ContentPasted1">"<span
style="background-color:rgb(255, 255, 255);display:inline
!important">site3.tobeblocked.com</span>",</div>
<div>}</div>
<div>--------------------------------------------------<br>
</div>
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255,
255, 255);" class="elementToProof ContentPasted1">
<span style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0); background-color:
rgb(255, 255, 255);">Is there a way I can </span><span
style="color: rgb(0, 0, 0); font-family: Calibri, Arial,
Helvetica, sans-serif; background-color: rgb(255, 255, 255);
font-size: 12pt; display: inline !important;"
class="ContentPasted2">populate the blocklist file it with the
list of domains that I want to block, one domain per line,
instead of the other extra characters that i need to type, I
just want to avoid syntax errors when updating the file.</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255,
255, 255);" class="elementToProof ContentPasted1">
<span style="color: rgb(0, 0, 0); font-family: Calibri, Arial,
Helvetica, sans-serif; background-color: rgb(255, 255, 255);
font-size: 12pt; display: inline !important;"
class="ContentPasted2"><br>
</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255,
255, 255);" class="elementToProof ContentPasted1">
<span style="color: rgb(0, 0, 0); font-family: Calibri, Arial,
Helvetica, sans-serif; background-color: rgb(255, 255, 255);
font-size: 12pt; display: inline !important;"
class="ContentPasted2"><br>
</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255,
255, 255);" class="elementToProof ContentPasted1">
<span style="color: rgb(0, 0, 0); font-family: Calibri, Arial,
Helvetica, sans-serif; background-color: rgb(255, 255, 255);
font-size: 12pt; display: inline !important;"
class="ContentPasted2">Thanks </span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255,
255, 255);" class="elementToProof ContentPasted1">
<span style="color: rgb(0, 0, 0); font-family: Calibri, Arial,
Helvetica, sans-serif; background-color: rgb(255, 255, 255);
font-size: 12pt; display: inline !important;"
class="ContentPasted2"><br>
</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255,
255, 255);" class="elementToProof ContentPasted1">
<span style="color: rgb(0, 0, 0); font-family: Calibri, Arial,
Helvetica, sans-serif; background-color: rgb(255, 255, 255);
font-size: 12pt; display: inline !important;"
class="ContentPasted2">Clifford</span></div>
<br>
NOTICE: This message contains privileged and confidential
information intended only for the use of the addressee named
above. If you are not the intended recipient of this message you
are hereby notified that you must not disseminate, copy or take
any action in reliance on it. If you have received this message in
error please notify Microscan Infocommtech Pvt. Ltd. immediately.
Any views expressed in this message are those of the individual
sender, except where the sender has the authority to issue and
specifically states them. Tel - 022-66870600 Fax - 022-66870800
<br>
<fieldset class="moz-mime-attachment-header"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
Pdns-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Pdns-users@mailman.powerdns.com">Pdns-users@mailman.powerdns.com</a>
<a class="moz-txt-link-freetext" href="https://mailman.powerdns.com/mailman/listinfo/pdns-users">https://mailman.powerdns.com/mailman/listinfo/pdns-users</a>
</pre>
</blockquote>
</body>
</html>