добавляет больше IP-адресов

This commit is contained in:
2022-09-18 09:14:58 +03:00
parent aec687122a
commit 3d13b8263f
3 changed files with 23 additions and 2 deletions

View File

@@ -1,3 +1,4 @@
import ipaddress
import socket
from collections import defaultdict
from utils import prettyprint
@@ -12,7 +13,14 @@ def main(file_data: list):
if l.startswith('#') or l == '':
continue
dict[socket.gethostbyname(l) + '/32'].append(l)
domain_or_range, comment, *_ = [x.strip() for x in l.split('#')] + [None]
try:
ipaddress.ip_network(domain_or_range)
dict[domain_or_range].append(comment)
except ValueError:
dict[socket.gethostbyname(domain_or_range) + '/32'].append(l)
ips = list(dict.keys())