Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import ipaddr
- def sanitize_domains_and_ips():
- raw_domains = os.path.join(os.path.dirname(__file__), 'master_blacklist')
- domains = set()
- ip_addresses = set()
- with open(raw_domains) as items:
- for item in items.readlines():
- item = item.strip().lower().strip('.')
- try:
- if ipaddr.IPAddress(item):
- pass #ip_addresses.add(item)
- except ValueError as e:
- domains.add(item)
- return iter(domains) #, iter(ip_addresses)
- def generate_bind9_conf(domains):
- with open('/etc/bind/filter.conf','w') as conf:
- for d in domains:
- conf.write('zone "'+d+'" { type master ; file "/etc/bind/dummyblock"; }; \n')
- if __name__ == '__main__':
- generate_bind9_conf(sanitize_domains_and_ips())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement