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:
1 parent
d56745bc86
commit
759e3e7232
3 files changed
+65177
-17771
No files matched your search
Binary file not shown.
+65154
-17765
File diff suppressed because it is too large.
Load diff
+23
-6
@@ -18,20 +18,29 @@ error_exit() {
|
||||
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_dat() {
|
||||
TMPDIR=$(mktemp -d)
|
||||
TMPDIR=$(mktemp -d "${TMPDIR:-/tmp}/compile_dat.XXXXXX")
|
||||
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
|
||||
if [[ -d ${GEOSITE} ]]; then
|
||||
echo "Updating geosite repository..."
|
||||
(cd "${GEOSITE}" && git pull)
|
||||
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
|
||||
|
||||
echo "Running geosite generation..."
|
||||
(cd "${GEOSITE}" && go run main.go)
|
||||
|
||||
# Update geosite.dat if dlc.dat exists
|
||||
@@ -44,16 +53,19 @@ compile_dat() {
|
||||
|
||||
# Install geoip if not already installed
|
||||
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
|
||||
|
||||
cd "$TMPDIR"
|
||||
|
||||
# Download and process GeoLite2 data
|
||||
echo "Downloading GeoLite2 data..."
|
||||
curl -L -O http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country-CSV.zip
|
||||
unzip -q GeoLite2-Country-CSV.zip
|
||||
mkdir geoip && mv *.csv geoip/
|
||||
|
||||
echo "Generating geoip.dat..."
|
||||
"$GOPATH/bin/geoip" \
|
||||
--country=./geoip/GeoLite2-Country-Locations-en.csv \
|
||||
--ipv4=./geoip/GeoLite2-Country-Blocks-IPv4.csv \
|
||||
@@ -72,11 +84,13 @@ compile_dat() {
|
||||
|
||||
# Download data function
|
||||
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 \
|
||||
| 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 \
|
||||
| xargs wget -O "$DATADIR/geosite.dat"
|
||||
}
|
||||
@@ -84,7 +98,10 @@ download_dat() {
|
||||
# Main execution logic
|
||||
ACTION="${1:-download}"
|
||||
|
||||
check_dependencies
|
||||
|
||||
case $ACTION in
|
||||
"download") download_dat ;;
|
||||
"compile") compile_dat ;;
|
||||
*) echo "Invalid action: $ACTION" ; exit 1 ;;
|
||||
esac
|
||||
Reference in new issue
Block a user