Mercurial > dnsbl
annotate make-tld-conf.py @ 454:3fb2b1f81487
Added tag stable-6-0-71 for changeset 8393ce4658cc
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Mon, 04 Jun 2018 19:13:28 -0700 |
parents | 78eedbbce636 |
children | f5b394bec28c |
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') |
445
78eedbbce636
round spamassassin scores; check >= rather than >
Carl Byington <carl@five-ten-sg.com>
parents:
307
diff
changeset
|
39 |
78eedbbce636
round spamassassin scores; check >= rather than >
Carl Byington <carl@five-ten-sg.com>
parents:
307
diff
changeset
|
40 c="grep '^\*.*multi.surbl' /etc/cron.daily/rpz | awk '{print $1}' | cut -c3- | sed -e 's/.multi.surbl.org//g'" |
78eedbbce636
round spamassassin scores; check >= rather than >
Carl Byington <carl@five-ten-sg.com>
parents:
307
diff
changeset
|
41 content = cmd(c) |
78eedbbce636
round spamassassin scores; check >= rather than >
Carl Byington <carl@five-ten-sg.com>
parents:
307
diff
changeset
|
42 for x in content.split('\n'): |
78eedbbce636
round spamassassin scores; check >= rather than >
Carl Byington <carl@five-ten-sg.com>
parents:
307
diff
changeset
|
43 f.write(x + '\n') |
78eedbbce636
round spamassassin scores; check >= rather than >
Carl Byington <carl@five-ten-sg.com>
parents:
307
diff
changeset
|
44 |
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
|
45 f.close() |