Skip to content

Instantly share code, notes, and snippets.

@allex
Forked from maddie/update-v2ray-geo.sh
Last active July 14, 2023 07:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save allex/12011d02da2e8b605a6cb715debb35f8 to your computer and use it in GitHub Desktop.
Save allex/12011d02da2e8b605a6cb715debb35f8 to your computer and use it in GitHub Desktop.
Script for updating V2Ray geoip.dat and geosite.dat on OpenWRT
#!/bin/sh
# GistID: 12011d02da2e8b605a6cb715debb35f8
# GistURL: https://gist.github.com/allex/12011d02da2e8b605a6cb715debb35f8
LOGGER_TAG=v2ray-geodata-updater
log () {
echo "$@"
logger -t $LOGGER_TAG -- "$@"
}
download () {
url=$1
name=${2:-${url##*/}}
log "> downloading $name..."
if ! curl -o /tmp/"$name" -sfL "$url" ; then
log "failed to download latest $name, not updating!"
else
mv /tmp/"$name" "$name"
log "$name updated"
fi
}
log "fetching geoip urls..."
curl -sL -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/v2fly/geoip/releases/latest | \
grep browser_download_url | \
cut -d\" -f4 | \
grep -e "\.dat$" | \
while read -r url; do download "$url"; done
log "fetching geosite url..."
curl -sL -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/v2fly/domain-list-community/releases/latest | \
grep browser_download_url | \
cut -d\" -f4 | \
grep -e "\.dat$" | \
while read -r url; do
name=${url##*/}
if [ "$name" = "dlc.dat" ]; then
name=geosite.dat
fi
download "$url" "$name"
done
@allex
Copy link
Author

allex commented Jul 14, 2023

https://github.com/v2fly/v2ray-core/blob/master/.github/workflows/release.yml#L139

      - name: Download geo files
        run: |
          wget -O release/config/geoip.dat "https://raw.githubusercontent.com/v2fly/geoip/release/geoip.dat"
          wget -O release/config/geoip-only-cn-private.dat "https://raw.githubusercontent.com/v2fly/geoip/release/geoip-only-cn-private.dat"
          wget -O release/config/geosite.dat "https://raw.githubusercontent.com/v2fly/domain-list-community/release/dlc.dat"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment