Mercurial > dnsbl
annotate make-tld-conf.py @ 375:aeb4480a2a95 stable-6-0-49
avoid packaging generated dnsbl.service file
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Wed, 08 Feb 2017 11:34:51 -0800 |
parents | c8144da09419 |
children | 78eedbbce636 |
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 | 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): |
300
3a3b0cbcaf6e
update tld.conf for new zones
Carl Byington <carl@five-ten-sg.com>
parents:
291
diff
changeset
|
6 print c |
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
|
7 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
|
8 |
291
9f0d9fcb58dd
Never add auto-whitelist entries for outgoing mail from localhost
Carl Byington <carl@five-ten-sg.com>
parents:
289
diff
changeset
|
9 url = 'https://publicsuffix.org/list/effective_tld_names.dat' |
9f0d9fcb58dd
Never add auto-whitelist entries for outgoing mail from localhost
Carl Byington <carl@five-ten-sg.com>
parents:
289
diff
changeset
|
10 c = 'curl %s 2>/dev/null' % url |
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
|
11 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
|
12 f=open('tld.conf','w') |
276 | 13 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
|
14 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
|
15 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
|
16 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
|
17 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
|
18 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
|
19 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
|
20 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
|
21 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
|
22 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
|
23 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
|
24 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
|
25 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
|
26 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
|
27 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
|
28 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
|
29 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
|
30 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
|
31 x = y |
6497944a9bd9
update tld.conf, ignore domains with no ns records
Carl Byington <carl@five-ten-sg.com>
parents:
276
diff
changeset
|
32 if not prefix and (len(x.split('.')) == 1): |
300
3a3b0cbcaf6e
update tld.conf for new zones
Carl Byington <carl@five-ten-sg.com>
parents:
291
diff
changeset
|
33 rc = cmd("dig %s ns +short 2>&1" % x) |
289
6497944a9bd9
update tld.conf, ignore domains with no ns records
Carl Byington <carl@five-ten-sg.com>
parents:
276
diff
changeset
|
34 if not rc: |
300
3a3b0cbcaf6e
update tld.conf for new zones
Carl Byington <carl@five-ten-sg.com>
parents:
291
diff
changeset
|
35 rc = cmd("sleep 3; dig %s ns +short 2>&1" % x) |
289
6497944a9bd9
update tld.conf, ignore domains with no ns records
Carl Byington <carl@five-ten-sg.com>
parents:
276
diff
changeset
|
36 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
|
37 f.write('%s%s\n' % (prefix, x)) |
307
c8144da09419
updated tld on 2015-10-15
Carl Byington <carl@five-ten-sg.com>
parents:
300
diff
changeset
|
38 f.write('\n') |
c8144da09419
updated tld on 2015-10-15
Carl Byington <carl@five-ten-sg.com>
parents:
300
diff
changeset
|
39 f.write('// enable rdns as a tld, so *.reverse.softlayer.com is effective in the rpz zone\n') |
c8144da09419
updated tld on 2015-10-15
Carl Byington <carl@five-ten-sg.com>
parents:
300
diff
changeset
|
40 f.write('reverse.softlayer.com\n') |
c8144da09419
updated tld on 2015-10-15
Carl Byington <carl@five-ten-sg.com>
parents:
300
diff
changeset
|
41 f.write('sl-reverse.com\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
|
42 f.close() |