mirror of
https://github.com/MetaCubeX/meta-rules-dat.git
synced 2024-11-13 04:55:35 +08:00
add sing-rule-set
This commit is contained in:
parent
5273c5e5a2
commit
ad85e0596f
38
.github/workflows/run.yml
vendored
38
.github/workflows/run.yml
vendored
@ -218,6 +218,31 @@ jobs:
|
||||
geo convert ip -i v2ray -o sing -f geoip-lite.db ./geoip-lite.dat
|
||||
geo convert ip -i v2ray -o meta -f geoip-lite.metadb ./geoip-lite.dat
|
||||
|
||||
- name: Convert geo to sing-rule-set
|
||||
env:
|
||||
NO_SKIP: true
|
||||
run: |
|
||||
mkdir -p ./sing-rule/geo
|
||||
cp ./geoip.dat ./geosite.db ./resouces/convert.sh ./sing-rule/geo/
|
||||
cd ./sing-rule/geo
|
||||
wget https://github.com/SagerNet/sing-box/releases/download/v1.8.0-alpha.1/sing-box-1.8.0-alpha.1-linux-amd64.tar.gz -O sing-box.tar.gz && tar zxvf sing-box.tar.gz && mv sing-box-1.8.0-alpha.1-linux-amd64/sing-box ./ && rm -r sing-box-1.8.0-alpha.1-linux-amd64
|
||||
wget https://github.com/IrineSistiana/mosdns/releases/download/v4.5.3/mosdns-linux-amd64.zip -O mosdns.zip && unzip mosdns.zip
|
||||
chmod 755 mosdns sing-box convert.sh && ./convert.sh
|
||||
rm mosdns* sing-box* convert.sh geoip.dat geosite.db LICENSE README.md config.yaml
|
||||
|
||||
|
||||
- name: Convert geo-lite to sing-rule-set
|
||||
env:
|
||||
NO_SKIP: true
|
||||
run: |
|
||||
mkdir -p ./sing-rule/geo-lite
|
||||
cp ./geoip-lite.dat ./sing-rule/geo-lite/geoip.dat && cp ./geosite-lite.db ./sing-rule/geo-lite/geosite.db && cp ./resouces/convert.sh ./sing-rule/geo-lite/
|
||||
cd ./sing-rule/geo-lite
|
||||
wget https://github.com/SagerNet/sing-box/releases/download/v1.8.0-alpha.1/sing-box-1.8.0-alpha.1-linux-amd64.tar.gz -O sing-box.tar.gz && tar zxvf sing-box.tar.gz && mv sing-box-1.8.0-alpha.1-linux-amd64/sing-box ./ && rm -r sing-box-1.8.0-alpha.1-linux-amd64
|
||||
wget https://github.com/IrineSistiana/mosdns/releases/download/v4.5.3/mosdns-linux-amd64.zip -O mosdns.zip && unzip mosdns.zip
|
||||
chmod 755 mosdns sing-box convert.sh && ./convert.sh
|
||||
rm mosdns* sing-box* convert.sh geoip.dat geosite.db LICENSE README.md config.yaml
|
||||
|
||||
- name: Move and zip files
|
||||
run: |
|
||||
mkdir -p ./publish/
|
||||
@ -278,6 +303,19 @@ jobs:
|
||||
git remote add origin "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}"
|
||||
git push -f -u origin release
|
||||
|
||||
- name: Git push assets to "sing-rule" branch
|
||||
run: |
|
||||
cd sing-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 sing
|
||||
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 sing
|
||||
|
||||
- name: Purge jsdelivr CDN
|
||||
run: |
|
||||
cd publish || exit 1
|
||||
|
31
resouces/convert.sh
Normal file
31
resouces/convert.sh
Normal file
@ -0,0 +1,31 @@
|
||||
#!/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
|
||||
sed -i 's/^/ "/g' ./geoip/geoip_${list[i]}.txt
|
||||
sed -i 's/$/",/g' ./geoip/geoip_${list[i]}.txt
|
||||
sed -i '1s/^/{\n "version": 1,\n "rules": [\n {\n "ip_cidr": [\n/g' ./geoip/geoip_${list[i]}.txt
|
||||
sed -i '$ s/,$/\n ]\n }\n ]\n}/g' ./geoip/geoip_${list[i]}.txt
|
||||
mv ./geoip/geoip_${list[i]}.txt ./geoip/${list[i]}.json
|
||||
./sing-box rule-set compile "./geoip/${list[i]}.json" -o ./geoip/${list[i]}.srs
|
||||
done
|
||||
|
||||
list=($(./sing-box geosite list | sed 's/ (.*)$//g'))
|
||||
mkdir -p geosite
|
||||
for ((i = 0; i < ${#list[@]}; i++)); do
|
||||
./sing-box geosite export ${list[i]} -o ./geosite/${list[i]}.json
|
||||
./sing-box rule-set compile ./geosite/${list[i]}.json -o ./geosite/${list[i]}.srs
|
||||
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
|
Loading…
Reference in New Issue
Block a user