Add ability to process IPV6 CIDR (#132)

* Support IPV6 CIDR

* Remove duplicate domain from GFWList and update Telegram CIDR

* Support DOMAIN-SUFFIX rules
This commit is contained in:
Wydy
2023-04-04 10:07:49 +08:00
committed by GitHub
parent b80b810d54
commit 6c46bd8155
3 changed files with 35 additions and 58 deletions

View File

@@ -96,7 +96,10 @@ for row in rule:
row = row.lstrip('.*')
# 清除后缀
row = row.rstrip('/^*')
row = row.rstrip('/*')
if row[-1] == '^':
row = '.'+row
row = row.rstrip('^')
row = re.sub(r':\d{2,5}$', '', row) # 清除端口
# 不能含有的字符
@@ -109,7 +112,7 @@ for row in rule:
continue
# 只匹配域名或 IP
if re.match(r'^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,9}$', row) or re.match(r'^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$', row):
if re.match(r'^\.?[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})*\.[a-zA-Z0-9][-a-zA-Z0-9]{1,}$', row) or re.match(r'^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$', row):
domains.append(row)
print('done.')