Minor updates to collect-networking-logs.ps1

* enable log collection to work offline (using local copies of networking.sh and wsl_networking.wprp, if existing)
* enable alternative mechanism to end log collection, in addition to keypress - termination of process tcpdump.
This commit is contained in:
Slavy Mihov 2024-03-04 10:36:03 -08:00 committed by GitHub
parent 6c800da5c8
commit 5c5e6dcacf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 30 additions and 6 deletions

View File

@ -11,9 +11,26 @@ mkdir -p $folder
$logProfile = "$folder/wsl_networking.wprp"
$networkingBashScript = "$folder/networking.sh"
# Download supporting files
Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/wsl_networking.wprp" -OutFile $logProfile
Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/networking.sh" -OutFile $networkingBashScript
# Copy/Download supporting files
if (Test-Path "$PSScriptRoot/wsl_networking.wprp")
{
Copy-Item "$PSScriptRoot/wsl_networking.wprp" $logProfile
}
else
{
Write-Host -ForegroundColor Yellow "wsl_networking.wprp not found in the current directory. Downloading it from GitHub."
Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/wsl_networking.wprp" -OutFile $logProfile
}
if (Test-Path "$PSScriptRoot/networking.sh")
{
Copy-Item "$PSScriptRoot/networking.sh" $networkingBashScript
}
else
{
Write-Host -ForegroundColor Yellow "networking.sh not found in the current directory. Downloading it from GitHub."
Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/networking.sh" -OutFile $networkingBashScript
}
# Retrieve WSL version and wslconfig file
get-appxpackage MicrosoftCorporationII.WindowsSubsystemforLinux > $folder/appxpackage.txt
@ -105,9 +122,16 @@ try
183 # Application 2
$Key = $null
while ($Key -Eq $null -Or $Key.VirtualKeyCode -Eq $null -Or $KeysToIgnore -Contains $Key.VirtualKeyCode)
while (($Key -Eq $null -Or $Key.VirtualKeyCode -Eq $null -Or $KeysToIgnore -Contains $Key.VirtualKeyCode) -and ($null -eq $tcpdumpProcess -or $tcpdumpProcess.HasExited -eq $false))
{
$Key = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
if ([console]::KeyAvailable)
{
$Key = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown')
}
else
{
Start-Sleep -Seconds 1
}
}
Write-Host "`nSaving logs..."
@ -238,4 +262,4 @@ $logArchive = "$(Resolve-Path $folder).zip"
Compress-Archive -Path $folder -DestinationPath $logArchive
Remove-Item $folder -Recurse
Write-Host -ForegroundColor Green "Logs saved in: $logArchive. Please attach that file to the GitHub issue."
Write-Host -ForegroundColor Green "Logs saved in: $logArchive. Please attach that file to the GitHub issue."