mirror of
https://github.com/TG-Twilight/AWAvenue-Ads-Rule.git
synced 2025-11-04 14:49:47 +08:00
移除无效域名查询(action无法判断正确判断是否有效)
Some checks failed
build Rule / execute_python_script (push) Has been cancelled
Some checks failed
build Rule / execute_python_script (push) Has been cancelled
This commit is contained in:
parent
0647a71c01
commit
aef319700f
19
main.py
19
main.py
@ -20,7 +20,7 @@ def get_latest_git_tag(): # 获取最新的git tag
|
||||
|
||||
class RuleList:
|
||||
def __init__(self, domain_file, regex_file, ip_file, ip6_file):
|
||||
self.domain_list, self.domainv6_list = self.domain_file(domain_file)
|
||||
self.domain_list = self.domain_file(domain_file)
|
||||
self.regex_list = self.regex_file(regex_file)
|
||||
self.ip_list = self.ip_file(ip_file)
|
||||
self.ip6_list = self.ip6_file(ip6_file)
|
||||
@ -30,20 +30,7 @@ class RuleList:
|
||||
|
||||
def domain_file(self, filename):
|
||||
with open(filename, 'r') as file:
|
||||
domains = {line.strip() for line in file}
|
||||
|
||||
valid_domains = set()
|
||||
valid_domains_v6 = set()
|
||||
with concurrent.futures.ThreadPoolExecutor(max_workers=8) as executor:
|
||||
future_to_domain = {executor.submit(config.check_domain, domain): domain for domain in domains}
|
||||
for future in concurrent.futures.as_completed(future_to_domain):
|
||||
domain = future_to_domain[future]
|
||||
result = future.result()
|
||||
if result["A"] or result["AAAA"]:
|
||||
valid_domains.add(domain)
|
||||
if result["AAAA"]:
|
||||
valid_domains_v6.add(domain)
|
||||
return sorted(valid_domains), sorted(valid_domains_v6)
|
||||
return sorted({line.strip() for line in file})
|
||||
|
||||
def regex_file(self, filename):
|
||||
with open(filename, 'r') as file:
|
||||
@ -118,7 +105,7 @@ def RunScript():
|
||||
# 判断插件是否有list、total、suffix、comment四个属性
|
||||
if len(plugins) == 4:
|
||||
WriteFile(plugins_name, plugins['list'], plugins['suffix'], plugins['comment'], str(plugins['total']))
|
||||
print(f"{plugins_name}转换成功")
|
||||
print(f"{plugins_name}转换成功 共计 "+ str(plugins['total'])+ " 条规则")
|
||||
else:
|
||||
print(f"转换插件:{plugins_name}执行失败: 缺少必要属性")
|
||||
|
||||
|
||||
@ -1,16 +1,14 @@
|
||||
|
||||
def format_domain(List, Listv6):
|
||||
def format_domain(List):
|
||||
domain = []
|
||||
for line in List:
|
||||
domain_lines = f"address=/{line.strip()}/0.0.0.0"
|
||||
domain.append(domain_lines)
|
||||
|
||||
for line in Listv6:
|
||||
domain_lines = f"address=/{line.strip()}/::"
|
||||
domain.append(domain_lines)
|
||||
return domain
|
||||
|
||||
|
||||
def build(rule):
|
||||
list = format_domain(rule.domain_list, rule.domainv6_list)
|
||||
list = format_domain(rule.domain_list)
|
||||
return {'list': list, 'suffix': '.conf', 'comment': '#', 'total': len(list)}
|
||||
@ -1,17 +1,15 @@
|
||||
import json
|
||||
|
||||
def format_domain(List, Listv6):
|
||||
def format_domain(List):
|
||||
domain = ["0.0.0.0 localhost", "::1 localhost", "", ""]
|
||||
for line in List:
|
||||
domain_lines = f"0.0.0.0 {line.strip()}"
|
||||
domain.append(domain_lines)
|
||||
|
||||
for line in Listv6:
|
||||
domain_lines = f":: {line.strip()}"
|
||||
domain.append(domain_lines)
|
||||
return domain
|
||||
|
||||
|
||||
def build(rule):
|
||||
list = format_domain(rule.domain_list, rule.domainv6_list)
|
||||
list = format_domain(rule.domain_list)
|
||||
return {'list': list, 'suffix': '.txt', 'comment': '#', 'total': len(list)}
|
||||
@ -1,16 +1,14 @@
|
||||
import json
|
||||
|
||||
def format_domain(List, Listv6):
|
||||
def format_domain(List):
|
||||
domain = []
|
||||
for line in List:
|
||||
domain_line = f"ip dns static add address=240.0.0.1 name={line.strip()}"
|
||||
domain.append(domain_line)
|
||||
|
||||
for line in Listv6:
|
||||
domain_line = f"ip dns static add address=:: name={line.strip()}"
|
||||
domain.append(domain_line)
|
||||
return domain
|
||||
|
||||
def build(rule):
|
||||
list = format_domain(rule.domain_list, rule.domainv6_list)
|
||||
list = format_domain(rule.domain_list)
|
||||
return {'list': list, 'suffix': '.txt', 'comment': '!', 'total': len(list)}
|
||||
|
||||
@ -1,16 +1,15 @@
|
||||
|
||||
def format_domain(List, Listv6):
|
||||
def format_domain(List):
|
||||
domain = ["127.0.0.1 localhost", "::1 localhost", "", ""]
|
||||
for line in List:
|
||||
domain_lines = f"0.0.0.0 {line.strip()}"
|
||||
domain.append(domain_lines)
|
||||
|
||||
for line in Listv6:
|
||||
domain_lines = f":: {line.strip()}"
|
||||
domain.append(domain_lines)
|
||||
|
||||
return domain
|
||||
|
||||
|
||||
def build(rule):
|
||||
list = format_domain(rule.domain_list, rule.domainv6_list)
|
||||
list = format_domain(rule.domain_list)
|
||||
return {'list': list, 'suffix': '.txt', 'comment': '!', 'total': len(list)}
|
||||
Loading…
Reference in New Issue
Block a user