add meta-rule-set

This commit is contained in:
xishang0128 2023-12-01 16:25:26 +08:00
parent ad85e0596f
commit 017479b5c4
2 changed files with 75 additions and 0 deletions

View File

@ -243,6 +243,29 @@ jobs:
chmod 755 mosdns sing-box convert.sh && ./convert.sh chmod 755 mosdns sing-box convert.sh && ./convert.sh
rm mosdns* sing-box* convert.sh geoip.dat geosite.db LICENSE README.md config.yaml rm mosdns* sing-box* convert.sh geoip.dat geosite.db LICENSE README.md config.yaml
- name: Convert geo to meta-rule-set
env:
NO_SKIP: true
run: |
mkdir -p ./meta-rule/geo
cp ./geoip.dat ./custom/publish/geosite.dat ./resouces/convert-clash.sh ./meta-rule/geo/
cd ./meta-rule/geo
wget https://github.com/IrineSistiana/mosdns/releases/download/v4.5.3/mosdns-linux-amd64.zip -O mosdns.zip && unzip mosdns.zip
chmod 755 mosdns convert-clash.sh && ./convert-clash.sh
rm mosdns* convert-clash.sh geoip.dat geosite.dat LICENSE README.md config.yaml
- name: Convert geo-lite to meta-rule-set
env:
NO_SKIP: true
run: |
mkdir -p ./meta-rule/geo-lite
cp ./geoip-lite.dat ./meta-rule/geo-lite/geoip.dat && cp ./community/geosite-lite.dat ./meta-rule/geo-lite/geosite.dat && cp ./resouces/convert-clash.sh ./meta-rule/geo-lite/
cd ./meta-rule/geo-lite
wget https://github.com/IrineSistiana/mosdns/releases/download/v4.5.3/mosdns-linux-amd64.zip -O mosdns.zip && unzip mosdns.zip
chmod 755 mosdns convert-clash.sh && ./convert-clash.sh
rm mosdns* convert-clash.sh geoip.dat geosite.dat LICENSE README.md config.yaml
- name: Move and zip files - name: Move and zip files
run: | run: |
mkdir -p ./publish/ mkdir -p ./publish/
@ -316,6 +339,20 @@ jobs:
git remote add origin "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}" git remote add origin "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}"
git push -f -u origin sing git push -f -u origin sing
- name: Git push assets to "meta-rule" branch
run: |
cd meta-rule || exit 1
ls
git init
git config --local user.name "github-actions[bot]"
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git checkout -b meta
git add .
git commit -m "Released on ${{ env.BUILDTIME }}"
git remote add origin "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}"
git push -f -u origin meta
- name: Purge jsdelivr CDN - name: Purge jsdelivr CDN
run: | run: |
cd publish || exit 1 cd publish || exit 1

38
resouces/convert-clash.sh Executable file
View File

@ -0,0 +1,38 @@
#!/bin/bash
mkdir -p geoip
./mosdns v2dat unpack-ip -o ./geoip/ geoip.dat
list=($(ls ./geoip | sed 's/geoip_//g' | sed 's/\.txt//g'))
for ((i = 0; i < ${#list[@]}; i++)); do
# echo "${list[i]}"
mv ./geoip/geoip_${list[i]}.txt ./geoip/${list[i]}.list
echo "payload:" >./geoip/${list[i]}.yaml
cat ./geoip/${list[i]}.list | sed 's/^/- "/g' | sed 's/$/"/g' >>./geoip/${list[i]}.yaml
done
mkdir -p geosite
./mosdns v2dat unpack-domain -o ./geosite/ geosite.dat
list=($(ls ./geosite | sed 's/geosite_//g' | sed 's/\.txt//g'))
for ((i = 0; i < ${#list[@]}; i++)); do
# echo "${list[i]}"
mv ./geosite/geosite_${list[i]}.txt ./geosite/${list[i]}.list
sed -i '/^#/d' geosite/${list[i]}.list
sed -i '/^keyword:/d' geosite/${list[i]}.list
sed -i '/^regexp:/d' geosite/${list[i]}.list
sed -i 's/^/+./g' ./geosite/${list[i]}.list
sed -i 's/+.full://g' ./geosite/${list[i]}.list
sed -i 's/+.domain:/+./g' ./geosite/${list[i]}.list
echo "payload:" >./geosite/${list[i]}.yaml
cat ./geosite/${list[i]}.list | sed 's/^/- "/g' | sed 's/$/"/g' >>./geosite/${list[i]}.yaml
done
#mkdir -p mixed
#for file in $(find geoip -type f | grep -v srs | awk -F "/" '{print $NF}'); do
# if [ -n "$(find geosite -type f -iname "$file")" ]; then
# file=$(find ./geosite -type f -iname "$file" | awk -F"/" '{print $NF}' | sed 's/\.json//g')
# head -n -3 ./geoip/${file}.json >./mixed/${file}.json
# sed -i 's/]/],/g' ./mixed/${file}.json
# tail -n +5 ./geosite/${file}.json >>./mixed/${file}.json
# ./sing-box rule-set compile ./mixed/${file}.json -o ./mixed/${file}.srs
# fi
#done