mirror of
https://github.com/2dust/AndroidLibXrayLite.git
synced 2025-06-28 14:19:51 +00:00
Geofiles: Switch to Loyalsoldier's v2ray-rules-dat (#132)
* Geofiles: Switch to Loyalsoldier's v2ray-rules-dat * Update gen_assets.sh * Update gen_assets.sh * Update gen_assets.sh * Update gen_assets.sh * Refactoring Names * Update libv2ray_main.go * Synchronization optimization and code reduction Synchronization optimization and code reduction * Update libv2ray_support.go * Update libv2ray_support_test.go * Update libv2ray_support_test.go * Revert libv2ray_main.go * Revert libv2ray_support.go * Revert libv2ray_support_test.go
This commit is contained in:
parent
d56745bc86
commit
759e3e7232
3 changed files with 65178 additions and 17772 deletions
BIN
assets/geoip.dat
BIN
assets/geoip.dat
Binary file not shown.
82919
assets/geosite.dat
82919
assets/geosite.dat
File diff suppressed because one or more lines are too long
|
@ -18,20 +18,29 @@ error_exit() {
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Check for required dependencies
|
||||||
|
check_dependencies() {
|
||||||
|
command -v jq >/dev/null 2>&1 || { echo >&2 "jq is required but it's not installed. Aborting."; exit 1; }
|
||||||
|
command -v go >/dev/null 2>&1 || { echo >&2 "Go is required but it's not installed. Aborting."; exit 1; }
|
||||||
|
}
|
||||||
|
|
||||||
# Compile data function
|
# Compile data function
|
||||||
compile_dat() {
|
compile_dat() {
|
||||||
TMPDIR=$(mktemp -d)
|
TMPDIR=$(mktemp -d "${TMPDIR:-/tmp}/compile_dat.XXXXXX")
|
||||||
trap 'error_exit' ERR
|
trap 'error_exit' ERR
|
||||||
|
|
||||||
local GEOSITE="${GOPATH}/src/github.com/v2ray/domain-list-community"
|
local GEOSITE="${GOPATH}/src/github.com/Loyalsoldier/v2ray-rules-dat"
|
||||||
|
|
||||||
# Clone or update the geosite repository
|
# Clone or update the geosite repository
|
||||||
if [[ -d ${GEOSITE} ]]; then
|
if [[ -d ${GEOSITE} ]]; then
|
||||||
|
echo "Updating geosite repository..."
|
||||||
(cd "${GEOSITE}" && git pull)
|
(cd "${GEOSITE}" && git pull)
|
||||||
else
|
else
|
||||||
git clone https://github.com/v2ray/domain-list-community.git "${GEOSITE}"
|
echo "Cloning geosite repository..."
|
||||||
|
git clone https://github.com/Loyalsoldier/v2ray-rules-dat.git "${GEOSITE}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "Running geosite generation..."
|
||||||
(cd "${GEOSITE}" && go run main.go)
|
(cd "${GEOSITE}" && go run main.go)
|
||||||
|
|
||||||
# Update geosite.dat if dlc.dat exists
|
# Update geosite.dat if dlc.dat exists
|
||||||
|
@ -44,16 +53,19 @@ compile_dat() {
|
||||||
|
|
||||||
# Install geoip if not already installed
|
# Install geoip if not already installed
|
||||||
if [[ ! -x "$GOPATH/bin/geoip" ]]; then
|
if [[ ! -x "$GOPATH/bin/geoip" ]]; then
|
||||||
go get -v -u github.com/v2ray/geoip
|
echo "Installing geoip..."
|
||||||
|
go install github.com/Loyalsoldier/geoip@latest
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd "$TMPDIR"
|
cd "$TMPDIR"
|
||||||
|
|
||||||
# Download and process GeoLite2 data
|
# Download and process GeoLite2 data
|
||||||
|
echo "Downloading GeoLite2 data..."
|
||||||
curl -L -O http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country-CSV.zip
|
curl -L -O http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country-CSV.zip
|
||||||
unzip -q GeoLite2-Country-CSV.zip
|
unzip -q GeoLite2-Country-CSV.zip
|
||||||
mkdir geoip && mv *.csv geoip/
|
mkdir geoip && mv *.csv geoip/
|
||||||
|
|
||||||
|
echo "Generating geoip.dat..."
|
||||||
"$GOPATH/bin/geoip" \
|
"$GOPATH/bin/geoip" \
|
||||||
--country=./geoip/GeoLite2-Country-Locations-en.csv \
|
--country=./geoip/GeoLite2-Country-Locations-en.csv \
|
||||||
--ipv4=./geoip/GeoLite2-Country-Blocks-IPv4.csv \
|
--ipv4=./geoip/GeoLite2-Country-Blocks-IPv4.csv \
|
||||||
|
@ -72,11 +84,13 @@ compile_dat() {
|
||||||
|
|
||||||
# Download data function
|
# Download data function
|
||||||
download_dat() {
|
download_dat() {
|
||||||
wget -qO - https://api.github.com/repos/v2ray/geoip/releases/latest \
|
echo "Downloading geoip.dat..."
|
||||||
|
wget -qO - https://api.github.com/repos/Loyalsoldier/v2ray-rules-dat/releases/latest \
|
||||||
| jq -r .assets[].browser_download_url | grep geoip.dat \
|
| jq -r .assets[].browser_download_url | grep geoip.dat \
|
||||||
| xargs wget -O "$DATADIR/geoip.dat"
|
| xargs wget -O "$DATADIR/geoip.dat"
|
||||||
|
|
||||||
wget -qO - https://api.github.com/repos/v2ray/domain-list-community/releases/latest \
|
echo "Downloading geosite.dat..."
|
||||||
|
wget -qO - https://api.github.com/repos/Loyalsoldier/v2ray-rules-dat/releases/latest \
|
||||||
| grep browser_download_url | cut -d '"' -f 4 \
|
| grep browser_download_url | cut -d '"' -f 4 \
|
||||||
| xargs wget -O "$DATADIR/geosite.dat"
|
| xargs wget -O "$DATADIR/geosite.dat"
|
||||||
}
|
}
|
||||||
|
@ -84,7 +98,10 @@ download_dat() {
|
||||||
# Main execution logic
|
# Main execution logic
|
||||||
ACTION="${1:-download}"
|
ACTION="${1:-download}"
|
||||||
|
|
||||||
|
check_dependencies
|
||||||
|
|
||||||
case $ACTION in
|
case $ACTION in
|
||||||
"download") download_dat ;;
|
"download") download_dat ;;
|
||||||
"compile") compile_dat ;;
|
"compile") compile_dat ;;
|
||||||
|
*) echo "Invalid action: $ACTION" ; exit 1 ;;
|
||||||
esac
|
esac
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue