From 9db6eb3392aa82dc9b086d025fff04fbdc77c450 Mon Sep 17 00:00:00 2001 From: DustinWin Date: Sun, 17 Nov 2024 15:42:18 +0800 Subject: [PATCH] Update ruleset_geodata --- .github/workflows/run.yml | 421 ++++++++----- README.md | 1136 +++++++++++++++++++++-------------- tools/convert.sh | 107 ++++ tools/convert_compatible.sh | 107 ++++ 4 files changed, 1190 insertions(+), 581 deletions(-) create mode 100644 tools/convert.sh create mode 100644 tools/convert_compatible.sh diff --git a/.github/workflows/run.yml b/.github/workflows/run.yml index 3c5eec0631a..6f009b6e072 100644 --- a/.github/workflows/run.yml +++ b/.github/workflows/run.yml @@ -1,44 +1,32 @@ -name: Build V2Ray rules dat files +name: Build ruleset and geodata on: workflow_dispatch: schedule: - - cron: "0 22 * * *" + - cron: "0 19 * * *" push: branches: - master paths-ignore: - "**/README.md" + jobs: build: runs-on: ubuntu-latest steps: - name: Set variables run: | - echo "RELEASE_NAME=Released on $(date +%Y%m%d%H%M)" >> $GITHUB_ENV - echo "TAG_NAME=$(date +%Y%m%d%H%M)" >> $GITHUB_ENV - echo "CHINA_DOMAINS_URL=https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/accelerated-domains.china.conf" >> $GITHUB_ENV - echo "GOOGLE_DOMAINS_URL=https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/google.china.conf" >> $GITHUB_ENV - echo "APPLE_DOMAINS_URL=https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/apple.china.conf" >> $GITHUB_ENV - echo "EASYLISTCHINA_EASYLIST_REJECT_URL=https://easylist-downloads.adblockplus.org/easylistchina+easylist.txt" >> $GITHUB_ENV - echo "PETERLOWE_REJECT_URL=https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=1&mimetype=plaintext" >> $GITHUB_ENV - echo "ADGUARD_DNS_REJECT_URL=https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt" >> $GITHUB_ENV - echo "DANPOLLOCK_REJECT_URL=https://someonewhocares.org/hosts/hosts" >> $GITHUB_ENV - echo "CUSTOM_DIRECT=https://raw.githubusercontent.com/Loyalsoldier/domain-list-custom/release/cn.txt" >> $GITHUB_ENV - echo "CUSTOM_PROXY=https://raw.githubusercontent.com/Loyalsoldier/domain-list-custom/release/geolocation-!cn.txt" >> $GITHUB_ENV - echo "WIN_SPY=https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy.txt" >> $GITHUB_ENV - echo "WIN_UPDATE=https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/update.txt" >> $GITHUB_ENV - echo "WIN_EXTRA=https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/extra.txt" >> $GITHUB_ENV + echo "update_version=$(date -d '+8 hours' +%Y-%m-%d)" >> ${GITHUB_ENV} + echo "domains_download_url=https://raw.githubusercontent.com/DustinWin/domain-list-custom/domains" >> ${GITHUB_ENV} + echo "ips_download_url=https://github.com/DustinWin/geoip/releases/download/ips" >> ${GITHUB_ENV} shell: bash - - name: Checkout the "hidden" branch of this repo - uses: actions/checkout@v4 - with: - ref: hidden + - name: Clone Repository + uses: actions/checkout@master - - name: Checkout Loyalsoldier/domain-list-custom + - name: Checkout DustinWin/domain-list-custom uses: actions/checkout@v4 with: - repository: Loyalsoldier/domain-list-custom + repository: DustinWin/domain-list-custom path: custom - name: Checkout v2fly/domain-list-community @@ -47,165 +35,318 @@ jobs: repository: v2fly/domain-list-community path: community - - name: Checkout cokebar/gfwlist2dnsmasq - uses: actions/checkout@v4 - with: - repository: cokebar/gfwlist2dnsmasq - path: gfwlist2dnsmasq - - name: Setup Go uses: actions/setup-go@v5 with: go-version-file: ./custom/go.mod cache-dependency-path: ./custom/go.sum - - name: Get geoip.dat relative files + - name: Generate `clash` geodata run: | - wget https://github.com/Loyalsoldier/geoip/raw/release/geoip.dat - wget https://github.com/Loyalsoldier/geoip/raw/release/geoip.dat.sha256sum + mkdir -p ./community/mydata/ + archs1=(private ads microsoft-cn apple-cn google-cn games-cn ai networktest netflix disney max primevideo appletv youtube tiktok bilibili proxy cn) + archs2=(private ads microsoft-cn apple-cn google-cn games-cn ai networktest proxy cn) + + # Generate `clash` geosite-all.dat + for ((i = 0; i < 18; i++)); do + curl -sSL "${domains_download_url}/${archs1[i]}.list" | grep -E 'DOMAIN,|DOMAIN-SUFFIX,|DOMAIN-KEYWORD' | sed -e 's/^DOMAIN,/full:/' -e 's/^DOMAIN-SUFFIX,//' -e 's/^DOMAIN-KEYWORD,/keyword:/' > "./community/mydata/${archs1[i]}" + done + curl -sSL "${domains_download_url}/fakeip-filter.list" | sed -e 's/^DOMAIN,/full:/' -e 's/^DOMAIN-SUFFIX,//' -e 's/^DOMAIN-KEYWORD,/keyword:/' -e 's/^DOMAIN-REGEX,/regexp:/' > ./community/mydata/fakeip-filter + cd ./community/ + go run ./ --datapath=./mydata/ --outputname geosite-all.dat + + # Generate `clash` geosite-all-lite.dat + rm -f ./mydata/ads + go run ./ --datapath=./mydata/ --outputname geosite-all-lite.dat + + # Generate `clash` geosite.dat + rm -f ./mydata/* + for ((i = 0; i < 10; i++)); do + curl -sSL "${domains_download_url}/${archs2[i]}.list" | grep -E 'DOMAIN,|DOMAIN-SUFFIX,|DOMAIN-KEYWORD' | sed -e 's/^DOMAIN,/full:/' -e 's/^DOMAIN-SUFFIX,//' -e 's/^DOMAIN-KEYWORD,/keyword:/' > "./mydata/${archs2[i]}" + done + curl -sSL "${domains_download_url}/fakeip-filter.list" | sed -e 's/^DOMAIN,/full:/' -e 's/^DOMAIN-SUFFIX,//' -e 's/^DOMAIN-KEYWORD,/keyword:/' -e 's/^DOMAIN-REGEX,/regexp:/' > ./mydata/fakeip-filter + go run ./ --datapath=./mydata/ --outputname geosite.dat - - name: Generate GFWList domains + # Generate `clash` geosite-lite.dat + rm -f ./mydata/ads + go run ./ --datapath=./mydata/ --outputname geosite-lite.dat + + - name: Generate `sing-box` geodata run: | - cd gfwlist2dnsmasq || exit 1 - chmod +x ./gfwlist2dnsmasq.sh - ./gfwlist2dnsmasq.sh -l -o ./temp-gfwlist.txt + cd ./community/ || exit 1 + go install -trimpath -ldflags="-s -w -buildid=" github.com/metacubex/geo/cmd/geo@master + for file in $(ls *.dat | sed 's/\.dat$//'); do + geo convert site -i v2ray -o sing -f "./${file}.db" "./${file}.dat" + done - - name: Get and add direct domains into temp-direct.txt file + - name: Get geoip relative files run: | - curl -sSL $CHINA_DOMAINS_URL | perl -ne '/^server=\/([^\/]+)\// && print "$1\n"' > temp-direct.txt - curl -sSL ${CUSTOM_DIRECT} | perl -ne '/^(domain):([^:]+)(\n$|:@.+)/ && print "$2\n"' >> temp-direct.txt + mkdir -p ./clash/ ./sing-box/ + # Download Clash geoip files (.mmdb) + clash_mmdb=($(curl -sSL https://api.github.com/repos/DustinWin/geoip/releases | grep '"browser_download_url"' | grep '.mmdb' | awk -F'"' '{print $4}')) + count_clash_mmdb=${#clash_mmdb[@]} + for ((i = 0; i < count_clash_mmdb; i++)); do + wget -P ./clash/ "${clash_mmdb[i]}" + done + + # Download Clash other geoip files (except .mmdb) + clash_others=($(curl -sSL https://api.github.com/repos/DustinWin/geoip/releases | grep '"browser_download_url"' | grep '/clash/' | grep -v '.mmdb' | awk -F'"' '{print $4}')) + count_clash_others=${#clash_others[@]} + for ((i = 0; i < count_clash_others; i++)); do + wget -P ./community/ "${clash_others[i]}" + done - - name: Get and add proxy domains into temp-proxy.txt file + # Download sing-box all geoip files + singbox_all=($(curl -sSL https://api.github.com/repos/DustinWin/geoip/releases | grep '"browser_download_url"' | grep '/sing-box/' | awk -F'"' '{print $4}')) + count_singbox_all=${#singbox_all[@]} + for ((i = 0; i < count_singbox_all; i++)); do + wget -P ./community/ "${singbox_all[i]}" + done + + - name: Move `clash` and `sing-box` geodata files run: | - cat ./gfwlist2dnsmasq/temp-gfwlist.txt | perl -ne '/^((?=^.{3,255})[a-zA-Z0-9][-_a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-_a-zA-Z0-9]{0,62})+)/ && print "$1\n"' > temp-proxy.txt - curl -sSL $GOOGLE_DOMAINS_URL | perl -ne '/^server=\/([^\/]+)\// && print "$1\n"' >> temp-proxy.txt - curl -sSL $APPLE_DOMAINS_URL | perl -ne '/^server=\/([^\/]+)\// && print "$1\n"' >> temp-proxy.txt - curl -sSL ${CUSTOM_PROXY} | grep -Ev ":@cn" | perl -ne '/^(domain):([^:]+)(\n$|:@.+)/ && print "$2\n"' >> temp-proxy.txt + cd ./community/ || exit 1 + for file in $(ls *.dat *.metadb); do + install -Dp "./${file}" ../clash/ + done + for file in $(ls *.db); do + install -Dp "./${file}" ../sing-box/ + done + rm -rf ../custom* ../community* - - name: Get and add reject domains into temp-reject.txt file + - name: Generate `clash` rule-set run: | - curl -sSL $EASYLISTCHINA_EASYLIST_REJECT_URL | perl -ne '/^\|\|([-_0-9a-zA-Z]+(\.[-_0-9a-zA-Z]+){1,64})\^$/ && print "$1\n"' | perl -ne 'print if not /^[0-9]{1,3}(\.[0-9]{1,3}){3}$/' > temp-reject.txt - curl -sSL $ADGUARD_DNS_REJECT_URL | perl -ne '/^\|\|([-_0-9a-zA-Z]+(\.[-_0-9a-zA-Z]+){1,64})\^$/ && print "$1\n"' | perl -ne 'print if not /^[0-9]{1,3}(\.[0-9]{1,3}){3}$/' >> temp-reject.txt - curl -sSL $PETERLOWE_REJECT_URL | perl -ne '/^127\.0\.0\.1\s([-_0-9a-zA-Z]+(\.[-_0-9a-zA-Z]+){1,64})$/ && print "$1\n"' >> temp-reject.txt - curl -sSL $DANPOLLOCK_REJECT_URL | perl -ne '/^127\.0\.0\.1\s([-_0-9a-zA-Z]+(\.[-_0-9a-zA-Z]+){1,64})/ && print "$1\n"' | sed '1d' >> temp-reject.txt + mkdir -p ./clash-ruleset/ ./sing-box-ruleset/ ./sing-box-ruleset-compatible/ + domains=(private ads microsoft-cn apple-cn google-cn games-cn ai netflix disney max primevideo appletv youtube tiktok bilibili proxy cn) + archs=(applications networktest) + ips=(netflixip telegramip privateip cnip) + + # Generate `clash` rule-set (yaml) + for ((i = 0; i < 17; i++)); do + echo 'payload:' > "./clash-ruleset/${domains[i]}.yaml" + curl -sSL "${domains_download_url}/${domains[i]}.list" | grep -E 'DOMAIN,|DOMAIN-SUFFIX,' | sed -e "s/^DOMAIN,/ - '/" -e "s/^DOMAIN-SUFFIX,/ - '+\./" -e "s/$/'/" >> "./clash-ruleset/${domains[i]}.yaml" + done + echo 'payload:' > "./clash-ruleset/fakeip-filter.yaml" + curl -sSL "${domains_download_url}/fakeip-filter.list" | sed -e "s/^DOMAIN,/ - '/" -e "s/^DOMAIN-SUFFIX,/ - '+\./" -e "s/^DOMAIN-REGEX,/ - '/" -e "s/'\./'/" -e "s/$/'/" >> ./clash-ruleset/fakeip-filter.yaml + + for ((i = 0; i < 2; i++)); do + echo 'payload:' > "./clash-ruleset/${archs[i]}.yaml" + curl -sSL "${domains_download_url}/${archs[i]}.list" | sed 's/^/ - /' >> "./clash-ruleset/${archs[i]}.yaml" + done + + for ((i = 0; i < 4; i++)); do + echo 'payload:' > "./clash-ruleset/${ips[i]}.yaml" + curl -sSL "${ips_download_url}/${ips[i]}.list" | grep 'IP-CIDR' | sed -e "s/^IP-CIDR,/ - '/" -e "s/^IP-CIDR6,/ - '/" -e "s/$/'/" >> "./clash-ruleset/${ips[i]}.yaml" + done + + # Generate `clash` rule-set (text) + for ((i = 0; i < 17; i++)); do + curl -sSL "${domains_download_url}/${domains[i]}.list" | grep -E 'DOMAIN,|DOMAIN-SUFFIX,' | sed -e 's/^DOMAIN,//' -e 's/^DOMAIN-SUFFIX,/+\./' > "./clash-ruleset/${domains[i]}.list" + done + curl -sSL "${domains_download_url}/fakeip-filter.list" | sed -e 's/^DOMAIN,//' -e 's/^DOMAIN-SUFFIX,/+\./' -e 's/^DOMAIN-REGEX,//' -e 's/^\.//' > ./clash-ruleset/fakeip-filter.list + + for ((i = 0; i < 2; i++)); do + curl -sSL "${domains_download_url}/${archs[i]}.list" > "./clash-ruleset/${archs[i]}.list" + done + + for ((i = 0; i < 4; i++)); do + curl -sSL "${ips_download_url}/${ips[i]}.list" | grep 'IP-CIDR' | sed -e 's/^IP-CIDR,//' -e 's/^IP-CIDR6,//' > "./clash-ruleset/${ips[i]}.list" + done + + # Ready for generate `clash` rule-set (mrs) + for ((i = 0; i < 17; i++)); do + mkdir -p "./tools/domains/${domains[i]}/" + curl "${domains_download_url}/${domains[i]}.list" | grep -E 'DOMAIN,|DOMAIN-SUFFIX,' | sed -e 's/^DOMAIN,//' -e 's/^DOMAIN-SUFFIX,/+\./' > "./tools/domains/${domains[i]}/${domains[i]}.list" + done + mkdir -p "./tools/domains/fakeip-filter/" + curl -sSL "${domains_download_url}/fakeip-filter.list" | sed -e 's/^DOMAIN,//' -e 's/^DOMAIN-SUFFIX,/+\./' -e 's/^DOMAIN-REGEX,//' -e 's/^\.//' > ./tools/domains/fakeip-filter/fakeip-filter.list + + for ((i = 0; i < 4; i++)); do + mkdir -p "./tools/ips/${ips[i]}/" + curl -sSL "${ips_download_url}/${ips[i]}.list"| grep 'IP-CIDR' | sed -e 's/^IP-CIDR,//' -e 's/^IP-CIDR6,//' > "./tools/ips/${ips[i]}/${ips[i]}.list" + done + + # Ready for generate `sing-box` rule_set + for ((i = 0; i < 17; i++)); do + mkdir -p "./tools/rules/${domains[i]}/" + curl "${domains_download_url}/${domains[i]}.list" | grep -E 'DOMAIN,|DOMAIN-SUFFIX,|DOMAIN-KEYWORD' > "./tools/rules/${domains[i]}/${domains[i]}.yaml" + done + mkdir -p "./tools/rules/fakeip-filter/" + curl "${domains_download_url}/fakeip-filter.list" > "./tools/rules/fakeip-filter/fakeip-filter.yaml" + + for ((i = 0; i < 2; i++)); do + mkdir -p "./tools/rules/${archs[i]}/" + curl "${domains_download_url}/${archs[i]}.list" > "./tools/rules/${archs[i]}/${archs[i]}.yaml" + done + + for ((i = 0; i < 4; i++)); do + mkdir -p "./tools/rules/${ips[i]}/" + curl -sSL "${ips_download_url}/${ips[i]}.list"| grep 'IP-CIDR' > "./tools/rules/${ips[i]}/${ips[i]}.yaml" + done - - name: Reserve `full`, `regexp` and `keyword` type of rules from custom lists to "reserve" files + - name: Download and unzip `mihomo` core run: | - curl -sSL ${CUSTOM_DIRECT} | perl -ne '/^((full|regexp|keyword):[^:]+)(\n$|:@.+)/ && print "$1\n"' | sort --ignore-case -u > direct-reserve.txt - curl -sSL ${CUSTOM_PROXY} | grep -Ev ":@cn" | perl -ne '/^((full|regexp|keyword):[^:]+)(\n$|:@.+)/ && print "$1\n"' | sort --ignore-case -u > proxy-reserve.txt + wget https://github.com/DustinWin/clash_singbox-tools/releases/download/mihomo/mihomo-alpha-linux-amd64.tar.gz -O - | tar -zxf - -C ./tools/ + mv -f ./tools/CrashCore ./tools/mihomo - - name: Add proxy, direct and reject domains from "hidden" branch to appropriate temp files + - name: Generate `clash` rule-set (mrs) run: | - cat proxy.txt >> temp-proxy.txt - cat direct.txt >> temp-direct.txt - cat reject.txt >> temp-reject.txt + cd ./tools/ + chmod +x ./mihomo + list=($(ls ./domains/)) + for ((i = 0; i < ${#list[@]}; i++)); do + ./mihomo convert-ruleset domain text "./domains/${list[i]}/${list[i]}.list" ../clash-ruleset/${list[i]}.mrs + done + + list=($(ls ./ips/)) + for ((i = 0; i < ${#list[@]}; i++)); do + ./mihomo convert-ruleset ipcidr text "./ips/${list[i]}/${list[i]}.list" ../clash-ruleset/${list[i]}.mrs + done + rm -rf ./mihomo* ./domains/ ./ips/ - - name: Sort and generate redundant lists + - name: Download and unzip `sing-box` core run: | - cat temp-proxy.txt | sort --ignore-case -u > proxy-list-with-redundant - cat temp-direct.txt | sort --ignore-case -u > direct-list-with-redundant - cat temp-reject.txt | sort --ignore-case -u > reject-list-with-redundant + wget https://github.com/DustinWin/clash_singbox-tools/releases/download/sing-box/sing-box-dev-linux-amd64v3.tar.gz -O - | tar -zxf - -C ./tools/ + mv -f ./tools/CrashCore ./tools/sing-box - - name: Remove redundant domains + - name: Generate `sing-box` rule_set run: | - chmod +x findRedundantDomain.py - ./findRedundantDomain.py ./direct-list-with-redundant ./direct-list-deleted-unsort - ./findRedundantDomain.py ./proxy-list-with-redundant ./proxy-list-deleted-unsort - ./findRedundantDomain.py ./reject-list-with-redundant ./reject-list-deleted-unsort - [ ! -f "direct-list-deleted-unsort" ] && touch direct-list-deleted-unsort - [ ! -f "proxy-list-deleted-unsort" ] && touch proxy-list-deleted-unsort - [ ! -f "reject-list-deleted-unsort" ] && touch reject-list-deleted-unsort - sort ./direct-list-deleted-unsort > ./direct-list-deleted-sort - sort ./proxy-list-deleted-unsort > ./proxy-list-deleted-sort - sort ./reject-list-deleted-unsort > ./reject-list-deleted-sort - diff ./direct-list-deleted-sort ./direct-list-with-redundant | awk '/^>/{print $2}' > ./direct-list-without-redundant - diff ./proxy-list-deleted-sort ./proxy-list-with-redundant | awk '/^>/{print $2}' > ./proxy-list-without-redundant - diff ./reject-list-deleted-sort ./reject-list-with-redundant | awk '/^>/{print $2}' > ./reject-list-without-redundant + cd ./tools/ + chmod +x ./convert.sh && ./convert.sh + rm -rf ./sing-box* + mv -f ./*.json ./*.srs ../sing-box-ruleset/ - - name: Remove domains from "need-to-remove" lists in "hidden" branch + - name: Download and unzip `sing-box` core(compatible) run: | - diff ./direct-need-to-remove.txt ./direct-list-without-redundant | awk '/^>/{print $2}' > temp-cn.txt - diff ./proxy-need-to-remove.txt ./proxy-list-without-redundant | awk '/^>/{print $2}' > temp-geolocation-\!cn.txt - diff ./reject-need-to-remove.txt ./reject-list-without-redundant | awk '/^>/{print $2}' > temp-category-ads-all.txt + wget https://github.com/DustinWin/clash_singbox-tools/releases/download/sing-box/sing-box-release-linux-amd64v3.tar.gz -O - | tar -zxf - -C ./tools/ + mv -f ./tools/CrashCore ./tools/sing-box - - name: Write lists to data directory + - name: Generate `sing-box` rule_set(compatible) run: | - cat temp-cn.txt | sort --ignore-case -u | perl -ne '/^((?=^.{1,255})[a-zA-Z0-9][-_a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-_a-zA-Z0-9]{0,62})*)/ && print "$1\n"' > ./community/data/cn - cat temp-cn.txt | sort --ignore-case -u | perl -ne 'print if not /^((?=^.{3,255})[a-zA-Z0-9][-_a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-_a-zA-Z0-9]{0,62})+)/' > direct-tld-list.txt - cat temp-geolocation-\!cn.txt | sort --ignore-case -u | perl -ne '/^((?=^.{1,255})[a-zA-Z0-9][-_a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-_a-zA-Z0-9]{0,62})*)/ && print "$1\n"' > ./community/data/geolocation-\!cn - cat temp-geolocation-\!cn.txt | sort --ignore-case -u | perl -ne 'print if not /^((?=^.{3,255})[a-zA-Z0-9][-_a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-_a-zA-Z0-9]{0,62})+)/' > proxy-tld-list.txt - cat temp-category-ads-all.txt | sort --ignore-case -u | perl -ne '/^((?=^.{1,255})[a-zA-Z0-9][-_a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-_a-zA-Z0-9]{0,62})*)/ && print "$1\n"' > ./community/data/category-ads-all - cat temp-category-ads-all.txt | sort --ignore-case -u | perl -ne 'print if not /^((?=^.{3,255})[a-zA-Z0-9][-_a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-_a-zA-Z0-9]{0,62})+)/' > reject-tld-list.txt + cd ./tools/ + chmod +x ./convert_compatible.sh && ./convert_compatible.sh + rm -rf ./sing-box* ./rules* + mv -f ./*.json ./*.srs ../sing-box-ruleset-compatible/ - - name: Add `full`, `regexp` and `keyword` type of rules back into "cn", "geolocation-!cn" and "category-ads-all" list + - name: Release and upload `clash` assets + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + release_name: clash + tag: clash + overwrite: true + body: | + [Clash](https://github.com/Dreamacro/clash) 规则集文件(包含 .dat、.mmdb 和 .metadb 文件) + 规则集文件文件更新于 ${{ env.update_version }} + file_glob: true + file: ./clash/* + + - name: Release and upload `clash-ruleset` assets + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + release_name: clash-ruleset + tag: clash-ruleset + overwrite: true + body: "Clash ruleset 规则集文件,包含 .yaml、.list 和 .mrs 格式" + file_glob: true + file: ./clash-ruleset/* + + - name: Commit and push `clash-ruleset` branch run: | - [ -f "direct-reserve.txt" ] && cat direct-reserve.txt >> ./community/data/cn - [ -f "proxy-reserve.txt" ] && cat proxy-reserve.txt >> ./community/data/geolocation-\!cn - [ -f "reject-reserve.txt" ] && cat reject-reserve.txt >> ./community/data/category-ads-all - cp ./community/data/cn direct-list.txt - cp ./community/data/geolocation-\!cn proxy-list.txt - cp ./community/data/category-ads-all reject-list.txt + cd ./clash-ruleset/ || exit 1 + git init + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git checkout -b clash-ruleset + git add . && git commit -m "Clash rule-set 规则集文件更新于 ${update_version}" + git remote add origin "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}" + git push -f -u origin clash-ruleset - - name: Create `china-list`、`google-cn`、`apple-cn`、`gfw`、`greatfire` lists + - name: Release and upload `sing-box` assets + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + release_name: sing-box + tag: sing-box + overwrite: true + body: | + [sing-box](https://github.com/SagerNet/sing-box) 规则集文件(包含 .db 文件) + 规则集文件更新于 ${{ env.update_version }} + file_glob: true + file: ./sing-box/* + + - name: Release and upload `sing-box-ruleset` assets + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + release_name: sing-box-ruleset + tag: sing-box-ruleset + overwrite: true + body: "sing-box ruleset 规则集文件,包含 .srs 和 .json 格式" + file_glob: true + file: ./sing-box-ruleset/* + + - name: Commit and push `sing-box-ruleset` branch run: | - curl -sSL $CHINA_DOMAINS_URL | perl -ne '/^server=\/([^\/]+)\// && print "$1\n"' > ./community/data/china-list - curl -sSL $CHINA_DOMAINS_URL | perl -ne '/^server=\/([^\/]+)\// && print "$1\n"' > china-list.txt - curl -sSL $GOOGLE_DOMAINS_URL | perl -ne '/^server=\/([^\/]+)\// && print "full:$1\n"' > ./community/data/google-cn - curl -sSL $GOOGLE_DOMAINS_URL | perl -ne '/^server=\/([^\/]+)\// && print "full:$1\n"' > google-cn.txt - curl -sSL $APPLE_DOMAINS_URL | perl -ne '/^server=\/([^\/]+)\// && print "full:$1\n"' > ./community/data/apple-cn - curl -sSL $APPLE_DOMAINS_URL | perl -ne '/^server=\/([^\/]+)\// && print "full:$1\n"' > apple-cn.txt - cat ./gfwlist2dnsmasq/temp-gfwlist.txt | perl -ne '/^((?=^.{3,255})[a-zA-Z0-9][-_a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-_a-zA-Z0-9]{0,62})+)/ && print "$1\n"' >> ./community/data/gfw - cat ./community/data/gfw | sort --ignore-case -u > gfw.txt - cat ./community/data/greatfire | sort --ignore-case -u > greatfire.txt - curl -sSL $WIN_SPY | grep "0.0.0.0" | awk '{print $2}' > ./community/data/win-spy - curl -sSL $WIN_SPY | grep "0.0.0.0" | awk '{print $2}' > win-spy.txt - curl -sSL $WIN_UPDATE | grep "0.0.0.0" | awk '{print $2}' > ./community/data/win-update - curl -sSL $WIN_UPDATE | grep "0.0.0.0" | awk '{print $2}' > win-update.txt - curl -sSL $WIN_EXTRA | grep "0.0.0.0" | awk '{print $2}' > ./community/data/win-extra - curl -sSL $WIN_EXTRA | grep "0.0.0.0" | awk '{print $2}' > win-extra.txt - - - name: Build geosite.dat file - run: | - cd custom || exit 1 - go run ./ --datapath=../community/data - - - name: Move and zip files and generate sha256 hash - run: | - install -Dp ./geoip.dat ./publish/geoip.dat - install -Dp ./geoip.dat.sha256sum ./publish/geoip.dat.sha256sum - install -Dp ./custom/publish/geosite.dat ./publish/geosite.dat - install -p {proxy,direct,reject}-tld-list.txt ./publish/ - install -p {proxy,direct,reject}-list.txt ./publish/ - install -p {china-list,apple-cn,google-cn,gfw,greatfire,win-spy,win-update,win-extra}.txt ./publish/ - cd ./publish || exit 1 - zip rules.zip {proxy,direct,reject}-list.txt geoip.dat geosite.dat - sha256sum geosite.dat > geosite.dat.sha256sum - sha256sum rules.zip > rules.zip.sha256sum - - - name: Release and upload assets + cd ./sing-box-ruleset/ || exit 1 + git init + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git checkout -b sing-box-ruleset + git add . && git commit -m "sing-box rule_set 规则集文件更新于 ${update_version}" + git remote add origin "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}" + git push -f -u origin sing-box-ruleset + + - name: Release and upload `sing-box-ruleset-compatible` assets uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} - release_name: ${{ env.RELEASE_NAME }} - tag: ${{ env.TAG_NAME }} + release_name: sing-box-ruleset-compatible + tag: sing-box-ruleset-compatible + overwrite: true + body: "sing-box ruleset 规则集文件,包含 .srs 和 .json 格式" file_glob: true - file: ./publish/* + file: ./sing-box-ruleset-compatible/* - - name: Git push assets to "release" branch + - name: Commit and push `sing-box-ruleset-compatible` branch run: | - cd publish || exit 1 + cd ./sing-box-ruleset-compatible/ || exit 1 git init + git config --local user.email "github-actions[bot]@users.noreply.github.com" git config --local user.name "github-actions[bot]" - git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" - git checkout -b release - git add . - git commit -m "${{ env.RELEASE_NAME }}" + git checkout -b sing-box-ruleset-compatible + git add . && git commit -m "sing-box rule_set 规则集文件更新于 ${update_version}" git remote add origin "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}" - git push -f -u origin release + git push -f -u origin sing-box-ruleset-compatible - - name: Purge jsdelivr CDN + - name: Purge jsDelivr CDN run: | - cd publish || exit 1 + cd ./clash/ || exit 1 for file in $(ls); do - curl -i "https://purge.jsdelivr.net/gh/${{ github.repository }}@release/${file}" + curl -i "https://purge.jsdelivr.net/gh/${{ github.repository }}@clash/${file}" done + cd ../sing-box/ || exit 1 + for file in $(ls); do + curl -i "https://purge.jsdelivr.net/gh/${{ github.repository }}@sing-box/${file}" + done + cd ../clash-ruleset/ || exit 1 + for file in $(ls); do + curl -i "https://purge.jsdelivr.net/gh/${{ github.repository }}@clash-ruleset/${file}" + done + cd ../sing-box-ruleset/ || exit 1 + for file in $(ls); do + curl -i "https://purge.jsdelivr.net/gh/${{ github.repository }}@sing-box-ruleset/${file}" + done + cd ../sing-box-ruleset-compatible/ || exit 1 + for file in $(ls); do + curl -i "https://purge.jsdelivr.net/gh/${{ github.repository }}@sing-box-ruleset-compatible/${file}" + done + + - name: Delete old workflow runs + uses: Mattraks/delete-workflow-runs@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + repository: ${{ github.repository }} + retain_days: 3 + keep_minimum_runs: 1 \ No newline at end of file diff --git a/README.md b/README.md index 8db96c95c47..f678ec5cd20 100644 --- a/README.md +++ b/README.md @@ -1,488 +1,742 @@ -# 简介 - -[**V2Ray**](https://github.com/v2fly/v2ray-core) 路由规则文件加强版,可代替 V2Ray 官方 `geoip.dat` 和 `geosite.dat`,适用于 [V2Ray](https://github.com/v2fly/v2ray-core)、[Xray-core](https://github.com/XTLS/Xray-core)、[mihomo](https://github.com/MetaCubeX/mihomo/tree/Meta)、[hysteria](https://github.com/apernet/hysteria)、[Trojan-Go](https://github.com/p4gefau1t/trojan-go)、[leaf](https://github.com/eycorsican/leaf)。使用 GitHub Actions 北京时间每天早上 6 点自动构建,保证规则最新。 - -## 规则文件生成方式 - -### geoip.dat - -- 通过仓库 [@Loyalsoldier/geoip](https://github.com/Loyalsoldier/geoip) 生成 -- 默认使用 [MaxMind GeoLite2 Country CSV 数据](https://github.com/Loyalsoldier/geoip/blob/release/GeoLite2-Country-CSV.zip)生成各个国家和地区的 GeoIP 文件。所有可供使用的国家和地区 geoip 类别(如 `geoip:cn`,两位英文字母表示国家或地区),请查看:[https://www.iban.com/country-codes](https://www.iban.com/country-codes) -- 中国大陆 (`geoip:cn`) IPv4 地址数据融合了 [IPIP.net](https://github.com/17mon/china_ip_list/blob/master/china_ip_list.txt) 和 [@gaoyifan/china-operator-ip](https://github.com/gaoyifan/china-operator-ip/blob/ip-lists/china.txt) -- 中国大陆 (`geoip:cn`) IPv6 地址数据融合了 MaxMind GeoLite2 和 [@gaoyifan/china-operator-ip](https://github.com/gaoyifan/china-operator-ip/blob/ip-lists/china6.txt) -- 新增类别(方便有特殊需求的用户使用): - - `geoip:cloudflare` - - `geoip:cloudfront` - - `geoip:facebook` - - `geoip:fastly` - - `geoip:google` - - `geoip:netflix` - - `geoip:telegram` - - `geoip:twitter` - -> 希望定制 `geoip.dat` 文件?需要适用于其他代理软件的 GeoIP 格式文件?查看项目 [@Loyalsoldier/geoip](https://github.com/Loyalsoldier/geoip)。 - -### geosite.dat - -- 基于 [@v2fly/domain-list-community/data](https://github.com/v2fly/domain-list-community/tree/master/data) 数据,通过仓库 [@Loyalsoldier/domain-list-custom](https://github.com/Loyalsoldier/domain-list-custom) 生成 -- **加入大量中国大陆域名、Apple 域名和 Google 域名**: - - [@felixonmars/dnsmasq-china-list/accelerated-domains.china.conf](https://github.com/felixonmars/dnsmasq-china-list/blob/master/accelerated-domains.china.conf) 加入到 `geosite:china-list` 和 `geosite:cn` 类别中 - - [@felixonmars/dnsmasq-china-list/apple.china.conf](https://github.com/felixonmars/dnsmasq-china-list/blob/master/apple.china.conf) 加入到 `geosite:geolocation-!cn` 类别中(如希望本文件中的 Apple 域名直连,请参考下面 [geosite 的 Routing 配置方式](https://github.com/Loyalsoldier/v2ray-rules-dat#geositedat-1)) - - [@felixonmars/dnsmasq-china-list/google.china.conf](https://github.com/felixonmars/dnsmasq-china-list/blob/master/google.china.conf) 加入到 `geosite:geolocation-!cn` 类别中(如希望本文件中的 Google 域名直连,请参考下面 [geosite 的 Routing 配置方式](https://github.com/Loyalsoldier/v2ray-rules-dat#geositedat-1)) -- **加入 GFWList 域名**: - - 基于 [@gfwlist/gfwlist](https://github.com/gfwlist/gfwlist) 数据,通过仓库 [@cokebar/gfwlist2dnsmasq](https://github.com/cokebar/gfwlist2dnsmasq) 生成 - - 加入到 `geosite:gfw` 类别中,供习惯于 PAC 模式并希望使用 [GFWList](https://github.com/gfwlist/gfwlist) 的用户使用 - - 同时加入到 `geosite:geolocation-!cn` 类别中 -- **加入 EasyList 和 EasyListChina 广告域名**:通过 [@AdblockPlus/EasylistChina+Easylist.txt](https://easylist-downloads.adblockplus.org/easylistchina+easylist.txt) 获取并加入到 `geosite:category-ads-all` 类别中 -- **加入 AdGuard DNS Filter 广告域名**:通过 [@AdGuard/DNS-filter](https://kb.adguard.com/en/general/adguard-ad-filters#dns-filter) 获取并加入到 `geosite:category-ads-all` 类别中 -- **加入 Peter Lowe 广告和隐私跟踪域名**:通过 [@PeterLowe/adservers](https://pgl.yoyo.org/adservers) 获取并加入到 `geosite:category-ads-all` 类别中 -- **加入 Dan Pollock 广告域名**:通过 [@DanPollock/hosts](https://someonewhocares.org/hosts) 获取并加入到 `geosite:category-ads-all` 类别中 -- **加入 Windows 操作系统相关的系统升级和隐私跟踪域名**: - - 基于 [@crazy-max/WindowsSpyBlocker](https://github.com/crazy-max/WindowsSpyBlocker/tree/master/data/hosts) 数据 - - [**慎用**] Windows 操作系统使用的隐私跟踪域名 [@crazy-max/WindowsSpyBlocker/hosts/spy.txt](https://github.com/crazy-max/WindowsSpyBlocker/blob/master/data/hosts/spy.txt) 加入到 `geosite:win-spy` 类别中 - - [**慎用**] Windows 操作系统使用的系统升级域名 [@crazy-max/WindowsSpyBlocker/hosts/update.txt](https://github.com/crazy-max/WindowsSpyBlocker/blob/master/data/hosts/update.txt) 加入到 `geosite:win-update` 类别中 - - [**慎用**] Windows 操作系统附加的隐私跟踪域名 [@crazy-max/WindowsSpyBlocker/hosts/extra.txt](https://github.com/crazy-max/WindowsSpyBlocker/blob/master/data/hosts/extra.txt) 加入到 `geosite:win-extra` 类别中 - - 关于这三个类别的使用方式,请参考下面 [geosite 的 Routing 配置方式](https://github.com/Loyalsoldier/v2ray-rules-dat#geositedat-1) -- **可添加自定义直连、代理和广告域名**:由于上游域名列表更新缓慢或缺失某些域名,所以引入**需要添加的域名**列表。[`hidden 分支`](https://github.com/Loyalsoldier/v2ray-rules-dat/tree/hidden)里的三个文件 `direct.txt`、`proxy.txt` 和 `reject.txt`,分别存放自定义的需要添加的直连、代理、广告域名,最终分别加入到 `geosite:cn`、`geosite:geolocation-!cn` 和 `geosite:category-ads-all` 类别中 -- **可移除自定义直连、代理和广告域名**:由于上游域名列表存在需要被移除的域名,所以引入**需要移除的域名**列表。[`hidden 分支`](https://github.com/Loyalsoldier/v2ray-rules-dat/tree/hidden)里的三个文件 `direct-need-to-remove.txt`、`proxy-need-to-remove.txt` 和 `reject-need-to-remove.txt`,分别存放自定义的需要从 `direct-list`(直连域名列表)、`proxy-list`(代理域名列表)和 `reject-list`(广告域名列表) 移除的域名 - -## 规则文件下载地址 - -> 如果无法访问域名 `raw.githubusercontent.com`,可以使用第二个地址 `cdn.jsdelivr.net`。 -> 如果无法访问域名 `cdn.jsdelivr.net`,可以将其替换为 `fastly.jsdelivr.net`。 -> -> *.sha256sum 为校验文件。 - -- **geoip.dat**: - - [https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat](https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat) - - [https://cdn.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/geoip.dat](https://cdn.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/geoip.dat) -- **geosite.dat**: - - [https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat](https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat) - - [https://cdn.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/geosite.dat](https://cdn.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/geosite.dat) -- **直连域名列表 direct-list.txt**: - - [https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/direct-list.txt](https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/direct-list.txt) - - [https://cdn.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/direct-list.txt](https://cdn.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/direct-list.txt) -- **代理域名列表 proxy-list.txt**: - - [https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/proxy-list.txt](https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/proxy-list.txt) - - [https://cdn.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/proxy-list.txt](https://cdn.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/proxy-list.txt) -- **广告域名列表 reject-list.txt**: - - [https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/reject-list.txt](https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/reject-list.txt) - - [https://cdn.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/reject-list.txt](https://cdn.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/reject-list.txt) -- **@felixonmars/dnsmasq-china-list 仓库收集的在中国大陆可直连的域名列表 china-list.txt**: - - [https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/china-list.txt](https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/china-list.txt) - - [https://cdn.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/china-list.txt](https://cdn.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/china-list.txt) -- **Apple 在中国大陆可直连的域名列表 apple-cn.txt**: - - [https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/apple-cn.txt](https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/apple-cn.txt) - - [https://cdn.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/apple-cn.txt](https://cdn.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/apple-cn.txt) -- **Google 在中国大陆可直连的域名列表 google-cn.txt**: - - [https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/google-cn.txt](https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/google-cn.txt) - - [https://cdn.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/google-cn.txt](https://cdn.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/google-cn.txt) -- **GFWList 域名列表 gfw.txt**: - - [https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/gfw.txt](https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/gfw.txt) - - [https://cdn.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/gfw.txt](https://cdn.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/gfw.txt) -- **Windows 操作系统使用的隐私跟踪域名列表 win-spy.txt**: - - [https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/win-spy.txt](https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/win-spy.txt) - - [https://cdn.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/win-spy.txt](https://cdn.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/win-spy.txt) -- **Windows 操作系统使用的系统升级域名列表 win-update.txt**: - - [https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/win-update.txt](https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/win-update.txt) - - [https://cdn.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/win-update.txt](https://cdn.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/win-update.txt) -- **Windows 操作系统使用的附加隐私跟踪域名列表 win-extra.txt**: - - [https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/win-extra.txt](https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/win-extra.txt) - - [https://cdn.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/win-extra.txt](https://cdn.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/win-extra.txt) - -## 规则文件使用方式 - -### geoip.dat - +# 注:单独给 sing-box v1.9.0 版本的内核生成了[规则集](https://github.com/DustinWin/ruleset_geodata/tree/sing-box-ruleset-compatible) + +# 一、 geodata 规则集文件说明 +## 1. 文件类型 +① Clash geodata 规则集文件,包括:geosite.dat、geoip.dat、Country.mmdb 和 geoip.metadb、ASN.mmdb(仅限 [mihomo 内核](https://github.com/MetaCubeX/mihomo))等 +② [sing-box](https://github.com/SagerNet/sing-box) geodata 规则集文件,包括:geosite.db 和 geoip.db 等 +## 2. 数据源 +① 每天凌晨 3 点(北京时间 UTC+8)自动构建,根据 [Loyalsoldier/v2ray-rules-dat](https://github.com/Loyalsoldier/v2ray-rules-dat) 和 [Loyalsoldier/geoip](https://github.com/Loyalsoldier/geoip) 进行深度定制,可点击查看包含的[域名列表](https://github.com/DustinWin/domain-list-custom/tree/domains)和 [IP 段列表](https://github.com/DustinWin/geoip/tree/ips) +② `geosite,fakeip-filter,📌 fakeip 过滤` 源采用 [ShellCrash/public/fake_ip_filter.list](https://github.com/juewuy/ShellCrash/blob/dev/public/fake_ip_filter.list)(搭载 mihomo 内核或 [sing-box PuerNya 版内核](https://github.com/PuerNya/sing-box/tree/building)时,可使该规则集内的域名走 realip) +③ `geosite,private,🔒 私有网络` 源采用 [blackmatrix7/ios_rule_script/Lan](https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash/Lan)(仅域名)和 [TrackersList](https://github.com/XIU2/TrackersListCollection/blob/master/all.txt)(仅域名)组合,并添加主流 [Clash dashboard 在线面板](https://github.com/DustinWin/clash_singbox-tools/tree/main/Clash-dashboard)域名(`clash.metacubex.one`、`yacd.haishan.me`、`yacd.metacubex.one`、`d.metacubex.one`、`metacubex.github.io` 和 `metacubexd.pages.dev`) +④ `geosite,ads,🛑 广告拦截` 源采用 [privacy-protection-tools/anti-AD](https://github.com/privacy-protection-tools/anti-AD) +⑤ `geosite,microsoft-cn,🪟 微软服务` 源采用 [v2fly/domain-list-community/microsoft@cn](https://github.com/v2fly/domain-list-community/blob/master/data/microsoft) +⑥ `geosite,apple-cn,🍎 苹果服务` 源采用 [v2fly/domain-list-community/apple@cn](https://github.com/v2fly/domain-list-community/blob/master/data/apple) +⑦ `geosite,google-cn,🇬 谷歌服务` 源采用 [v2fly/domain-list-community/google@cn](https://github.com/v2fly/domain-list-community/blob/master/data/google) +⑧ `geosite,games-cn,🎮 游戏服务` 源采用 [v2fly/domain-list-community/category-games@cn](https://github.com/v2fly/domain-list-community/blob/master/data/category-games)、[blackmatrix7/ios_rule_script/SteamCN](https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash/SteamCN) 和 [blackmatrix7/ios_rule_script/GameDownloadCN](https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash/Game/GameDownloadCN) 组合 +⑨ `geosite,netflix,🎥 奈飞视频` 源采用 [blackmatrix7/ios_rule_script/Netflix](https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash/Netflix) +⑩ `geosite,disney,📽️ 迪士尼+` 源采用 [blackmatrix7/ios_rule_script/Disney](https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash/Disney) +⑪ `geosite,max,🎞️ Max` 源采用 [blackmatrix7/ios_rule_script/HBO](https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash/HBO) +⑫ `geosite,primevideo,🎬 Prime Video` 源采用 [blackmatrix7/ios_rule_script/PrimeVideo](https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash/PrimeVideo) +⑬ `geosite,appletv,🍎 Apple TV+` 源采用 [blackmatrix7/ios_rule_script/AppleTV](https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash/AppleTV) +⑭ `geosite,youtube,📹 油管视频` 源采用 [blackmatrix7/ios_rule_script/YouTube](https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash/YouTube) +⑮ `geosite,tiktok,🎵 TikTok` 源采用 [blackmatrix7/ios_rule_script/TikTok](https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash/TikTok) +⑯ `geosite,bilibili,📺 哔哩哔哩` 源采用 [blackmatrix7/ios_rule_script/BiliBili](https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash/BiliBili) +⑰ `geosite,ai,🤖 人工智能` 源采用 [blackmatrix7/ios_rule_script/OpenAI](https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash/OpenAI)、[blackmatrix7/ios_rule_script/Copilot](https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash/Copilot)、[blackmatrix7/ios_rule_script/Gemini](https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash/Gemini) 和 [blackmatrix7/ios_rule_script/Claude](https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash/Claude) 组合 +⑱ `geosite,networktest,📈 网络测试` 源采用 [blackmatrix7/ios_rule_script/Speedtest](https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash/Speedtest) 和 IPv6 测试域名关键字(`keyword`,包括:`ipv6-test`、`test-ipv6`、`ipv6test` 和 `testipv6`)组合 +⑲ `geosite,proxy,🪜 代理域名` 源采用 [v2fly/domain-list-community/geolocation-!cn](https://github.com/v2fly/domain-list-community/blob/master/data/geolocation-!cn)(删除了带有 `@cn` 和 `@ads` 的域名,并新增了 [gfwlist](https://github.com/gfwlist/gfwlist) 和 v2fly/domain-list-community/cn 中带有 `@!cn` 的域名)和 [blackmatrix7/ios_rule_script/Global](https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash/Global) 组合 +⑳ `geosite,cn,🇨🇳 直连域名` 源采用 [v2fly/domain-list-community/cn](https://github.com/v2fly/domain-list-community/blob/master/data/cn)(删除了带有 `@!cn` 和 `@ads` 的域名,并新增了 v2fly/domain-list-community/geolocation-!cn 中带有 `@cn` 的域名)和 [blackmatrix7/ios_rule_script/ChinaMax](https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash/ChinaMax)(仅域名) +㉑ `geoip,netflix,🎥 奈飞视频` 源采用 [GeoLite2-ASN-CSV/Netflix](https://dev.maxmind.com/geoip/geolite2-free-geolocation-data) 和 [blackmatrix7/ios_rule_script/Netflix](https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash/Netflix)(Netflix_IP.txt)组合 +㉒ `geoip,telegram,📲 电报消息` 源采用 [GeoLite2-ASN-CSV/Telegram](https://dev.maxmind.com/geoip/geolite2-free-geolocation-data) 和 [Telegram IP 段](https://core.telegram.org/resources/cidr.txt)组合 +㉓ `geoip,private,🔒 私有网络` 源采用 [DustinWin/geoip/config.json](https://github.com/DustinWin/geoip/blob/master/config.json) 中的 `input.type:private` 和 [TrackersList](https://github.com/XIU2/TrackersListCollection/blob/master/all.txt)(仅 IP)组合 +㉔ `geoip,cn,🇨🇳 直连 IP` 源采用 [GeoLite2-Country-CSV/CN](https://dev.maxmind.com/geoip/geolite2-free-geolocation-data)、[17mon/china_ip_list](https://github.com/17mon/china_ip_list)、[gaoyifan/china-operator-ip](https://github.com/gaoyifan/china-operator-ip)、[APNIC/CN](http://ftp.apnic.net/stats/apnic/delegated-apnic-latest) 和 [blackmatrix7/ios_rule_script/ChinaASN](https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Surge/ChinaASN) 组合 +## 3. 文件下载 +**规则集文件包含的规则和下载地址对应关系如下表:** + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
规则集文件名称包含规则GitHub 源jsDelivr 源GitHub Proxy 源
geosite-all.datfakeip-filterprivateadsmicrosoft-cnapple-cngoogle-cngames-cnnetflixdisneymaxprimevideoappletvyoutubetiktokbilibiliainetworktestproxycn点此下载点此下载点此下载
geosite-all.dbfakeip-filterprivateadsmicrosoft-cnapple-cngoogle-cngames-cnnetflixdisneymaxprimevideoappletvyoutubetiktokbilibiliainetworktestproxycn点此下载点此下载点此下载
geosite-all-lite.datfakeip-filterprivateadsmicrosoft-cnapple-cngoogle-cngames-cnnetflixdisneymaxprimevideoappletvyoutubetiktokbilibiliainetworktestproxycn点此下载点此下载点此下载
geosite-all-lite.dbfakeip-filterprivateadsmicrosoft-cnapple-cngoogle-cngames-cnnetflixdisneymaxprimevideoappletvyoutubetiktokbilibiliainetworktestproxycn点此下载点此下载点此下载
geosite.datfakeip-filterprivateadsmicrosoft-cnapple-cngoogle-cngames-cnainetworktestproxycn点此下载点此下载点此下载
geosite.dbfakeip-filterprivateadsmicrosoft-cnapple-cngoogle-cngames-cnainetworktestproxycn点此下载点此下载点此下载
geosite-lite.datfakeip-filterprivateadsmicrosoft-cnapple-cngoogle-cngames-cnainetworktestproxycn点此下载点此下载点此下载
geosite-lite.dbfakeip-filterprivateadsmicrosoft-cnapple-cngoogle-cngames-cnainetworktestproxycn点此下载点此下载点此下载
geoip-all.dat点此查看点此下载点此下载点此下载
Country-all.mmdb点此下载点此下载点此下载
geoip-all.metadb点此下载点此下载点此下载
geoip-all.db点此下载点此下载点此下载
Country-ASN-all.mmdbcloudflarecloudfrontfacebookfastlygooglenetflixtelegramtwitter,具体可点此查看点此下载点此下载点此下载
geoip.datnetflixtelegramprivatecn点此下载点此下载点此下载
Country.mmdb点此下载点此下载点此下载
geoip.metadb点此下载点此下载点此下载
geoip.db点此下载点此下载点此下载
geoip-lite.datnetflixtelegramprivatecn点此下载点此下载点此下载
Country-lite.mmdb点此下载点此下载点此下载
geoip-lite.metadb点此下载点此下载点此下载
geoip-lite.db点此下载点此下载点此下载
Country-ASN.mmdbnetflixtelegramprivatecn,具体可点此查看点此下载点此下载点此下载
+ +## 4. 文件导入
- 点击查看在 V2RayXray-core 中的使用方法 -
-

需要先下载 geoip.dat 格式文件,并放置在程序目录内。

- -```json -"routing": { - "rules": [ - { - "type": "field", - "outboundTag": "Direct", - "ip": [ - "geoip:cn", - "geoip:private", - "ext:cn.dat:cn", - "ext:private.dat:private", - "ext:geoip-only-cn-private.dat:cn", - "ext:geoip-only-cn-private.dat:private" - ] - }, - { - "type": "field", - "outboundTag": "Proxy", - "ip": [ - "geoip:us", - "geoip:jp", - "geoip:facebook", - "geoip:telegram", - "ext:geoip-asn.dat:facebook", - "ext:geoip-asn.dat:telegram" - ] - } - ] -} -``` -
+① 导入到 Linux 端(以 ShellCrash 导入 geosite.dat、geoip.dat、Country.mmdb、geoip.metadb、ASN.mmdb 和 geosite.db、geoip.db 为例) -
- 点击查看在 mihomo 中的使用方法 - -```yaml -geodata-mode: true -geox-url: - geoip: "https://cdn.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/geoip.dat" +连接 SSH 后执行如下命令: +``` +# 适用于 Clash 内核 +curl -o $CRASHDIR/GeoSite.dat -L https://cdn.jsdelivr.net/gh/DustinWin/ruleset_geodata@clash/geosite.dat +curl -o $CRASHDIR/GeoIP.dat -L https://cdn.jsdelivr.net/gh/DustinWin/ruleset_geodata@clash/geoip.dat +curl -o $CRASHDIR/Country.mmdb -L https://cdn.jsdelivr.net/gh/DustinWin/ruleset_geodata@clash/Country.mmdb +# 适用于 mihomo 内核 +curl -o $CRASHDIR/geoip.metadb -L https://cdn.jsdelivr.net/gh/DustinWin/ruleset_geodata@clash/geoip.metadb +curl -o $CRASHDIR/ASN.mmdb -L https://cdn.jsdelivr.net/gh/DustinWin/ruleset_geodata@clash/Country-ASN.mmdb +# 适用于 sing-box 内核 +curl -o $CRASHDIR/geosite.db -L https://cdn.jsdelivr.net/gh/DustinWin/ruleset_geodata@sing-box/geosite.db +curl -o $CRASHDIR/geoip.db -L https://cdn.jsdelivr.net/gh/DustinWin/ruleset_geodata@sing-box/geoip.db +$CRASHDIR/start.sh restart ```
-
- 点击查看在 hysteria 中的使用方法 -
-

需要先下载 geoip.dat 格式文件,并放置在 hysteria 程序目录内。

+② 导入到 Windows 端(以 Clash Verge 导入 geosite.dat、geoip.dat、Country.mmdb、geoip.metadb 和 ASN.mmdb 为例) +以管理员身份运行 CMD 命令提示符,执行如下命令: ``` -direct(geoip:cn) -proxy(geoip:telegram) -proxy(geoip:us) +taskkill /f /t /im "Clash Verge*" +taskkill /f /t /im clash-verge* +taskkill /f /t /im verge-mihomo* +curl -o %APPDATA%\io.github.clash-verge-rev.clash-verge-rev\geosite.dat -L https://cdn.jsdelivr.net/gh/DustinWin/ruleset_geodata@clash/geosite.dat +curl -o %APPDATA%\io.github.clash-verge-rev.clash-verge-rev\geoip.dat -L https://cdn.jsdelivr.net/gh/DustinWin/ruleset_geodata@clash/geoip.dat +curl -o %APPDATA%\io.github.clash-verge-rev.clash-verge-rev\Country.mmdb -L https://cdn.jsdelivr.net/gh/DustinWin/ruleset_geodata@clash/Country.mmdb +curl -o %APPDATA%\io.github.clash-verge-rev.clash-verge-rev\geoip.metadb -L https://cdn.jsdelivr.net/gh/DustinWin/ruleset_geodata@clash/geoip.metadb +curl -o %APPDATA%\io.github.clash-verge-rev.clash-verge-rev\ASN.mmdb -L https://cdn.jsdelivr.net/gh/DustinWin/ruleset_geodata@clash/Country-ASN.mmdb ```
+# 二、 ruleset 规则集文件说明 +## 1. 文件类型 +① Clash ruleset 规则集文件,格式为 `.yaml`(`format: yaml`)、`.list`(`format: text`) 和 `.mrs`(`format: mrs`) +② [sing-box](https://github.com/SagerNet/sing-box) ruleset 规则集文件,格式有 `.srs`(`"format": "binary"`)和 `.json`(`"format": "source"`) +## 2. 数据源 +① 每天凌晨 3 点(北京时间 UTC+8)自动构建,根据 [Loyalsoldier/clash-rules](https://github.com/Loyalsoldier/clash-rules) 和 [Loyalsoldier/geoip](https://github.com/Loyalsoldier/geoip) 进行深度定制,可点击查看包含的[域名列表](https://github.com/DustinWin/domain-list-custom/tree/domains)和 [IP 段列表](https://github.com/DustinWin/geoip/tree/ips) +② `rule-set,fakeip-filter,📌 fakeip 过滤` 源采用 [ShellCrash/public/fake_ip_filter.list](https://github.com/juewuy/ShellCrash/blob/dev/public/fake_ip_filter.list)(搭载 mihomo 内核或 sing-box PuerNya 版内核时,可使该规则集内的域名走 realip) +③ `rule-set,applications,🖥️ 直连软件` 源采用 [blackmatrix7/ios_rule_script/Download](https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash/Download) 和 [Loyalsoldier/clash-rules/applications.txt](https://github.com/Loyalsoldier/clash-rules/blob/release/applications.txt) 组合 +④ `rule-set,private,🔒 私有网络` 源采用 [blackmatrix7/ios_rule_script/Lan](https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash/Lan)(仅域名)和 [TrackersList](https://github.com/XIU2/TrackersListCollection/blob/master/all.txt)(仅域名)组合,并添加主流 [Clash dashboard 在线面板](https://github.com/DustinWin/clash_singbox-tools/tree/main/Clash-dashboard)域名(`clash.metacubex.one`、`yacd.haishan.me`、`yacd.metacubex.one`、`d.metacubex.one`、`metacubex.github.io` 和 `metacubexd.pages.dev`) +⑤ `rule-set,ads,🛑 广告拦截` 源采用 [privacy-protection-tools/anti-AD](https://github.com/privacy-protection-tools/anti-AD) +⑥ `rule-set,microsoft-cn,🪟 微软服务` 源采用 [v2fly/domain-list-community/microsoft@cn](https://github.com/v2fly/domain-list-community/blob/master/data/microsoft) +⑦ `rule-set,apple-cn,🍎 苹果服务` 源采用 [v2fly/domain-list-community/apple@cn](https://github.com/v2fly/domain-list-community/blob/master/data/apple) +⑧ `rule-set,google-cn,🇬 谷歌服务` 源采用 [v2fly/domain-list-community/google@cn](https://github.com/v2fly/domain-list-community/blob/master/data/google) +⑨ `rule-set,games-cn,🎮 游戏服务` 源采用 [v2fly/domain-list-community/category-games@cn](https://github.com/v2fly/domain-list-community/blob/master/data/category-games)、[blackmatrix7/ios_rule_script/SteamCN](https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash/SteamCN) 和 [blackmatrix7/ios_rule_script/GameDownloadCN](https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash/Game/GameDownloadCN) 组合 +⑩ `rule-set,netflix,🎥 奈飞视频` 源采用 [blackmatrix7/ios_rule_script/Netflix](https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash/Netflix)(仅域名) +⑪ `rule-set,disney,📽️ 迪士尼+` 源采用 [blackmatrix7/ios_rule_script/Disney](https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash/Disney) +⑫ `rule-set,max,🎞️ Max` 源采用 [blackmatrix7/ios_rule_script/HBO](https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash/HBO) +⑬ `rule-set,primevideo,🎬 Prime Video` 源采用 [blackmatrix7/ios_rule_script/PrimeVideo](https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash/PrimeVideo) +⑭ `rule-set,appletv,🍎 Apple TV+` 源采用 [blackmatrix7/ios_rule_script/AppleTV](https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash/AppleTV) +⑮ `rule-set,youtube,📹 油管视频` 源采用 [blackmatrix7/ios_rule_script/YouTube](https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash/YouTube) +⑯ `rule-set,tiktok,🎵 TikTok` 源采用 [blackmatrix7/ios_rule_script/TikTok](https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash/TikTok) +⑰ `rule-set,bilibili,📺 哔哩哔哩` 源采用 [blackmatrix7/ios_rule_script/BiliBili](https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash/BiliBili) +⑱ `rule-set,ai,🤖 人工智能` 源采用 [blackmatrix7/ios_rule_script/OpenAI](https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash/OpenAI)、[blackmatrix7/ios_rule_script/Copilot](https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash/Copilot)、[blackmatrix7/ios_rule_script/Gemini](https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash/Gemini) 和 [blackmatrix7/ios_rule_script/Claude](https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash/Claude) 组合 +⑲ `rule-set,networktest,📈 网络测试` 源采用 [blackmatrix7/ios_rule_script/Speedtest](https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash/Speedtest) 和 IPv6 测试域名关键字(`keyword`,包括:`ipv6-test`、`test-ipv6`、`ipv6test` 和 `testipv6`)组合 +⑳ `rule-set,proxy,🪜 代理域名` 源采用 [v2fly/domain-list-community/geolocation-!cn](https://github.com/v2fly/domain-list-community/blob/master/data/geolocation-!cn)(删除了带有 `@cn` 和 `@ads` 的域名,并新增了 [gfwlist](https://github.com/gfwlist/gfwlist) 和 v2fly/domain-list-community/cn 中带有 `@!cn` 的域名)和 [blackmatrix7/ios_rule_script/Global](https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash/Global) 组合 +㉑ `rule-set,cn,🇨🇳 直连域名` 源采用 [v2fly/domain-list-community/cn](https://github.com/v2fly/domain-list-community/blob/master/data/cn)(删除了带有 `@!cn` 和 `@ads` 的域名,并新增了 v2fly/domain-list-community/geolocation-!cn 中带有 `@cn` 的域名)和 [blackmatrix7/ios_rule_script/ChinaMax](https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash/ChinaMax)(仅域名) +㉒ `rule-set,netflixip,🎥 奈飞视频` 源采用 [GeoLite2-ASN-CSV/Netflix](https://dev.maxmind.com/geoip/geolite2-free-geolocation-data) 和 [blackmatrix7/ios_rule_script/Netflix](https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Clash/Netflix)(Netflix_IP.txt)组合 +㉓ `rule-set,telegramip,📲 电报消息` 源采用 [GeoLite2-ASN-CSV/Telegram](https://dev.maxmind.com/geoip/geolite2-free-geolocation-data) 和 [Telegram IP 段](https://core.telegram.org/resources/cidr.txt)组合 +㉔ `rule-set,privateip,🔒 私有网络` 源采用 [DustinWin/geoip/config.json](https://github.com/DustinWin/geoip/blob/master/config.json) 中的 `input.type:private` 和 [TrackersList](https://github.com/XIU2/TrackersListCollection/blob/master/all.txt)(仅 IP)组合 +㉕ `rule-set,cnip,🇨🇳 直连 IP` 源采用 [GeoLite2-Country-CSV/CN](https://dev.maxmind.com/geoip/geolite2-free-geolocation-data)、[17mon/china_ip_list](https://github.com/17mon/china_ip_list)、[gaoyifan/china-operator-ip](https://github.com/gaoyifan/china-operator-ip)、[APNIC/CN](http://ftp.apnic.net/stats/apnic/delegated-apnic-latest) 和 [blackmatrix7/ios_rule_script/ChinaASN](https://github.com/blackmatrix7/ios_rule_script/tree/master/rule/Surge/ChinaASN) 组合 +## 3. 文件使用
- 点击查看在 Trojan-Go 中的使用方法 -
-

需要先下载 geoip.dat 格式文件,并放置在 Trojan-Go 程序目录内。

- -```json -"router": { - "enabled": true, - "bypass": ["geoip:cn"], - "proxy": ["geoip:telegram", "geoip:us"], - "block": ["geoip:jp"], - "default_policy": "proxy", - "geoip": "./geoip.dat" -} -``` -
- -### geosite.dat - -跟 V2Ray 官方 `geosite.dat` 配置方式相同。相比官方 `geosite.dat` 文件,本项目特有的类别: - -- `geosite:china-list`:包含 [@felixonmars/dnsmasq-china-list/accelerated-domains.china.conf](https://github.com/felixonmars/dnsmasq-china-list/blob/master/accelerated-domains.china.conf) 文件里的域名,供有特殊 DNS 分流需求的用户使用。 -- `geosite:apple-cn`:包含 [@felixonmars/dnsmasq-china-list/apple.china.conf](https://github.com/felixonmars/dnsmasq-china-list/blob/master/apple.china.conf) 文件里的域名,供希望 Apple 域名直连(不走代理)的用户使用。 -- `geosite:google-cn`:包含 [@felixonmars/dnsmasq-china-list/google.china.conf](https://github.com/felixonmars/dnsmasq-china-list/blob/master/google.china.conf) 文件里的域名,供希望 Google 域名直连(不走代理)的用户使用。 -- [**慎用**]`geosite:win-spy`:包含 [@crazy-max/WindowsSpyBlocker/hosts/spy.txt](https://github.com/crazy-max/WindowsSpyBlocker/blob/master/data/hosts/spy.txt) 文件里的域名,供希望屏蔽 Windows 操作系统隐私跟踪域名的用户使用。 -- [**慎用**]`geosite:win-update`:包含 [@crazy-max/WindowsSpyBlocker/hosts/update.txt](https://github.com/crazy-max/WindowsSpyBlocker/blob/master/data/hosts/update.txt) 文件里的域名,供希望屏蔽 Windows 操作系统自动升级的用户使用。 -- [**慎用**]`geosite:win-extra`:包含 [@crazy-max/WindowsSpyBlocker/hosts/extra.txt](https://github.com/crazy-max/WindowsSpyBlocker/blob/master/data/hosts/extra.txt) 文件里的域名,供希望屏蔽 Windows 操作系统附加隐私跟踪域名的用户使用。 +① Clash 内核 -> ⚠️ 注意:在 Routing 配置中,类别越靠前(上),优先级越高,所以 `geosite:apple-cn` 和 `geosite:google-cn` 要放置在 `geosite:geolocation-!cn` 前(上)面才能生效。 - -#### 高级用法 - -v2fly/domain-list-community 项目 [data](https://github.com/v2fly/domain-list-community/tree/master/data) 目录中某些列表里的规则会被标记诸如 `@cn` 的 attribute(如下所示),意为该域名在中国大陆有接入点,可直连。 +- 注:以下只是节选,请酌情套用 ``` -steampowered.com.8686c.com @cn -steamstatic.com.8686c.com @cn -``` - -对于玩 Steam 国区游戏,想要直连的用户,可以设置类别 `geosite:steam@cn` 为直连,意为将 [steam](https://github.com/v2fly/domain-list-community/blob/master/data/steam) 列表内所有被标记了 `@cn` attribute 的规则(域名)设置为直连。同理,由于 [category-games](https://github.com/v2fly/domain-list-community/blob/master/data/category-games) 列表包含了 `steam`、`ea`、`blizzard`、`epicgames` 和 `nintendo` 等常见的游戏厂商。设置类别 `geosite:category-games@cn` 为直连,即可节省大量服务器流量。 - -> ⚠️ 注意:在 Routing 配置中,类别越靠前(上),优先级越高,所以 `geosite:category-games@cn` 等所有带有 `@cn` attribute 的规则都要放置在 `geosite:geolocation-!cn` 前(上)面才能生效。 -> -> `category-games` 列表内的规则(域名)可能会有疏漏,请留意规则命中情况。如发现遗漏,欢迎到项目 v2fly/domain-list-community 提 [issue](https://github.com/v2fly/domain-list-community/issues) 反馈。 - -#### 配置参考下面 👇👇👇 - -**白名单模式 Routing 配置方式**: - -```json -"routing": { - "rules": [ - { - "type": "field", - "outboundTag": "Reject", - "domain": ["geosite:category-ads-all"] - }, - { - "type": "field", - "outboundTag": "Direct", - "domain": [ - "geosite:private", - "geosite:apple-cn", - "geosite:google-cn", - "geosite:tld-cn", - "geosite:category-games@cn" - ] - }, - { - "type": "field", - "outboundTag": "Proxy", - "domain": ["geosite:geolocation-!cn"] - }, - { - "type": "field", - "outboundTag": "Direct", - "domain": ["geosite:cn"] - }, - { - "type": "field", - "outboundTag": "Proxy", - "network": "tcp,udp" - } - ] -} +proxy-groups: + - {name: 🚀 节点选择, type: select, proxies: [🇭🇰 香港节点, 🇹🇼 台湾节点, 🇯🇵 日本节点, 🇰🇷 韩国节点, 🇸🇬 新加坡节点, 🇺🇸 美国节点]} + - {name: 🐟 漏网之鱼, type: select, proxies: [🚀 节点选择, 🎯 全球直连]} + - {name: 📈 网络测试, type: select, proxies: [🎯 全球直连, 🇭🇰 香港节点, 🇹🇼 台湾节点, 🇯🇵 日本节点, 🇰🇷 韩国节点, 🇸🇬 新加坡节点, 🇺🇸 美国节点]} + - {name: 🤖 人工智能, type: select, proxies: [🚀 节点选择, 🇭🇰 香港节点, 🇯🇵 日本节点, 🇸🇬 新加坡节点, 🇺🇸 美国节点]} + - {name: 🎮 游戏服务, type: select, proxies: [🎯 全球直连, 🚀 节点选择]} + - {name: 🪟 微软服务, type: select, proxies: [🎯 全球直连, 🚀 节点选择]} + - {name: 🇬 谷歌服务, type: select, proxies: [🎯 全球直连, 🚀 节点选择]} + - {name: 🍎 苹果服务, type: select, proxies: [🎯 全球直连, 🚀 节点选择]} + - {name: 🎥 奈飞视频, type: select, proxies: [🚀 节点选择, 🇭🇰 香港节点, 🇯🇵 日本节点, 🇸🇬 新加坡节点]} + - {name: 📽️ 迪士尼+, type: select, proxies: [🚀 节点选择, 🇭🇰 香港节点, 🇯🇵 日本节点, 🇸🇬 新加坡节点]} + - {name: 🎞️ Max, type: select, proxies: [🚀 节点选择, 🇭🇰 香港节点, 🇯🇵 日本节点, 🇸🇬 新加坡节点]} + - {name: 🎬 Prime Video, type: select, proxies: [🚀 节点选择, 🇭🇰 香港节点, 🇯🇵 日本节点, 🇸🇬 新加坡节点]} + - {name: 🍎 Apple TV+, type: select, proxies: [🚀 节点选择, 🇭🇰 香港节点, 🇯🇵 日本节点, 🇸🇬 新加坡节点]} + - {name: 📹 油管视频, type: select, proxies: [🚀 节点选择, 🇭🇰 香港节点, 🇯🇵 日本节点, 🇸🇬 新加坡节点]} + - {name: 🎵 TikTok, type: select, proxies: [🚀 节点选择, 🇭🇰 香港节点, 🇯🇵 日本节点, 🇸🇬 新加坡节点]} + - {name: 📺 哔哩哔哩, type: select, proxies: [🎯 全球直连, 🚀 节点选择, 🇭🇰 香港节点, 🇯🇵 日本节点, 🇸🇬 新加坡节点]} + - {name: 🇨🇳 直连域名, type: select, proxies: [🎯 全球直连, 🚀 节点选择]} + - {name: 🇨🇳 直连 IP, type: select, proxies: [🎯 全球直连, 🚀 节点选择]} + - {name: 🪜 代理域名, type: select, proxies: [🚀 节点选择, 🎯 全球直连]} + - {name: 📲 电报消息, type: select, proxies: [🚀 节点选择]} + - {name: 🖥️ 直连软件, type: select, proxies: [🎯 全球直连]} + - {name: 🔒 私有网络, type: select, proxies: [🎯 全球直连]} + - {name: 🛑 广告拦截, type: select, proxies: [REJECT]} + - {name: 🎯 全球直连, type: select, proxies: [DIRECT]} + +rule-providers: + fakeip-filter: + type: http + behavior: domain + format: mrs + path: ./rules/fakeip-filter.mrs + url: "https://github.com/DustinWin/ruleset_geodata/releases/download/clash-ruleset/fakeip-filter.mrs" + interval: 86400 + + applications: + type: http + behavior: classical + format: text + path: ./rules/applications.list + url: "https://github.com/DustinWin/ruleset_geodata/releases/download/clash-ruleset/applications.list" + interval: 86400 + + private: + type: http + behavior: domain + format: mrs + path: ./rules/private.mrs + url: "https://github.com/DustinWin/ruleset_geodata/releases/download/clash-ruleset/private.mrs" + interval: 86400 + + ads: + type: http + behavior: domain + format: mrs + path: ./rules/ads.mrs + url: "https://github.com/DustinWin/ruleset_geodata/releases/download/clash-ruleset/ads.mrs" + interval: 86400 + + microsoft-cn: + type: http + behavior: domain + format: mrs + path: ./rules/microsoft-cn.mrs + url: "https://github.com/DustinWin/ruleset_geodata/releases/download/clash-ruleset/microsoft-cn.mrs" + interval: 86400 + + apple-cn: + type: http + behavior: domain + format: mrs + path: ./rules/apple-cn.mrs + url: "https://github.com/DustinWin/ruleset_geodata/releases/download/clash-ruleset/apple-cn.mrs" + interval: 86400 + + google-cn: + type: http + behavior: domain + format: mrs + path: ./rules/google-cn.mrs + url: "https://github.com/DustinWin/ruleset_geodata/releases/download/clash-ruleset/google-cn.mrs" + interval: 86400 + + games-cn: + type: http + behavior: domain + format: mrs + path: ./rules/games-cn.mrs + url: "https://github.com/DustinWin/ruleset_geodata/releases/download/clash-ruleset/games-cn.mrs" + interval: 86400 + + netflix: + type: http + behavior: domain + format: mrs + path: ./rules/netflix.mrs + url: "https://github.com/DustinWin/ruleset_geodata/releases/download/clash-ruleset/netflix.mrs" + interval: 86400 + + disney: + type: http + behavior: domain + format: mrs + path: ./rules/disney.mrs + url: "https://github.com/DustinWin/ruleset_geodata/releases/download/clash-ruleset/disney.mrs" + interval: 86400 + + max: + type: http + behavior: domain + format: mrs + path: ./rules/max.mrs + url: "https://github.com/DustinWin/ruleset_geodata/releases/download/clash-ruleset/max.mrs" + interval: 86400 + + primevideo: + type: http + behavior: domain + format: mrs + path: ./rules/primevideo.mrs + url: "https://github.com/DustinWin/ruleset_geodata/releases/download/clash-ruleset/primevideo.mrs" + interval: 86400 + + appletv: + type: http + behavior: domain + format: mrs + path: ./rules/appletv.mrs + url: "https://github.com/DustinWin/ruleset_geodata/releases/download/clash-ruleset/appletv.mrs" + interval: 86400 + + youtube: + type: http + behavior: domain + format: mrs + path: ./rules/youtube.mrs + url: "https://github.com/DustinWin/ruleset_geodata/releases/download/clash-ruleset/youtube.mrs" + interval: 86400 + + tiktok: + type: http + behavior: domain + format: mrs + path: ./rules/tiktok.mrs + url: "https://github.com/DustinWin/ruleset_geodata/releases/download/clash-ruleset/tiktok.mrs" + interval: 86400 + + bilibili: + type: http + behavior: domain + format: mrs + path: ./rules/bilibili.mrs + url: "https://github.com/DustinWin/ruleset_geodata/releases/download/clash-ruleset/bilibili.mrs" + interval: 86400 + + ai: + type: http + behavior: domain + format: mrs + path: ./rules/ai.mrs + url: "https://github.com/DustinWin/ruleset_geodata/releases/download/clash-ruleset/ai.mrs" + interval: 86400 + + networktest: + type: http + behavior: classical + format: text + path: ./rules/networktest.list + url: "https://github.com/DustinWin/ruleset_geodata/releases/download/clash-ruleset/networktest.list" + interval: 86400 + + proxy: + type: http + behavior: domain + format: mrs + path: ./rules/proxy.mrs + url: "https://github.com/DustinWin/ruleset_geodata/releases/download/clash-ruleset/proxy.mrs" + interval: 86400 + + cn: + type: http + behavior: domain + format: mrs + path: ./rules/cn.mrs + url: "https://github.com/DustinWin/ruleset_geodata/releases/download/clash-ruleset/cn.mrs" + interval: 86400 + + netflixip: + type: http + behavior: ipcidr + format: mrs + path: ./rules/netflixip.mrs + url: "https://github.com/DustinWin/ruleset_geodata/releases/download/clash-ruleset/netflixip.mrs" + interval: 86400 + + telegramip: + type: http + behavior: ipcidr + format: mrs + path: ./rules/telegramip.mrs + url: "https://github.com/DustinWin/ruleset_geodata/releases/download/clash-ruleset/telegramip.mrs" + interval: 86400 + + privateip: + type: http + behavior: ipcidr + format: mrs + path: ./rules/privateip.mrs + url: "https://github.com/DustinWin/ruleset_geodata/releases/download/clash-ruleset/privateip.mrs" + interval: 86400 + + cnip: + type: http + behavior: ipcidr + format: mrs + path: ./rules/cnip.mrs + url: "https://github.com/DustinWin/ruleset_geodata/releases/download/clash-ruleset/cnip.mrs" + interval: 86400 + +rules: + - RULE-SET,applications,🖥️ 直连软件 + - RULE-SET,private,🔒 私有网络 + - RULE-SET,ads,🛑 广告拦截 + - RULE-SET,microsoft-cn,🪟 微软服务 + - RULE-SET,apple-cn,🍎 苹果服务 + - RULE-SET,google-cn,🇬 谷歌服务 + - RULE-SET,games-cn,🎮 游戏服务 + - RULE-SET,netflix,🎥 奈飞视频 + - RULE-SET,disney,📽️ 迪士尼+ + - RULE-SET,max,🎞️ Max + - RULE-SET,primevideo,🎬 Prime Video + - RULE-SET,appletv,🍎 Apple TV+ + - RULE-SET,youtube,📹 油管视频 + - RULE-SET,tiktok,🎵 TikTok + - RULE-SET,bilibili,📺 哔哩哔哩 + - RULE-SET,ai,🤖 人工智能 + - RULE-SET,networktest,📈 网络测试 + - RULE-SET,proxy,🪜 代理域名 + - RULE-SET,cn,🇨🇳 直连域名 + - RULE-SET,netflixip,🎥 奈飞视频,no-resolve + - RULE-SET,telegramip,📲 电报消息,no-resolve + - RULE-SET,privateip,🔒 私有网络,no-resolve + - RULE-SET,cnip,🇨🇳 直连 IP ``` + +
+② sing-box 内核 -**黑名单模式 Routing 配置方式:** - -```json -"routing": { - "rules": [ - { - "type": "field", - "outboundTag": "Reject", - "domain": ["geosite:category-ads-all"] - }, - { - "type": "field", - "outboundTag": "Proxy", - "domain": ["geosite:gfw"] - }, - { - "type": "field", - "outboundTag": "Proxy", - "ip": ["geoip:telegram"] - }, - { - "type": "field", - "outboundTag": "Direct", - "network": "tcp,udp" - } - ] -} -``` +注: +- 1. 须手动新建“*ruleset*”文件夹,否则规则集文件不会保存在本地。如导入 [ShellCrash](https://github.com/juewuy/ShellCrash),可先连接 SSH 后执行命令 `mkdir -p $CRASHDIR/ruleset/` +- 2. 以下只是节选,请酌情套用 -**DNS 配置方式**: - -```json -"dns": { - "hosts": { - "dns.google": "8.8.8.8", - "dns.pub": "119.29.29.29", - "dns.alidns.com": "223.5.5.5", - "geosite:category-ads-all": "127.0.0.1" - }, - "servers": [ - { - "address": "https://1.1.1.1/dns-query", - "domains": ["geosite:geolocation-!cn"], - "expectIPs": ["geoip:!cn"] - }, - "8.8.8.8", - { - "address": "114.114.114.114", - "port": 53, - "domains": ["geosite:cn", "geosite:category-games@cn"], - "expectIPs": ["geoip:cn"], - "skipFallback": true - }, - { - "address": "localhost", - "skipFallback": true - } - ] -} ``` - -### 自用 V2Ray v4 版本客户端配置(不适用于 V2Ray v5 及更新的版本) - -注意事项: - -- 由于下面客户端配置的 DNS 使用了 `skipFallback` 选项,所以必须使用 v4.37.2 或更新版本的 [V2Ray](https://github.com/v2fly/v2ray-core/releases) -- 下面客户端配置使 V2Ray 在本机开启 SOCKS 代理(监听 1080 端口)和 HTTP 代理(监听 2080 端口),允许局域网内其他设备连接并使用代理 -- BT 流量统统直连(实测依然会有部分 BT 流量走代理,如果服务商禁止 BT 下载,请不要为下载软件设置代理) -- 最后,不命中任何路由规则的请求和流量,统统走代理 -- `outbounds` 里的第一个大括号内的配置,即为 V2Ray 代理服务的配置。请根据自身需求进行修改,并参照 V2Ray 官网配置文档中的 [配置 > Outbounds > OutboundObject](https://www.v2fly.org/config/outbounds.html#outboundobject) 部分进行补全 - -```jsonc { - "log": { - "loglevel": "warning" - }, - "dns": { - "hosts": { - "dns.google": "8.8.8.8", - "dns.pub": "119.29.29.29", - "dns.alidns.com": "223.5.5.5", - "geosite:category-ads-all": "127.0.0.1" - }, - "servers": [ + "outbounds": [ + { "tag": "🚀 节点选择", "type": "selector", "outbounds": [ "🇭🇰 香港节点", "🇹🇼 台湾节点", "🇯🇵 日本节点", "🇰🇷 韩国节点", "🇸🇬 新加坡节点", "🇺🇸 美国节点" ] }, + { "tag": "🐟 漏网之鱼", "type": "selector", "outbounds": [ "🚀 节点选择", "🎯 全球直连" ] }, + { "tag": "📈 网络测试", "type": "selector", "outbounds": [ "🎯 全球直连", "🇭🇰 香港节点", "🇹🇼 台湾节点", "🇯🇵 日本节点", "🇰🇷 韩国节点", "🇸🇬 新加坡节点", "🇺🇸 美国节点" ] }, + { "tag": "🤖 人工智能", "type": "selector", "outbounds": [ "🚀 节点选择", "🇭🇰 香港节点", "🇯🇵 日本节点", "🇸🇬 新加坡节点", "🇺🇸 美国节点" ] }, + { "tag": "🎮 游戏服务", "type": "selector", "outbounds": [ "🎯 全球直连", "🚀 节点选择" ] }, + { "tag": "🪟 微软服务", "type": "selector", "outbounds": [ "🎯 全球直连", "🚀 节点选择" ] }, + { "tag": "🇬 谷歌服务", "type": "selector", "outbounds": [ "🎯 全球直连", "🚀 节点选择" ] }, + { "tag": "🍎 苹果服务", "type": "selector", "outbounds": [ "🎯 全球直连", "🚀 节点选择" ] }, + { "tag": "🎥 奈飞视频", "type": "selector", "outbounds": [ "🚀 节点选择", "🇭🇰 香港节点", "🇯🇵 日本节点", "🇸🇬 新加坡节点" ] }, + { "tag": "📽️ 迪士尼+", "type": "selector", "outbounds": [ "🚀 节点选择", "🇭🇰 香港节点", "🇯🇵 日本节点", "🇸🇬 新加坡节点" ] }, + { "tag": "🎞️ Max", "type": "selector", "outbounds": [ "🚀 节点选择", "🇭🇰 香港节点", "🇯🇵 日本节点", "🇸🇬 新加坡节点" ] }, + { "tag": "🎬 Prime Video", "type": "selector", "outbounds": [ "🚀 节点选择", "🇭🇰 香港节点", "🇯🇵 日本节点", "🇸🇬 新加坡节点" ] }, + { "tag": "🍎 Apple TV+", "type": "selector", "outbounds": [ "🚀 节点选择", "🇭🇰 香港节点", "🇯🇵 日本节点", "🇸🇬 新加坡节点" ] }, + { "tag": "📹 油管视频", "type": "selector", "outbounds": [ "🚀 节点选择", "🇭🇰 香港节点", "🇯🇵 日本节点", "🇸🇬 新加坡节点" ] }, + { "tag": "🎵 TikTok", "type": "selector", "outbounds": [ "🚀 节点选择", "🇭🇰 香港节点", "🇯🇵 日本节点", "🇸🇬 新加坡节点" ] }, + { "tag": "📺 哔哩哔哩", "type": "selector", "outbounds": [ "🎯 全球直连", "🚀 节点选择", "🇭🇰 香港节点", "🇯🇵 日本节点", "🇸🇬 新加坡节点" ] }, + { "tag": "🇨🇳 直连域名", "type": "selector", "outbounds": [ "🎯 全球直连", "🚀 节点选择" ] }, + { "tag": "🇨🇳 直连 IP", "type": "selector", "outbounds": [ "🎯 全球直连", "🚀 节点选择" ] }, + { "tag": "🪜 代理域名", "type": "selector", "outbounds": [ "🚀 节点选择", "🎯 全球直连" ] }, + { "tag": "📲 电报消息", "type": "selector", "outbounds": ["🚀 节点选择"] }, + { "tag": "🖥️ 直连软件", "type": "selector", "outbounds": ["🎯 全球直连"] }, + { "tag": "🔒 私有网络", "type": "selector", "outbounds": ["🎯 全球直连"] }, + { "tag": "🛑 广告拦截", "type": "selector", "outbounds": ["REJECT"] }, + { "tag": "🎯 全球直连", "type": "selector", "outbounds": ["DIRECT"] }, + { "tag": "REJECT", "type": "block" }, + { "tag": "DIRECT", "type": "direct" }, + { "tag": "GLOBAL", "type": "selector", "outbounds": [ "DIRECT", "REJECT", "🇭🇰 香港节点", "🇹🇼 台湾节点", "🇯🇵 日本节点", "🇰🇷 韩国节点", "🇸🇬 新加坡节点", "🇺🇸 美国节点" ] }, + ], + "route": { + "rules": [ + { "rule_set": [ "applications" ], "outbound": "🖥️ 直连软件" }, + { "rule_set": [ "private" ], "outbound": "🔒 私有网络" }, + { "rule_set": [ "ads" ], "outbound": "🛑 广告拦截" }, + { "rule_set": [ "microsoft-cn" ], "outbound": "🪟 微软服务" }, + { "rule_set": [ "apple-cn" ], "outbound": "🍎 苹果服务" }, + { "rule_set": [ "google-cn" ], "outbound": "🇬 谷歌服务" }, + { "rule_set": [ "games-cn" ], "outbound": "🎮 游戏服务" }, + { "rule_set": [ "netflix", "netflixip" ], "outbound": "🎥 奈飞视频", "skip_resolve": true }, + { "rule_set": [ "disney" ], "outbound": "📽️ 迪士尼+" }, + { "rule_set": [ "max" ], "outbound": "🎞️ Max" }, + { "rule_set": [ "primevideo" ], "outbound": "🎬 Prime Video" }, + { "rule_set": [ "appletv" ], "outbound": "🍎 Apple TV+" }, + { "rule_set": [ "youtube" ], "outbound": "📹 油管视频" }, + { "rule_set": [ "tiktok" ], "outbound": "🎵 TikTok" }, + { "rule_set": [ "bilibili" ], "outbound": "📺 哔哩哔哩" }, + { "rule_set": [ "ai" ], "outbound": "🤖 人工智能" }, + { "rule_set": [ "networktest" ], "outbound": "📈 网络测试" }, + { "rule_set": [ "proxy" ], "outbound": "🪜 代理域名" }, + { "rule_set": [ "cn" ], "outbound": "🇨🇳 直连域名" }, + { "rule_set": [ "telegramip" ], "outbound": "📲 电报消息", "skip_resolve": true }, + { "rule_set": [ "privateip" ], "outbound": "🔒 私有网络", "skip_resolve": true }, + { "rule_set": [ "cnip" ], "outbound": "🇨🇳 直连 IP" } + ], + "rule_set": [ { - "address": "https://1.1.1.1/dns-query", - "domains": ["geosite:geolocation-!cn", "geosite:google@cn"], - "expectIPs": ["geoip:!cn"] + "tag": "fakeip-filter", + "type": "remote", + "format": "binary", + "path": "./ruleset/fakeip-filter.srs", + "url": "https://github.com/DustinWin/ruleset_geodata/releases/download/sing-box-ruleset/fakeip-filter.srs" }, - "8.8.8.8", { - "address": "114.114.114.114", - "port": 53, - "domains": [ - "geosite:cn", - "geosite:icloud", - "geosite:category-games@cn" - ], - "expectIPs": ["geoip:cn"], - "skipFallback": true + "tag": "applications", + "type": "remote", + "format": "binary", + "path": "./ruleset/applications.srs", + "url": "https://github.com/DustinWin/ruleset_geodata/releases/download/sing-box-ruleset/applications.srs" }, { - "address": "localhost", - "skipFallback": true - } - ] - }, - "inbounds": [ - { - "protocol": "socks", - "listen": "0.0.0.0", - "port": 1080, - "tag": "Socks-In", - "settings": { - "ip": "127.0.0.1", - "udp": true, - "auth": "noauth" + "tag": "private", + "type": "remote", + "format": "binary", + "path": "./ruleset/private.srs", + "url": "https://github.com/DustinWin/ruleset_geodata/releases/download/sing-box-ruleset/private.srs" + }, + { + "tag": "ads", + "type": "remote", + "format": "binary", + "path": "./ruleset/ads.srs", + "url": "https://github.com/DustinWin/ruleset_geodata/releases/download/sing-box-ruleset/ads.srs" + }, + { + "tag": "microsoft-cn", + "type": "remote", + "format": "binary", + "path": "./ruleset/microsoft-cn.srs", + "url": "https://github.com/DustinWin/ruleset_geodata/releases/download/sing-box-ruleset/microsoft-cn.srs" + }, + { + "tag": "apple-cn", + "type": "remote", + "format": "binary", + "path": "./ruleset/apple-cn.srs", + "url": "https://github.com/DustinWin/ruleset_geodata/releases/download/sing-box-ruleset/apple-cn.srs" + }, + { + "tag": "google-cn", + "type": "remote", + "format": "binary", + "path": "./ruleset/google-cn.srs", + "url": "https://github.com/DustinWin/ruleset_geodata/releases/download/sing-box-ruleset/google-cn.srs" + }, + { + "tag": "games-cn", + "type": "remote", + "format": "binary", + "path": "./ruleset/games-cn.srs", + "url": "https://github.com/DustinWin/ruleset_geodata/releases/download/sing-box-ruleset/games-cn.srs" + }, + { + "tag": "netflix", + "type": "remote", + "format": "binary", + "path": "./ruleset/netflix.srs", + "url": "https://github.com/DustinWin/ruleset_geodata/releases/download/sing-box-ruleset/netflix.srs" }, - "sniffing": { - "enabled": true, - "destOverride": ["http", "tls"] - } - }, - { - "protocol": "http", - "listen": "0.0.0.0", - "port": 2080, - "tag": "Http-In", - "sniffing": { - "enabled": true, - "destOverride": ["http", "tls"] - } - } - ], - "outbounds": [ - { - //下面这行,协议类别要改为socks、shadowsocks、vmess或vless等(记得删除本行文字说明) - "protocol": "协议类别", - "settings": {}, - //下面这行,tag的值对应Routing里的outboundTag,这里为Proxy(记得删除本行文字说明) - "tag": "Proxy", - "streamSettings": {}, - "mux": {} - }, - { - "protocol": "dns", - "tag": "Dns-Out" - }, - { - "protocol": "freedom", - "tag": "Direct", - "settings": { - "domainStrategy": "UseIPv4" - } - }, - { - "protocol": "blackhole", - "tag": "Reject", - "settings": { - "response": { - "type": "http" - } - } - } - ], - "routing": { - "domainStrategy": "IPIfNonMatch", - "domainMatcher": "mph", - "rules": [ { - "type": "field", - "outboundTag": "Direct", - "protocol": ["bittorrent"] + "tag": "disney", + "type": "remote", + "format": "binary", + "path": "./ruleset/disney.srs", + "url": "https://github.com/DustinWin/ruleset_geodata/releases/download/sing-box-ruleset/disney.srs" }, { - "type": "field", - "outboundTag": "Dns-Out", - "inboundTag": ["Socks-In", "Http-In"], - "network": "udp", - "port": 53 + "tag": "max", + "type": "remote", + "format": "binary", + "path": "./ruleset/max.srs", + "url": "https://github.com/DustinWin/ruleset_geodata/releases/download/sing-box-ruleset/max.srs" }, { - "type": "field", - "outboundTag": "Reject", - "domain": ["geosite:category-ads-all"] + "tag": "primevideo", + "type": "remote", + "format": "binary", + "path": "./ruleset/primevideo.srs", + "url": "https://github.com/DustinWin/ruleset_geodata/releases/download/sing-box-ruleset/primevideo.srs" }, { - "type": "field", - "outboundTag": "Proxy", - "domain": [ - "full:www.icloud.com", - "domain:icloud-content.com", - "geosite:google" - ] + "tag": "appletv", + "type": "remote", + "format": "binary", + "path": "./ruleset/appletv.srs", + "url": "https://github.com/DustinWin/ruleset_geodata/releases/download/sing-box-ruleset/appletv.srs" }, { - "type": "field", - "outboundTag": "Direct", - "domain": [ - "geosite:tld-cn", - "geosite:icloud", - "geosite:category-games@cn" - ] + "tag": "youtube", + "type": "remote", + "format": "binary", + "path": "./ruleset/youtube.srs", + "url": "https://github.com/DustinWin/ruleset_geodata/releases/download/sing-box-ruleset/youtube.srs" }, { - "type": "field", - "outboundTag": "Proxy", - "domain": ["geosite:geolocation-!cn"] + "tag": "tiktok", + "type": "remote", + "format": "binary", + "path": "./ruleset/tiktok.srs", + "url": "https://github.com/DustinWin/ruleset_geodata/releases/download/sing-box-ruleset/tiktok.srs" }, { - "type": "field", - "outboundTag": "Direct", - "domain": ["geosite:cn", "geosite:private"] + "tag": "bilibili", + "type": "remote", + "format": "binary", + "path": "./ruleset/bilibili.srs", + "url": "https://github.com/DustinWin/ruleset_geodata/releases/download/sing-box-ruleset/bilibili.srs" }, { - "type": "field", - "outboundTag": "Direct", - "ip": ["geoip:cn", "geoip:private"] + "tag": "ai", + "type": "remote", + "format": "binary", + "path": "./ruleset/ai.srs", + "url": "https://github.com/DustinWin/ruleset_geodata/releases/download/sing-box-ruleset/ai.srs" }, { - "type": "field", - "outboundTag": "Proxy", - "network": "tcp,udp" + "tag": "networktest", + "type": "remote", + "format": "binary", + "path": "./ruleset/networktest.srs", + "url": "https://github.com/DustinWin/ruleset_geodata/releases/download/sing-box-ruleset/networktest.srs" + }, + { + "tag": "proxy", + "type": "remote", + "format": "binary", + "path": "./ruleset/proxy.srs", + "url": "https://github.com/DustinWin/ruleset_geodata/releases/download/sing-box-ruleset/proxy.srs" + }, + { + "tag": "cn", + "type": "remote", + "format": "binary", + "path": "./ruleset/cn.srs", + "url": "https://github.com/DustinWin/ruleset_geodata/releases/download/sing-box-ruleset/cn.srs" + }, + { + "tag": "netflixip", + "type": "remote", + "format": "binary", + "path": "./ruleset/netflixip.srs", + "url": "https://github.com/DustinWin/ruleset_geodata/releases/download/sing-box-ruleset/netflixip.srs" + }, + { + "tag": "telegramip", + "type": "remote", + "format": "binary", + "path": "./ruleset/telegramip.srs", + "url": "https://github.com/DustinWin/ruleset_geodata/releases/download/sing-box-ruleset/telegramip.srs" + }, + { + "tag": "privateip", + "type": "remote", + "format": "binary", + "path": "./ruleset/privateip.srs", + "url": "https://github.com/DustinWin/ruleset_geodata/releases/download/sing-box-ruleset/privateip.srs" + }, + { + "tag": "cnip", + "type": "remote", + "format": "binary", + "path": "./ruleset/cnip.srs", + "url": "https://github.com/DustinWin/ruleset_geodata/releases/download/sing-box-ruleset/cnip.srs" } ] } } ``` - -## 致谢 - -- [@Loyalsoldier/geoip](https://github.com/Loyalsoldier/geoip) -- [@v2fly/domain-list-community](https://github.com/v2fly/domain-list-community) -- [@Loyalsoldier/domain-list-custom](https://github.com/Loyalsoldier/domain-list-custom) -- [@felixonmars/dnsmasq-china-list](https://github.com/felixonmars/dnsmasq-china-list) -- [@gfwlist/gfwlist](https://github.com/gfwlist/gfwlist) -- [@cokebar/gfwlist2dnsmasq](https://github.com/cokebar/gfwlist2dnsmasq) -- [@AdblockPlus/EasylistChina+Easylist.txt](https://easylist-downloads.adblockplus.org/easylistchina+easylist.txt) -- [@AdGuard/DNS-filter](https://kb.adguard.com/en/general/adguard-ad-filters#dns-filter) -- [@PeterLowe/adservers](https://pgl.yoyo.org/adservers) -- [@DanPollock/hosts](https://someonewhocares.org/hosts) -- [@crazy-max/WindowsSpyBlocker](https://github.com/crazy-max/WindowsSpyBlocker) - -## 项目 Star 数增长趋势 - -[![Stargazers over time](https://starchart.cc/Loyalsoldier/v2ray-rules-dat.svg)](https://starchart.cc/Loyalsoldier/v2ray-rules-dat) +
diff --git a/tools/convert.sh b/tools/convert.sh new file mode 100644 index 00000000000..3117de8f046 --- /dev/null +++ b/tools/convert.sh @@ -0,0 +1,107 @@ +# 处理文件 +list=($(ls ./rules/)) +for ((i = 0; i < ${#list[@]}; i++)); do + mkdir -p ${list[i]} + # 归类 + # android package + if [ -n "$(cat ./rules/${list[i]}/${list[i]}.yaml | grep 'PROCESS-NAME,' | grep -v '\.exe' | grep '\.')" ]; then + cat ./rules/${list[i]}/${list[i]}.yaml | grep 'PROCESS-NAME,' | grep -v '\.exe' | grep '\.' | sed 's/^PROCESS-NAME,//' > ${list[i]}/package.json + fi + # process name + if [ -n "$(cat ./rules/${list[i]}/${list[i]}.yaml | grep 'PROCESS-NAME,' | grep -v '\.')" ]; then + cat ./rules/${list[i]}/${list[i]}.yaml | grep 'PROCESS-NAME,' | grep -v '\.' | sed 's/^PROCESS-NAME,//' > ${list[i]}/process.json + fi + if [ -n "$(cat ./rules/${list[i]}/${list[i]}.yaml | grep 'PROCESS-NAME,' | grep '\.exe')" ]; then + cat ./rules/${list[i]}/${list[i]}.yaml | grep 'PROCESS-NAME,' | grep '\.exe' | sed 's/^PROCESS-NAME,//' >> ${list[i]}/process.json + fi + # domain + if [ -n "$(cat ./rules/${list[i]}/${list[i]}.yaml | grep 'DOMAIN,')" ]; then + cat ./rules/${list[i]}/${list[i]}.yaml | grep 'DOMAIN,' | sed 's/^DOMAIN,//' > ${list[i]}/domain.json + fi + # suffix + if [ -n "$(cat ./rules/${list[i]}/${list[i]}.yaml | grep 'DOMAIN-SUFFIX,')" ]; then + cat ./rules/${list[i]}/${list[i]}.yaml | grep 'DOMAIN-SUFFIX,' | sed 's/^DOMAIN-SUFFIX,//' > ${list[i]}/suffix.json + fi + # keyword + if [ -n "$(cat ./rules/${list[i]}/${list[i]}.yaml | grep 'DOMAIN-KEYWORD,')" ]; then + cat ./rules/${list[i]}/${list[i]}.yaml | grep 'DOMAIN-KEYWORD,' | sed 's/^DOMAIN-KEYWORD,//' > ${list[i]}/keyword.json + fi + # regex + if [ -n "$(cat ./rules/${list[i]}/${list[i]}.yaml | grep 'DOMAIN-REGEX,')" ]; then + cat ./rules/${list[i]}/${list[i]}.yaml | grep 'DOMAIN-REGEX,' | sed 's/^DOMAIN-REGEX,//' > ${list[i]}/regex.json + fi + # ipcidr + if [ -n "$(cat ./rules/${list[i]}/${list[i]}.yaml | grep 'IP-CIDR')" ]; then + cat ./rules/${list[i]}/${list[i]}.yaml | grep 'IP-CIDR' | sed -e 's/^IP-CIDR,//' -e 's/^IP-CIDR6,//' > ${list[i]}/ipcidr.json + fi + # 转换成 .json 格式 + # android package + if [ -f "${list[i]}/package.json" ]; then + sed -i 's/.*/ "&",/' ${list[i]}/package.json + sed -i '1s/^/ "package_name": [\n/' ${list[i]}/package.json + sed -i '$s/,$/\n ],/' ${list[i]}/package.json + fi + # process name + if [ -f "${list[i]}/process.json" ]; then + sed -i 's/.*/ "&",/' ${list[i]}/process.json + sed -i '1s/^/ "process_name": [\n/' ${list[i]}/process.json + sed -i '$s/,$/\n ],/' ${list[i]}/process.json + fi + # domain + if [ -f "${list[i]}/domain.json" ]; then + sed -i 's/.*/ "&",/' ${list[i]}/domain.json + sed -i '1s/^/ "domain": [\n/' ${list[i]}/domain.json + sed -i '$s/,$/\n ],/' ${list[i]}/domain.json + fi + # suffix + if [ -f "${list[i]}/suffix.json" ]; then + sed -i 's/.*/ "&",/' ${list[i]}/suffix.json + sed -i '1s/^/ "domain_suffix": [\n/' ${list[i]}/suffix.json + sed -i '$s/,$/\n ],/' ${list[i]}/suffix.json + fi + # keyword + if [ -f "${list[i]}/keyword.json" ]; then + sed -i 's/.*/ "&",/' ${list[i]}/keyword.json + sed -i '1s/^/ "domain_keyword": [\n/' ${list[i]}/keyword.json + sed -i '$s/,$/\n ],/' ${list[i]}/keyword.json + fi + # regex + if [ -f "${list[i]}/regex.json" ]; then + sed -i 's/.*/ "&",/' ${list[i]}/regex.json + sed -i '1s/^/ "domain_regex": [\n/' ${list[i]}/regex.json + sed -i '$s/,$/\n ],/' ${list[i]}/regex.json + fi + # ipcidr + if [ -f "${list[i]}/ipcidr.json" ]; then + sed -i 's/.*/ "&",/' ${list[i]}/ipcidr.json + sed -i '1s/^/ "ip_cidr": [\n/' ${list[i]}/ipcidr.json + sed -i '$s/,$/\n ],/' ${list[i]}/ipcidr.json + fi + # 合并文件 + if [ -f "${list[i]}/package.json" -a -f "${list[i]}/process.json" ]; then + mv -f ${list[i]}/package.json ${list[i]}.json + sed -i '$ s/,$/\n },\n {/' ${list[i]}.json + cat ${list[i]}/process.json >> ${list[i]}.json + rm -f ${list[i]}/process.json + elif [ -f "${list[i]}/package.json" ]; then + mv -f ${list[i]}/package.json ${list[i]}.json + elif [ -f "${list[i]}/process.json" ]; then + mv -f ${list[i]}/process.json ${list[i]}.json + fi + + if [ "$(ls ${list[i]})" = "" ]; then + sed -i '1s/^/{\n "version": 2,\n "rules": [\n {\n/' ${list[i]}.json + elif [ -f "${list[i]}.json" ]; then + sed -i '1s/^/{\n "version": 2,\n "rules": [\n {\n/' ${list[i]}.json + sed -i '$ s/,$/\n },\n {/' ${list[i]}.json + cat ${list[i]}/* >> ${list[i]}.json + else + cat ${list[i]}/* >> ${list[i]}.json + sed -i '1s/^/{\n "version": 2,\n "rules": [\n {\n/' ${list[i]}.json + fi + sed -i '$ s/,$/\n }\n ]\n}/' ${list[i]}.json + rm -rf ${list[i]} + + # 编译成 .srs 格式 + ./sing-box rule-set compile --output ${list[i]}.srs ${list[i]}.json +done diff --git a/tools/convert_compatible.sh b/tools/convert_compatible.sh new file mode 100644 index 00000000000..21593d56f5b --- /dev/null +++ b/tools/convert_compatible.sh @@ -0,0 +1,107 @@ +# 处理文件 +list=($(ls ./rules/)) +for ((i = 0; i < ${#list[@]}; i++)); do + mkdir -p ${list[i]} + # 归类 + # android package + if [ -n "$(cat ./rules/${list[i]}/${list[i]}.yaml | grep 'PROCESS-NAME,' | grep -v '\.exe' | grep '\.')" ]; then + cat ./rules/${list[i]}/${list[i]}.yaml | grep 'PROCESS-NAME,' | grep -v '\.exe' | grep '\.' | sed 's/^PROCESS-NAME,//' > ${list[i]}/package.json + fi + # process name + if [ -n "$(cat ./rules/${list[i]}/${list[i]}.yaml | grep 'PROCESS-NAME,' | grep -v '\.')" ]; then + cat ./rules/${list[i]}/${list[i]}.yaml | grep 'PROCESS-NAME,' | grep -v '\.' | sed 's/^PROCESS-NAME,//' > ${list[i]}/process.json + fi + if [ -n "$(cat ./rules/${list[i]}/${list[i]}.yaml | grep 'PROCESS-NAME,' | grep '\.exe')" ]; then + cat ./rules/${list[i]}/${list[i]}.yaml | grep 'PROCESS-NAME,' | grep '\.exe' | sed 's/^PROCESS-NAME,//' >> ${list[i]}/process.json + fi + # domain + if [ -n "$(cat ./rules/${list[i]}/${list[i]}.yaml | grep 'DOMAIN,')" ]; then + cat ./rules/${list[i]}/${list[i]}.yaml | grep 'DOMAIN,' | sed 's/^DOMAIN,//' > ${list[i]}/domain.json + fi + # suffix + if [ -n "$(cat ./rules/${list[i]}/${list[i]}.yaml | grep 'DOMAIN-SUFFIX,')" ]; then + cat ./rules/${list[i]}/${list[i]}.yaml | grep 'DOMAIN-SUFFIX,' | sed 's/^DOMAIN-SUFFIX,//' > ${list[i]}/suffix.json + fi + # keyword + if [ -n "$(cat ./rules/${list[i]}/${list[i]}.yaml | grep 'DOMAIN-KEYWORD,')" ]; then + cat ./rules/${list[i]}/${list[i]}.yaml | grep 'DOMAIN-KEYWORD,' | sed 's/^DOMAIN-KEYWORD,//' > ${list[i]}/keyword.json + fi + # regex + if [ -n "$(cat ./rules/${list[i]}/${list[i]}.yaml | grep 'DOMAIN-REGEX,')" ]; then + cat ./rules/${list[i]}/${list[i]}.yaml | grep 'DOMAIN-REGEX,' | sed 's/^DOMAIN-REGEX,//' > ${list[i]}/regex.json + fi + # ipcidr + if [ -n "$(cat ./rules/${list[i]}/${list[i]}.yaml | grep 'IP-CIDR')" ]; then + cat ./rules/${list[i]}/${list[i]}.yaml | grep 'IP-CIDR' | sed -e 's/^IP-CIDR,//' -e 's/^IP-CIDR6,//' > ${list[i]}/ipcidr.json + fi + # 转换成 .json 格式 + # android package + if [ -f "${list[i]}/package.json" ]; then + sed -i 's/.*/ "&",/' ${list[i]}/package.json + sed -i '1s/^/ "package_name": [\n/' ${list[i]}/package.json + sed -i '$s/,$/\n ],/' ${list[i]}/package.json + fi + # process name + if [ -f "${list[i]}/process.json" ]; then + sed -i 's/.*/ "&",/' ${list[i]}/process.json + sed -i '1s/^/ "process_name": [\n/' ${list[i]}/process.json + sed -i '$s/,$/\n ],/' ${list[i]}/process.json + fi + # domain + if [ -f "${list[i]}/domain.json" ]; then + sed -i 's/.*/ "&",/' ${list[i]}/domain.json + sed -i '1s/^/ "domain": [\n/' ${list[i]}/domain.json + sed -i '$s/,$/\n ],/' ${list[i]}/domain.json + fi + # suffix + if [ -f "${list[i]}/suffix.json" ]; then + sed -i 's/.*/ "&",/' ${list[i]}/suffix.json + sed -i '1s/^/ "domain_suffix": [\n/' ${list[i]}/suffix.json + sed -i '$s/,$/\n ],/' ${list[i]}/suffix.json + fi + # keyword + if [ -f "${list[i]}/keyword.json" ]; then + sed -i 's/.*/ "&",/' ${list[i]}/keyword.json + sed -i '1s/^/ "domain_keyword": [\n/' ${list[i]}/keyword.json + sed -i '$s/,$/\n ],/' ${list[i]}/keyword.json + fi + # regex + if [ -f "${list[i]}/regex.json" ]; then + sed -i 's/.*/ "&",/' ${list[i]}/regex.json + sed -i '1s/^/ "domain_regex": [\n/' ${list[i]}/regex.json + sed -i '$s/,$/\n ],/' ${list[i]}/regex.json + fi + # ipcidr + if [ -f "${list[i]}/ipcidr.json" ]; then + sed -i 's/.*/ "&",/' ${list[i]}/ipcidr.json + sed -i '1s/^/ "ip_cidr": [\n/' ${list[i]}/ipcidr.json + sed -i '$s/,$/\n ],/' ${list[i]}/ipcidr.json + fi + # 合并文件 + if [ -f "${list[i]}/package.json" -a -f "${list[i]}/process.json" ]; then + mv -f ${list[i]}/package.json ${list[i]}.json + sed -i '$ s/,$/\n },\n {/' ${list[i]}.json + cat ${list[i]}/process.json >> ${list[i]}.json + rm -f ${list[i]}/process.json + elif [ -f "${list[i]}/package.json" ]; then + mv -f ${list[i]}/package.json ${list[i]}.json + elif [ -f "${list[i]}/process.json" ]; then + mv -f ${list[i]}/process.json ${list[i]}.json + fi + + if [ "$(ls ${list[i]})" = "" ]; then + sed -i '1s/^/{\n "version": 1,\n "rules": [\n {\n/' ${list[i]}.json + elif [ -f "${list[i]}.json" ]; then + sed -i '1s/^/{\n "version": 1,\n "rules": [\n {\n/' ${list[i]}.json + sed -i '$ s/,$/\n },\n {/' ${list[i]}.json + cat ${list[i]}/* >> ${list[i]}.json + else + cat ${list[i]}/* >> ${list[i]}.json + sed -i '1s/^/{\n "version": 1,\n "rules": [\n {\n/' ${list[i]}.json + fi + sed -i '$ s/,$/\n }\n ]\n}/' ${list[i]}.json + rm -rf ${list[i]} + + # 编译成 .srs 格式 + ./sing-box rule-set compile --output ${list[i]}.srs ${list[i]}.json +done