From 9b440f02802b26136910cb6a5755b651700828df Mon Sep 17 00:00:00 2001 From: Loyalsoldier <10487845+Loyalsoldier@users.noreply.github.com> Date: Sun, 19 Jan 2025 08:02:42 +0800 Subject: [PATCH] Feat: use free DB-IP lite country MMDB database For more details, see https://github.com/v2fly/geoip/issues/108 --- .github/workflows/build.yml | 23 ++++++++++++----------- .gitignore | 4 ++++ README.md | 10 ++++------ config.json | 6 ++---- 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 00d9b3e7..c1553ba6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,12 +2,13 @@ name: Build geoip.dat on: workflow_dispatch: schedule: - - cron: "0 0 * * 4" + - cron: "0 0 5 * *" push: branches: - master paths-ignore: - "README.md" + - "configuration.md" - ".gitignore" - "LICENSE" - "**/dependabot.yml" @@ -19,7 +20,7 @@ jobs: - name: Checkout codebase uses: actions/checkout@v4 - - name: Set up Go + - name: Setup Go uses: actions/setup-go@v5 with: go-version-file: go.mod @@ -28,20 +29,20 @@ jobs: run: | echo "TAG_NAME=$(date +%Y%m%d%H%M)" >> $GITHUB_ENV echo "RELEASE_NAME=$(date +%Y%m%d%H%M)" >> $GITHUB_ENV + echo "YEAR=$(date +%Y)" >> $GITHUB_ENV + echo "MONTH=$(date +%m)" >> $GITHUB_ENV shell: bash - - name: Get GeoLite2 - env: - LICENSE_KEY: ${{ secrets.MAXMIND_LICEHSE }} + - name: Get DB-IP Lite Country MMDB database run: | - curl -L "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country-CSV&license_key=${LICENSE_KEY}&suffix=zip" -o GeoLite2-Country-CSV.zip - unzip GeoLite2-Country-CSV.zip - rm -f GeoLite2-Country-CSV.zip - mv GeoLite2* geolite2 + curl -L -o dbip-country-lite.mmdb.gz "https://download.db-ip.com/free/dbip-country-lite-${{ env.YEAR }}-${{ env.MONTH }}.mmdb.gz" + gzip -d dbip-country-lite.mmdb.gz + mkdir -p db-ip + mv dbip-country-lite*.mmdb ./db-ip/dbip-country-lite.mmdb - - name: Build geoip.dat + - name: Build GeoIP files run: | - go run ./ + go run ./ -c ./config.json - name: Generate sha256 checksum for dat files run: | diff --git a/.gitignore b/.gitignore index 66c9fd92..804f894c 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,10 @@ # vendor/ geolite2/ +db-ip/ output/ tmp/ geoip +*.mmdb +*.dat +*.sha256sum diff --git a/README.md b/README.md index 62ead3ea..e07ba177 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # GeoIP for V2Ray -This project releases GeoIP files automatically every Thursday for routing purpose in Project V. It also provides a command line interface(CLI) tool for users to customize their own GeoIP files. +This project releases GeoIP files monthly for routing purpose in Project V. It also provides a command line interface(CLI) tool for users to customize their own GeoIP files. ## Download links @@ -168,10 +168,8 @@ All available output formats: - v2rayGeoIPDat (Convert data to V2Ray GeoIP dat format) ``` -## Notice - -This product includes GeoLite2 data created by MaxMind, available from [MaxMind](https://www.maxmind.com). - ## License -[CC-BY-SA-4.0](https://creativecommons.org/licenses/by-sa/4.0/) +This project is licensed under [CC-BY-SA-4.0](https://creativecommons.org/licenses/by-sa/4.0/) license. + +The free [IP Geolocation data by DB-IP](https://db-ip.com) is licensed under [CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/) license. diff --git a/config.json b/config.json index 700c7826..60a169fa 100644 --- a/config.json +++ b/config.json @@ -1,12 +1,10 @@ { "input": [ { - "type": "maxmindGeoLite2CountryCSV", + "type": "dbipCountryMMDB", "action": "add", "args": { - "country": "./geolite2/GeoLite2-Country-Locations-en.csv", - "ipv4": "./geolite2/GeoLite2-Country-Blocks-IPv4.csv", - "ipv6": "./geolite2/GeoLite2-Country-Blocks-IPv6.csv" + "uri": "./db-ip/dbip-country-lite.mmdb" } }, {