42 lines
966 B
Python
Executable File
42 lines
966 B
Python
Executable File
#!/usr/bin/env python
|
|
import datetime
|
|
import string
|
|
import sys
|
|
import urllib.request
|
|
|
|
HOST_LISTS = [
|
|
'hosts',
|
|
'https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling/hosts',
|
|
]
|
|
|
|
ZONE_HEADER = string.Template('''\
|
|
$$TTL 3H
|
|
@ IN SOA @ rname.invalid. (
|
|
${serial} ; serial
|
|
1D ; refresh
|
|
1H ; retry
|
|
1W ; expire
|
|
3H ) ; minimum
|
|
NS @
|
|
A 127.0.0.1
|
|
AAAA ::1
|
|
|
|
nextcloud.pyrocufflink.net CNAME cloud0.pyrocufflink.blue.
|
|
|
|
''')
|
|
|
|
serial = datetime.datetime.now().strftime('%Y%m%d%H%M%S')
|
|
|
|
sys.stdout.write(ZONE_HEADER.substitute(serial=serial))
|
|
|
|
for hostlist in HOST_LISTS:
|
|
if urllib.parse.urlsplit(hostlist).netloc:
|
|
f = urllib.request.urlopen(hostlist)
|
|
else:
|
|
f = open(hostlist, 'rb')
|
|
with f:
|
|
for line in f.readlines():
|
|
if line.startswith(b'0.0.0.0 '):
|
|
name = line.strip().split()[1].decode()
|
|
sys.stdout.write(f'{name} CNAME .\n')
|