DPR-blocked-sites/runners/1_ips_from_domains_txt.py
Maxim Slipenko b748fb1c96 Добавляет IP-диапазоны Google (#1)
Co-authored-by: Maxim Slipenko <no-reply@maxim.slipenko.com>
Reviewed-on: #1
2022-09-16 15:15:04 +00:00

22 lines
465 B
Python

import socket
from collections import defaultdict
from utils import prettyprint
ips = []
dict = defaultdict(list)
def main(file_data: list):
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:
file_data.append(prettyprint(ip, ', '.join(dict[ip])) + '\n')
return file_data