Skip to content

Commit

Permalink
Merge pull request #553 from chise0713/master
Browse files Browse the repository at this point in the history
Fix BUGs and add new GEOIP provider
  • Loading branch information
NormanBB authored Oct 29, 2023
2 parents 68f0b71 + ba56ed4 commit f0ac9b2
Show file tree
Hide file tree
Showing 7 changed files with 6,383 additions and 47 deletions.
15 changes: 15 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/.github"
schedule:
interval: "daily"
timezone: "Asia/Hong_Kong"
time: "06:00"
pull-request-branch-name:
separator: "-"
100 changes: 78 additions & 22 deletions .github/workflows/updategeoip-cn.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Update China IP list and generate BypassCN.rule
name: Update China IP list and generate BypassCN.rules and BypassCN_someip.rules

on:
workflow_dispatch:
Expand All @@ -13,36 +13,92 @@ jobs:
steps:

- name: Check out code into directory
uses: actions/checkout@v3

- name: Run the updategeoip-cn.sh
run: ./tools/updategeoip-cn.sh
shell: bash
uses: actions/checkout@v4

- name: Git Add BypassCNandLan.rules
- name: Git config
run: |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git fetch
cp ./BypassCNandLan.rules ./rules/BypassCNandLan.rules
git add ./rules/BypassCNandLan.rules
if ! git commit -am "Updated at $(date)"; then
curl -oL ./ https://github.com/FQrabbit/SSTap-Rule/raw/master/rules/BypassCNandLan.rules
hash1=$(sha256sum "./BypassCNandLan.rules" | awk '{print $1}')
hash2=$(sha256sum "./rules/BypassCNandLan.rules" | awk '{print $1}')
if [ "$hash1" == "$hash2" ]; then
echo "Hashes match. The files are identical."
echo "Upstream not updated"
else
echo "Hashes do not match. The files are different."
echo "ERROR! Upstream updated! There's something went WRONG!"
exit 1
fi
shell: bash

- name: Get CIDR (Source someip) field
run: |
echo "#BypassCNandLan,绕过大陆和局域网someip,1,1,1,0,0,0," >> BypassCNandLan_someip.rules
curl https://raw.githubusercontent.com/0x2E/someip/build/cidr.txt >> BypassCNandLan_someip.rules
sed -i '2{/^$/d;}' BypassCNandLan_someip.rules # 删除源文件内第二行的空行
echo 10.0.0.0/8 >> BypassCNandLan_someip.rules
echo 172.16.0.0/12 >> BypassCNandLan_someip.rules
echo 192.168.0.0/16 >> BypassCNandLan_someip.rules
shell: bash

- name: Get CIDR field
run: |
echo "#BypassCNandLan,绕过大陆和局域网,1,1,1,0,0,0," >> BypassCNandLan.rules
curl https://raw.githubusercontent.com/Hackl0us/GeoIP2-CN/release/CN-ip-cidr.txt >> BypassCNandLan.rules
sed -i '2{/^$/d;}' BypassCNandLan.rules # 删除源文件内第二行的空行
echo 10.0.0.0/8 >> BypassCNandLan.rules
echo 172.16.0.0/12 >> BypassCNandLan.rules
echo 192.168.0.0/16 >> BypassCNandLan.rules
shell: bash

- name: Compare New file and Old file (Source someip)
run: |
hash1=$(sha256sum "./BypassCNandLan_someip.rules" | awk '{print $1}')
hash2=$(sha256sum "./rules/BypassCNandLan_someip.rules" | awk '{print $1}')
echo -e "hash1=$hash1\nhash2=$hash2"
if [ "$hash1" == "$hash2" ]; then
echo "Hashes match. The files are identical."
echo "Upstream not updated"
echo "STATUS_1=1" >> $GITHUB_ENV
exit 0
else
echo "Hashes do not match. The files are different."
echo "Upstream updated."
echo "STATUS_1=0" >> $GITHUB_ENV
cp ./BypassCNandLan_someip.rules ./rules/BypassCNandLan_someip.rules
git add ./rules/BypassCNandLan_someip.rules
git commit -am "Updated at $(TZ='Asia/Shanghai' date)"
fi
shell: bash

- name: Compare New file and Old file
run: |
hash1=$(sha256sum "./BypassCNandLan.rules" | awk '{print $1}')
hash2=$(sha256sum "./rules/BypassCNandLan.rules" | awk '{print $1}')
echo -e "hash1=$hash1\nhash2=$hash2"
if [ "$hash1" == "$hash2" ]; then
echo "Hashes match. The files are identical."
echo "Upstream not updated"
echo "STATUS_2=1" >> $GITHUB_ENV
exit 0
else
echo "Hashes do not match. The files are different."
echo "Upstream updated."
echo "STATUS_2=0" >> $GITHUB_ENV
cp ./BypassCNandLan.rules ./rules/BypassCNandLan.rules
git add ./rules/BypassCNandLan.rules
git commit -am "Updated at $(TZ='Asia/Shanghai' date)"
fi
shell: bash

- name: Check GitHub Environment Variable and judgment wheather a Github Push is Needed
run: |
if [[ "${{ env.STATUS_1 }}" == "0" ]] || [[ "${{ env.STATUS_2 }}" == "0" ]] ; then
echo "NeedUpdate=true" >> $GITHUB_ENV
else
echo "NeedUpdate=false" >> $GITHUB_ENV
fi
echo ${{ env.NeedUpdate }}
shell: bash

- name: GitHub Push
uses: ad-m/github-push-action@v0.6.0
if: env.NeedUpdate == 'true'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: master
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@

在这里会不定时的更新各个游戏的路由表规则,你只要下载所需的规则或规则包导入对应文件夹即可使用。

## 关于两个GEOIP源
[GEOIPCN.1](https://github.com/KoinuDayo/SSTap-Rule/raw/master/rules/BypassCNandLan.rules) || [GEOIPCN.2](https://github.com/KoinuDayo/SSTap-Rule/raw/master/rules/BypassCNandLan_someip.rules)

- GEOIPCN.1 是[Hackl0us/GeoIP2-CN](https://github.com/Hackl0us/GeoIP2-CN)的完整版本
- GEOIPCN.2 而是[0x2E/someip](https://github.com/0x2E/someip)的简化版本
两者在使用上一般不会有什么差距。
如果追求最小错误率请选择GEOIPCN.1,最求最高效率请选择GEOIPCN.2

## 规则使用方法

- [点我进入规则包下载页面](https://github.com/FQrabbit/SSTap-Rule/releases)
Expand Down
Loading

0 comments on commit f0ac9b2

Please sign in to comment.