diff make-tld-conf.py @ 467:f5b394bec28c

allow checking names without A records on uribl lists; improve extraction of fake TLDs from our RPZ zone
author Carl Byington <carl@five-ten-sg.com>
date Wed, 16 Dec 2020 10:25:37 -0800
parents 78eedbbce636
children
line wrap: on
line diff
--- a/make-tld-conf.py	Thu Apr 25 09:47:36 2019 -0700
+++ b/make-tld-conf.py	Wed Dec 16 10:25:37 2020 -0800
@@ -1,9 +1,9 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 
 import os, sys, time
 
 def cmd(c):
-    print c
+    print(c)
     return os.popen(c).read().rstrip('\n')
 
 url = 'https://publicsuffix.org/list/effective_tld_names.dat'
@@ -21,8 +21,7 @@
             prefix = ''
         yy = []
         for xx in x.split('.'):
-            y = unicode(xx, 'utf8')
-            z = y.encode('punycode')
+            z = xx.encode('punycode').decode('utf8')
             if z[-1:] == '-': yy.append(xx)
             else:             yy.append('xn--%s' % z)
         y = '.'.join(yy)
@@ -36,8 +35,18 @@
                 if not rc: prefix = '// no ns record for '
         f.write('%s%s\n' % (prefix, x))
 f.write('\n')
+f.write('\n')
+f.write('// add some TLDs from our rpz zone so names under them\n')
+f.write('// can be added to uribl style lists\n')
+f.write('\n')
 
-c="grep '^\*.*multi.surbl' /etc/cron.daily/rpz | awk '{print $1}' | cut -c3- | sed -e 's/.multi.surbl.org//g'"
+c="grep '^\*.*multi.surbl' /etc/cron.daily/rpz | awk '{print $1}' | cut -c3- | sed -e 's/.multi.surbl.org//g' | grep '\.'"
+content = cmd(c)
+for x in content.split('\n'):
+    f.write(x + '\n')
+
+f.write('\n')
+c="grep '^[^\*].*multi.surbl' /etc/cron.daily/rpz | egrep -v 'CNAME|g.write' | awk '{print $1}' | sed -e 's/.multi.surbl.org//g' | cut -d. -f2- | grep '\.'"
 content = cmd(c)
 for x in content.split('\n'):
     f.write(x + '\n')