Created
January 23, 2022 02:57
-
-
Save 4piu/e0ea1e53a52ee1041dd74d27b1ad56d5 to your computer and use it in GitHub Desktop.
Update geoip and geosite dat file for Xray
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# remote url | |
$GEOIP_URL="https://github.com/Loyalsoldier/v2ray-rules-dat/raw/release/geoip.dat" | |
$GEOSITE_URL="https://github.com/Loyalsoldier/v2ray-rules-dat/raw/release/geosite.dat" | |
# resource path | |
$GEOIP_PATH="C:\Users\WD-40\AppData\Local\qv2ray\vcore\geoip.dat" | |
$GEOSITE_PATH="C:\Users\WD-40\AppData\Local\qv2ray\vcore\geosite.dat" | |
# backup path | |
$GEOIP_BACKUP=$GEOIP_PATH+".bak" | |
$GEOSITE_BACKUP=$GEOSITE_PATH+".bak" | |
Write-Output ">>> Starting update dat file" | |
# backup | |
Copy-Item -Path $GEOIP_PATH -Destination $GEOIP_BACKUP -Force | |
Copy-Item -Path $GEOSITE_PATH -Destination $GEOSITE_BACKUP -Force | |
try { | |
# overwrite | |
Invoke-WebRequest -Uri $GEOIP_URL -OutFile $GEOIP_PATH | |
Invoke-WebRequest -Uri $GEOSITE_URL -OutFile $GEOSITE_PATH | |
Write-Output "<<< Update successful" | |
} catch { | |
Write-Output "Update failed" | |
# restore | |
Move-Item -Force $GEOIP_BACKUP $GEOIP_PATH | |
Move-Item -Force $GEOSITE_BACKUP $GEOSITE_PATH | |
exit 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment