diff --git a/SpeedTest.ps1 b/SpeedTest.ps1 index a114f26..eeaf37b 100644 --- a/SpeedTest.ps1 +++ b/SpeedTest.ps1 @@ -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