DPR-blocked-sites/runners/1_ips_from_domains_txt.py

21 lines
491 B
Python
Raw Normal View History

import socket
from collections import defaultdict
from utils import prettyprint
ips = []
dict = defaultdict(list)
def main():
with open('ips.txt', 'w') as out:
for line in open('domains.txt'):
l = line.strip()
if l.startswith('#') or l == '':
continue
dict[socket.gethostbyname(l) + '/32'].append(l)
ips = list(dict.keys())
for ip in ips:
out.write(prettyprint(ip, ', '.join(dict[ip])) + '\n')