-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathconfig.yaml
More file actions
114 lines (100 loc) · 4.48 KB
/
Copy pathconfig.yaml
File metadata and controls
114 lines (100 loc) · 4.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# 基础配置
work_dir: "./tmp"
output_dir: "./out"
# Mihomo 配置
mihomo:
api_url: "https://api.github.com/repos/MetaCubeX/mihomo/releases"
start_with: "mihomo-linux-amd64-alpha"
end_with: ".gz"
# sing-box 配置(用于生成 .srs 格式规则集)
singbox:
api_url: "https://api.github.com/repos/SagerNet/sing-box/releases"
start_with: "sing-box-"
end_with: "-linux-amd64.tar.gz"
# Git 配置
git:
user_email: "259484229+oom-wg[bot]@users.noreply.github.com"
user_name: "oom-wg[bot]"
release_branch: "release"
max_history: 7
timezone: "Asia/Shanghai"
# 任务配置
tasks:
ad:
format: "mrs srs"
src: # 会自动去重
- "https://github.com/privacy-protection-tools/anti-AD/raw/refs/heads/master/anti-ad-clash.yaml"
- "https://github.com/Cats-Team/AdRules/raw/refs/heads/main/adrules_domainset.txt"
- "https://github.com/MetaCubeX/meta-rules-dat/raw/refs/heads/meta/geo/geosite/category-httpdns-cn@ads.list"
- "https://github.com/ignaciocastro/a-dove-is-dumb/raw/refs/heads/main/pihole.txt"
custom_script: |
print(f" -> 执行自定义 AD 清洗,处理前数量: {len(domains)}")
# 定义需要移除的后缀,及其对应的替换规则 (None 代表只删不补)
# 格式: ".后缀": "替换内容"
rules_map = {
".xx.fbcdn.net.iberostar.com": "+.xx.fbcdn.net.iberostar.com",
".wns.windows.com": "+.wns.windows.com",
".p2l.info": "+.p2l.info",
".net.mydays.de": "+.net.mydays.de",
".net.anwalt.de": "+.net.anwalt.de",
".wo.com.cn": None, # 只移除规则(即放行),不添加泛屏蔽
".apps.iocnt.de": "+.apps.iocnt.de" # 用于配合下面的正则判断
}
new_domains = []
# 单次循环处理所有逻辑 (性能大大提升)
for d in domains:
skip = False
# 1. 特殊正则逻辑: 处理 data-xxx.apps.iocnt.de
if d.startswith("+.data-") and d.endswith(".apps.iocnt.de"):
skip = True
# 2. 批量后缀匹配
if not skip:
for suffix in rules_map:
if d.endswith(suffix):
skip = True
break
# 3. 如果没被标记跳过,则保留
if not skip:
new_domains.append(d)
# 4. 统一补回泛域名规则
for replacement in rules_map.values():
if replacement:
new_domains.append(replacement)
domains = new_domains
print(f" -> 清洗完成,处理后数量: {len(domains)}")
cn:
format: "mrs srs"
src:
- "https://github.com/MetaCubeX/meta-rules-dat/raw/meta/geo/geosite/cn.list"
- "https://github.com/MetaCubeX/meta-rules-dat/raw/meta/geo/geosite/steam@cn.list"
- "https://github.com/MetaCubeX/meta-rules-dat/raw/meta/geo/geosite/microsoft@cn.list"
- "https://github.com/MetaCubeX/meta-rules-dat/raw/meta/geo/geosite/google@cn.list"
- "https://github.com/MetaCubeX/meta-rules-dat/raw/meta/geo/geosite/win-update.list"
- "https://github.com/MetaCubeX/meta-rules-dat/raw/meta/geo/geosite/private.list"
# 自定义清洗脚本
# 在这里编写 Python 代码,变量名 'domains' 是一个列表,包含了当前所有的域名行
custom_script: |
print(f" -> 执行自定义清洗,处理前数量: {len(domains)}")
# 简单的过滤列表 (只删不补的放在这里)
# 复杂的逻辑或者需要补回的建议用上面的结构,或者保持现在的写法
# 过滤包含特定字符串的行
domains = [d for d in domains if "dsp.mp.microsoft.com" not in d]
# 过滤后缀
filter_suffixes = (
".wns.windows.com",
".100.in-addr.arpa",
".download.prss.microsoft.com"
)
# endswith 实际上支持传入元组 (tuple),一次匹配多个
domains = [d for d in domains if not d.endswith(filter_suffixes)]
# 批量补回
domains.append("+.do.dsp.mp.microsoft.com")
domains.append("+.wns.windows.com")
domains.append("+.100.in-addr.arpa")
domains.append("+.download.prss.microsoft.com")
print(f" -> 清洗完成,处理后数量: {len(domains)}")
cnIP:
format: "mrs srs"
src:
- "https://github.com/MetaCubeX/meta-rules-dat/raw/meta/geo/geoip/cn.list"
- "https://github.com/MetaCubeX/meta-rules-dat/raw/meta/geo/geoip/private.list"