AWAvenue-Ads-Rule/config.py
2025-05-19 10:57:56 +08:00

32 lines
1.1 KiB
Python

import os
import dns.resolver
SCRIPT_PATH = os.path.join(os.getcwd(), "script") # 插件文件夹
RULE_PATH = os.path.join(os.getcwd(), "rule") # 规则文件夹
OUT_PATH = os.getcwd() + "/out" # 输出文件夹
domain_file=RULE_PATH + "/domain.txt" # 规则文件
regex_file=RULE_PATH + "/domain_regex.txt" # 正则规则文件
ip_file=RULE_PATH + "/ip.txt" # IP规则文件
ip6_file=RULE_PATH + "/ip6.txt" # IPv6规则文件
def check_domain(domain):
resolver = dns.resolver.Resolver(configure=False)
resolver.nameservers = ['8.8.8.8', '1.1.1.1', '223.5.5.5', '9.9.9.9', '94.140.14.140']
resolver.timeout = 1
resolver.lifetime = 5
result = {"A": False, "AAAA": False}
try:
A = resolver.resolve(domain, "A", raise_on_no_answer=False)
result["A"] = bool(A and A.rrset)
except Exception as e:
print(f"解析 A 记录时出错: {e}")
try:
AAAA = resolver.resolve(domain, "AAAA", raise_on_no_answer=False)
result["AAAA"] = bool(AAAA and AAAA.rrset)
except Exception as e:
print(f"解析 AAAA 记录时出错: {e}")
return result