Skip to content

Commit 62919e2

Browse files
authored
Update adobe-ruleset.yml
1 parent 46d0b4b commit 62919e2

1 file changed

Lines changed: 44 additions & 16 deletions

File tree

.github/workflows/adobe-ruleset.yml

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,41 +19,70 @@ jobs:
1919
token: ${{ secrets.GITHUB_TOKEN }}
2020
persist-credentials: true
2121

22-
- name: Download and extract Adobe domains and IPs
22+
- name: Download, Merge and Extract Rules
2323
run: |
24-
# 创建目录
24+
# 确保目录存在
2525
mkdir -p other/adobe/block/domain
2626
mkdir -p other/adobe/block/ip
2727
28-
# 下载 hosts 文件
28+
# --- 1. 下载在线 Hosts 文件 ---
2929
echo "Downloading from macwk.cn..."
3030
curl -fsSL https://macwk.cn/list.txt > temp1.txt
3131
3232
echo "Downloading from macat.vip..."
3333
curl -fsSL https://www.macat.vip/list.txt > temp2.txt
3434
35-
# 合并两个文件
35+
# 合并两个在线临时文件
3636
cat temp1.txt temp2.txt > temp_all.txt
3737
38+
# --- 2. 处理域名 (Domain) ---
3839
echo "Processing Domains..."
39-
# 提取域名(第二列不是纯IP的)
40-
awk 'NF>=2 && !/^#/ && $2 !~ /^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+(:[0-9]+)?$/ {print $2}' temp_all.txt | \
40+
41+
# 2.1 从在线列表提取域名
42+
awk 'NF>=2 && !/^#/ && $2 !~ /^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+(:[0-9]+)?$/ {print $2}' temp_all.txt > temp_domains_raw.txt
43+
44+
# 2.2 合并本地自定义域名列表 (adddomain.list)
45+
if [ -f "other/adobe/block/adddomain.list" ]; then
46+
echo "Found adddomain.list, merging local domains..."
47+
cat "other/adobe/block/adddomain.list" >> temp_domains_raw.txt
48+
else
49+
echo "No local adddomain.list found, skipping merge."
50+
fi
51+
52+
# 2.3 清理、去重并输出最终文件
53+
cat temp_domains_raw.txt | \
4154
sed 's/\.$//' | \
4255
grep -v '^[[:space:]]*$' | \
4356
sort -u > other/adobe/block/domain/Adobe.list
4457
58+
# --- 3. 处理 IP (IP-CIDR) ---
4559
echo "Processing IPs..."
46-
# 提取IP(第二列是纯IP或IP:端口的)
47-
# 去除端口号,只保留IP,并添加 /32 CIDR
60+
61+
# 3.1 从在线列表提取 IP 并添加 /32
4862
awk 'NF>=2 && !/^#/ && $2 ~ /^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+(:[0-9]+)?$/ {
4963
split($2, a, ":");
5064
print a[1] "/32";
51-
}' temp_all.txt | \
52-
grep -v '^[[:space:]]*$' | \
53-
sort -u > other/adobe/block/ip/Adobe.list
65+
}' temp_all.txt > temp_ips_raw.txt
66+
67+
# 3.2 合并本地自定义 IP 列表 (addip.list)
68+
if [ -f "other/adobe/block/addip.list" ]; then
69+
echo "Found addip.list, merging local IPs..."
70+
# 使用 awk 智能处理:如果是纯IP自动加/32,如果是CIDR则保持原样
71+
awk '{
72+
# 跳过空行和注释
73+
if ($0 ~ /^[[:space:]]*$/ || $0 ~ /^#/) next;
74+
# 如果包含 / 则直接打印,否则添加 /32
75+
if ($0 ~ /\//) print $0; else print $0 "/32";
76+
}' "other/adobe/block/addip.list" >> temp_ips_raw.txt
77+
else
78+
echo "No local addip.list found, skipping merge."
79+
fi
80+
81+
# 3.3 去重并输出最终文件
82+
cat temp_ips_raw.txt | grep -v '^[[:space:]]*$' | sort -u > other/adobe/block/ip/Adobe.list
5483
55-
# 清理临时文件
56-
rm -f temp1.txt temp2.txt temp_all.txt
84+
# --- 4. 清理临时文件 ---
85+
rm -f temp1.txt temp2.txt temp_all.txt temp_domains_raw.txt temp_ips_raw.txt
5786
5887
echo "Total unique domains: $(wc -l < other/adobe/block/domain/Adobe.list)"
5988
echo "Total unique IPs: $(wc -l < other/adobe/block/ip/Adobe.list)"
@@ -76,7 +105,7 @@ jobs:
76105
echo "Warning: No domains found!"
77106
fi
78107
79-
# 为 IP 生成 mrs 文件 (注意这里用 ipcidr)
108+
# 为 IP 生成 mrs 文件
80109
if [ -s "other/adobe/block/ip/Adobe.list" ]; then
81110
echo "Generating mrs file for IPs..."
82111
./mihomo convert-ruleset ipcidr text "other/adobe/block/ip/Adobe.list" "other/adobe/block/ip/Adobe.mrs"
@@ -106,7 +135,6 @@ jobs:
106135
IPEOF
107136
while IFS= read -r line; do
108137
[[ -z "$line" || "$line" =~ ^[[:space:]]*# ]] && continue
109-
# .list 文件里已经包含 /32 了,这里直接写入即可
110138
echo " - '$line'" >> other/adobe/block/ip/Adobe.yaml
111139
done < other/adobe/block/ip/Adobe.list
112140
echo "IP YAML generated"
@@ -123,6 +151,6 @@ jobs:
123151
if git diff --staged --quiet; then
124152
echo "No changes to commit"
125153
else
126-
git commit -m "Update Adobe ruleset - $(date +'%Y-%m-%d %H:%M:%S')"
154+
git commit -m "Update Adobe ruleset (Integrated local lists) - $(date +'%Y-%m-%d %H:%M:%S')"
127155
git push
128156
fi

0 commit comments

Comments
 (0)