diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..2d14ce3 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,101 @@ +name: Build geoip files +on: + workflow_dispatch: + schedule: + - cron: "0 3,9,15,21 * * *" + push: + branches: + - master + paths-ignore: + - ".gitignore" + - "LICENSE*" + - "*.md" +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Checkout codebase + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Checkout runetfreedom/geoip + uses: actions/checkout@v4 + with: + repository: runetfreedom/geoip + path: geoip + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: ./geoip/go.mod + + - name: Set variables + run: | + echo "TAG_NAME=$(date +%Y%m%d%H%M)" >> $GITHUB_ENV + echo "RELEASE_NAME=$(date +%Y%m%d%H%M)" >> $GITHUB_ENV + shell: bash + + - name: Build geoip files + run: | + go build -C geoip ./ + ./geoip/geoip convert -c ./config.json + + - name: Verify mmdb files + run: | + cd ./output || exit 1 + go install -v github.com/maxmind/mmdbverify@latest + for name in $(ls *.mmdb); do + $(go env GOPATH)/bin/mmdbverify -file ${name} + done + + - name: Generate sha256 checksum for dat files + run: | + cd ./output || exit 1 + for name in $(ls *.dat); do + sha256sum ${name} > ./${name}.sha256sum + done + + - name: Generate sha256 checksum for mmdb files + run: | + cd ./output || exit 1 + for name in $(ls *.mmdb); do + sha256sum ${name} > ./${name}.sha256sum + done + + - name: Git push assets to "release" branch + run: | + cd output || exit 1 + git init + git config --local user.name "github-actions[bot]" + git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" + git checkout -b release + git add -A + git commit -m "${{ env.RELEASE_NAME }}" + git remote add geoip "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}" + git push -f -u geoip release + + - name: Purge jsdelivr CDN + run: | + cd output || exit 1 + for file in $(ls); do + curl -i "https://purge.jsdelivr.net/gh/${{ github.repository }}@release/${file}" + done + + - name: Remove some files to avoid publishing to GitHub release + run: | + rm -rf ./output/*.{gz,zip} + rm -rf ./output/GeoLite2-*.csv + rm -rf ./output/GeoLite2-*.mmdb + rm -rf ./output/GeoLite2-*.sha256sum + rm -rf ./output/{clash,dat,mrs,nginx,srs,surge,text} + + - name: Upload files to GitHub release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file_glob: true + file: ./output/* + release_name: ${{ env.RELEASE_NAME }} + tag: ${{ env.TAG_NAME }} diff --git a/config.json b/config.json new file mode 100644 index 0000000..926068b --- /dev/null +++ b/config.json @@ -0,0 +1,214 @@ +{ + "input": [ + { + "type": "v2rayGeoIPDat", + "action": "add", + "args": { + "uri": "https://github.com/Loyalsoldier/geoip/raw/release/geoip.dat" + } + }, + { + "type": "text", + "action": "add", + "args": { + "name": "ru-blocked", + "uri": "https://antifilter.download/list/ipresolve.lst" + } + }, + { + "type": "text", + "action": "add", + "args": { + "name": "ru-blocked", + "uri": "https://antifilter.download/list/subnet.lst" + } + }, + { + "type": "text", + "action": "add", + "args": { + "name": "ru-blocked-community", + "uri": "https://community.antifilter.download/list/community.lst" + } + }, + { + "type": "maxmindGeoLite2ASNCSV", + "action": "add", + "args": { + "ipv4": "https://github.com/Loyalsoldier/geoip/raw/release/GeoLite2-ASN-Blocks-IPv4.csv", + "ipv6": "https://github.com/Loyalsoldier/geoip/raw/release/GeoLite2-ASN-Blocks-IPv6.csv", + "wantedList": { + "ddos-guard": [ + "AS262254", + "AS57724", + "AS49612" + ], + "yandex": [ + "AS44534", + "AS13238", + "AS200350", + "AS208722" + ] + } + } + }, + { + "type": "private", + "action": "add" + } + ], + "output": [ + { + "type": "v2rayGeoIPDat", + "action": "output", + "args": { + "outputDir": "./output", + "outputName": "geoip.dat" + } + }, + { + "type": "v2rayGeoIPDat", + "action": "output", + "args": { + "outputDir": "./output", + "outputName": "geoip-asn.dat", + "wantedList": [ + "cloudflare", + "cloudfront", + "facebook", + "fastly", + "google", + "netflix", + "telegram", + "ddos-guard", + "yandex", + "twitter" + ] + } + }, + { + "type": "v2rayGeoIPDat", + "action": "output", + "args": { + "outputDir": "./output", + "outputName": "geoip-only-blocked.dat", + "wantedList": ["ru-blocked", "ru-blocked-community"] + } + }, + { + "type": "v2rayGeoIPDat", + "action": "output", + "args": { + "outputDir": "./output", + "oneFilePerList": true, + "wantedList": ["ru-blocked", "ru-blocked-community", "private"] + } + }, + { + "type": "v2rayGeoIPDat", + "action": "output", + "args": { + "oneFilePerList": true + } + }, + { + "type": "maxmindMMDB", + "action": "output", + "args": { + "outputDir": "./output", + "outputName": "Country.mmdb", + "overwriteList": [ + "ru-blocked", + "ru-blocked-community", + "private", + "cloudflare", + "cloudfront", + "facebook", + "fastly", + "google", + "netflix", + "telegram", + "ddos-guard", + "yandex", + "twitter" + ] + } + }, + { + "type": "maxmindMMDB", + "action": "output", + "args": { + "outputDir": "./output", + "outputName": "Country-asn.mmdb", + "wantedList": [ + "cloudflare", + "cloudfront", + "facebook", + "fastly", + "google", + "netflix", + "telegram", + "ddos-guard", + "yandex", + "twitter" + ] + } + }, + { + "type": "maxmindMMDB", + "action": "output", + "args": { + "outputDir": "./output", + "outputName": "Country-only-blocked.mmdb", + "wantedList": ["ru-blocked", "ru-blocked-community"] + } + }, + { + "type": "singboxSRS", + "action": "output" + }, + { + "type": "mihomoMRS", + "action": "output" + }, + { + "type": "text", + "action": "output" + }, + { + "type": "text", + "action": "output", + "args": { + "outputDir": "./output/nginx/allow", + "outputExtension": ".conf", + "addPrefixInLine": "allow ", + "addSuffixInLine": ";" + } + }, + { + "type": "text", + "action": "output", + "args": { + "outputDir": "./output/nginx/deny", + "outputExtension": ".conf", + "addPrefixInLine": "deny ", + "addSuffixInLine": ";" + } + }, + { + "type": "clashRuleSetClassical", + "action": "output" + }, + { + "type": "clashRuleSet", + "action": "output" + }, + { + "type": "surgeRuleSet", + "action": "output", + "args": { + "addSuffixInLine": ",no-resolve" + } + } + ] +} \ No newline at end of file