annotate make-tld-conf.py @ 289:6497944a9bd9

update tld.conf, ignore domains with no ns records
author Carl Byington <carl@five-ten-sg.com>
date Fri, 21 Mar 2014 12:36:52 -0700
parents 19ff60eaab74
children 9f0d9fcb58dd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
270
f92f24950bd3 Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1 #!/usr/bin/python
f92f24950bd3 Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2
276
19ff60eaab74 more tld entries
Carl Byington <carl@five-ten-sg.com>
parents: 270
diff changeset
3 import os, sys, time
270
f92f24950bd3 Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
4
f92f24950bd3 Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
5 def cmd(c):
f92f24950bd3 Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
6 return os.popen(c).read().rstrip('\n')
f92f24950bd3 Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
7
f92f24950bd3 Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
8
f92f24950bd3 Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
9 c = 'curl http://mxr.mozilla.org/mozilla-central/source/netwerk/dns/effective_tld_names.dat?raw=1 2>/dev/null'
f92f24950bd3 Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
10 content = cmd(c)
f92f24950bd3 Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
11 f=open('tld.conf','w')
276
19ff60eaab74 more tld entries
Carl Byington <carl@five-ten-sg.com>
parents: 270
diff changeset
12 f.write(time.strftime("// generated by make-tld-conf.py on %Y-%m-%d %H:%M:%S\n\n"))
270
f92f24950bd3 Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
13 for x in content.split('\n'):
f92f24950bd3 Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
14 if (x == '') or (x[:2] == '//'): f.write('%s\n' % x)
f92f24950bd3 Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
15 else:
f92f24950bd3 Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
16 if x[:1] == '!':
f92f24950bd3 Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
17 x = x[1:]
f92f24950bd3 Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
18 prefix = '!'
f92f24950bd3 Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
19 else:
f92f24950bd3 Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
20 prefix = ''
f92f24950bd3 Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
21 yy = []
f92f24950bd3 Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
22 for xx in x.split('.'):
f92f24950bd3 Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
23 y = unicode(xx, 'utf8')
f92f24950bd3 Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
24 z = y.encode('punycode')
f92f24950bd3 Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
25 if z[-1:] == '-': yy.append(xx)
f92f24950bd3 Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
26 else: yy.append('xn--%s' % z)
f92f24950bd3 Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
27 y = '.'.join(yy)
289
6497944a9bd9 update tld.conf, ignore domains with no ns records
Carl Byington <carl@five-ten-sg.com>
parents: 276
diff changeset
28 if not (y == x):
270
f92f24950bd3 Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
29 f.write('// %s%s\n' % (prefix, x))
289
6497944a9bd9 update tld.conf, ignore domains with no ns records
Carl Byington <carl@five-ten-sg.com>
parents: 276
diff changeset
30 x = y
6497944a9bd9 update tld.conf, ignore domains with no ns records
Carl Byington <carl@five-ten-sg.com>
parents: 276
diff changeset
31 if not prefix and (len(x.split('.')) == 1):
6497944a9bd9 update tld.conf, ignore domains with no ns records
Carl Byington <carl@five-ten-sg.com>
parents: 276
diff changeset
32 rc = cmd("dig %s ns +short" % x)
6497944a9bd9 update tld.conf, ignore domains with no ns records
Carl Byington <carl@five-ten-sg.com>
parents: 276
diff changeset
33 if not rc:
6497944a9bd9 update tld.conf, ignore domains with no ns records
Carl Byington <carl@five-ten-sg.com>
parents: 276
diff changeset
34 rc = cmd("sleep 3; dig %s ns +short" % x)
6497944a9bd9 update tld.conf, ignore domains with no ns records
Carl Byington <carl@five-ten-sg.com>
parents: 276
diff changeset
35 if not rc: prefix = '// no ns record for '
6497944a9bd9 update tld.conf, ignore domains with no ns records
Carl Byington <carl@five-ten-sg.com>
parents: 276
diff changeset
36 f.write('%s%s\n' % (prefix, x))
270
f92f24950bd3 Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
37 f.close()