Mercurial > dnsbl
diff make-tld-conf.py @ 270:f92f24950bd3 stable-6-0-35
Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Mon, 09 Sep 2013 15:15:53 -0700 |
parents | |
children | 19ff60eaab74 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/make-tld-conf.py Mon Sep 09 15:15:53 2013 -0700 @@ -0,0 +1,32 @@ +#!/usr/bin/python + +import os, sys + +def cmd(c): + return os.popen(c).read().rstrip('\n') + + +c = 'curl http://mxr.mozilla.org/mozilla-central/source/netwerk/dns/effective_tld_names.dat?raw=1 2>/dev/null' +content = cmd(c) +f=open('tld.conf','w') +for x in content.split('\n'): + if (x == '') or (x[:2] == '//'): f.write('%s\n' % x) + else: + if x[:1] == '!': + x = x[1:] + prefix = '!' + else: + prefix = '' + yy = [] + for xx in x.split('.'): + y = unicode(xx, 'utf8') + z = y.encode('punycode') + if z[-1:] == '-': yy.append(xx) + else: yy.append('xn--%s' % z) + y = '.'.join(yy) + if y == x: + f.write('%s%s\n' % (prefix, x)) + else: + f.write('// %s%s\n' % (prefix, x)) + f.write('%s%s\n' % (prefix, y)) +f.close()