File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -49,8 +49,20 @@ if ([string]::IsNullOrWhiteSpace($agenttag)) {
49
49
}
50
50
}
51
51
# Region判断
52
- $ipapi = Invoke-RestMethod - Uri " https://api.myip.com/" - UserAgent " Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.163 Safari/535.1"
53
- $region = $ipapi.cc
52
+ $ipapi = " "
53
+ $region = " Unknown"
54
+ foreach ($url in (" https://dash.cloudflare.com/cdn-cgi/trace" , " https://cf-ns.com/cdn-cgi/trace" , " https://1.0.0.1/cdn-cgi/trace" )) {
55
+ try {
56
+ $ipapi = Invoke-RestMethod - Uri $url - TimeoutSec 5 - UseBasicParsing
57
+ if ($ipapi -match " loc=(\w+)" ) {
58
+ $region = $Matches [1 ]
59
+ break
60
+ }
61
+ }
62
+ catch {
63
+ Write-Host " Error occurred while querying $url : $_ "
64
+ }
65
+ }
54
66
echo $ipapi
55
67
if ($region -ne " CN" ){
56
68
$download = " https://github.com/$agentrepo /releases/download/$agenttag /$file "
You can’t perform that action at this time.
0 commit comments