Update SpeedTest.ps1

This commit is contained in:
CristianD committed 2026-11-09 13:40:48 +00:00
1 parent 805748a00f
commit bdbcb439bb
1 file changed
+10 -9
+10 -9
View File
@@ -8,21 +8,22 @@ param(
Write-Host "Initializing HTTPS speed test via Cloudflare CDN..." -ForegroundColor Cyan
# 1. Latency (TTFB probe)
$wc = New-Object System.Net.WebClient
$stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
# IP Address Detection
try {
$null = $wc.DownloadString("https://speed.cloudflare.com/meta")
$latencyMs = [math]::Round($stopwatch.ElapsedMilliseconds)
Write-Host "Latency: $latencyMs ms" -ForegroundColor Yellow
$internalIP = (Get-NetIPAddress -AddressFamily IPv4 -InterfaceAlias * | Where-Object { $_.IPAddress -notlike "127.*" -and $_.IPAddress -notlike "169.254.*" } | Select-Object -First 1).IPAddress
$externalIP = ($wc.DownloadString("https://api.ipify.org")).Trim()
Write-Host "Internal IP: $internalIP" -ForegroundColor Yellow
Write-Host "External IP: $externalIP" -ForegroundColor Yellow
} catch {
Write-Warning "Latency probe failed: $_"
Write-Warning "Failed to resolve IP addresses: $_"
}
# 2. Download Test
# 1. Download Test
$downBytes = $DownloadMB * 1MB
Write-Host "Testing Download ($DownloadMB MB payload)..." -NoNewline
$stopwatch.Restart()
$stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
try {
$downData = $wc.DownloadData("https://speed.cloudflare.com/__down?bytes=$downBytes")
$stopwatch.Stop()
@@ -34,7 +35,7 @@ try {
Write-Warning "`nDownload failed: $_"
}
# 3. Upload Test
# 2. Upload Test
$upBytes = New-Object byte[] ($UploadMB * 1MB)
(New-Object System.Random).NextBytes($upBytes)
Write-Host "Testing Upload ($UploadMB MB payload)..." -NoNewline