Skip to content

Instantly share code, notes, and snippets.

@4piu
Created January 23, 2022 02:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save 4piu/e0ea1e53a52ee1041dd74d27b1ad56d5 to your computer and use it in GitHub Desktop.
Save 4piu/e0ea1e53a52ee1041dd74d27b1ad56d5 to your computer and use it in GitHub Desktop.
Update geoip and geosite dat file for Xray
# 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