From c28108f64e92cd8e1c89d77c9dfc8b6ce0ed7097 Mon Sep 17 00:00:00 2001 From: dysf888 <47450409+dysf888@users.noreply.github.com> Date: Fri, 29 Apr 2022 19:00:45 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=98=89=E6=96=B0=E5=A2=9Eregion=E5=88=A4?= =?UTF-8?q?=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 使用https://api.myip.com/ 无CF检查 $region -eq $null 暂未遇见,暂留 --- script/install.ps1 | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/script/install.ps1 b/script/install.ps1 index a77dae1..f685c38 100644 --- a/script/install.ps1 +++ b/script/install.ps1 @@ -13,7 +13,24 @@ $releases = "https://api.github.com/repos/$repo/releases" Write-Host "Determining latest nezha release" -BackgroundColor DarkGreen -ForegroundColor White [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 $tag = (Invoke-WebRequest -Uri $releases -UseBasicParsing | ConvertFrom-Json)[0].tag_name +#Region判断 +$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" +$region=$ipapi.cc +echo $ipapi +if($region -ne "CN"){ $download = "https://github.com/$repo/releases/download/$tag/$file" +Write-Host "Overseas machine("$region") direct connection!" -BackgroundColor DarkRed -ForegroundColor Green +echo $download +}elseif($region -eq $null){ +cls +$download = "https://ghproxy.com/github.com/$repo/releases/download/$tag/$file" +Write-Host "Error,Most of the time, it is caused by the domestic network environment,use ghproxy.com" -BackgroundColor DarkRed -ForegroundColor Green +echo $download +}else{ +$download = "https://ghproxy.com/github.com/$repo/releases/download/$tag/$file" +Write-Host "China's servers will be downloaded using the image address" -BackgroundColor DarkRed -ForegroundColor Green +echo $download +} Invoke-WebRequest $download -OutFile "C:\nezha.zip" #使用nssm安装服务 Invoke-WebRequest "http://nssm.cc/release/nssm-2.24.zip" -OutFile "C:\nssm.zip"