Merge pull request #348 from Icinga:feature/improve_tcp_debugging

Feature: Improves debug output on TCP handling

Improves debugging output on TCP handling, to provide separate messages for incoming message size, message bytes and the send message back to the client.
This commit is contained in:
Lord Hepipud 2021-08-20 13:56:54 +02:00 committed by GitHub
commit e370fc9ad5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 11 deletions

View file

@ -40,6 +40,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
* [#338](https://github.com/Icinga/icinga-powershell-framework/pull/338) Improves various styles, outputs and view for the Icinga for Windows Management Console and fixes some spelling mistakes
* [#342](https://github.com/Icinga/icinga-powershell-framework/pull/342) Adds feature to print commands being executed by the Icinga Management Console with `l` and improves summary visualisation for better readability
* [#346](https://github.com/Icinga/icinga-powershell-framework/pull/346) Adds support for version names for snapshots
* [#348](https://github.com/Icinga/icinga-powershell-framework/pull/348) Improves debug output on TCP handling by separating several network messages into multiple messages and by logging the send message to the client
## 1.5.2 (2021-07-09)

View file

@ -31,7 +31,7 @@ function New-IcingaTCPClientRESTMessage()
);
}
$ResponseMeessage = -Join(
$ResponseMessage = -Join(
[string]::Format(
'HTTP/1.1 {0} {1}{2}',
$HTTPResponse,
@ -53,8 +53,10 @@ function New-IcingaTCPClientRESTMessage()
$HTMLContent
);
Write-IcingaDebugMessage -Message 'Sending message to client' -Objects $ResponseMessage;
# Encode our message before sending it
$UTF8Message = [System.Text.Encoding]::UTF8.GetBytes($ResponseMeessage);
$UTF8Message = [System.Text.Encoding]::UTF8.GetBytes($ResponseMessage);
return @{
'message' = $UTF8Message;

View file

@ -16,15 +16,14 @@ function Read-IcingaTCPStream()
# Get the maxium size of our buffer
[byte[]]$bytes = New-Object byte[] $ReadLength;
# Read the content of our SSL stream
$MessgeSize = $Stream.Read($bytes, 0, $ReadLength);
Write-IcingaDebugMessage -Message 'Network Stream message size and content in bytes' -Objects $MessgeSize, $bytes;
$MessageSize = $Stream.Read($bytes, 0, $ReadLength);
# Resize our array to the correct size
[byte[]]$resized = New-Object byte[] $MessgeSize;
[array]::Copy($bytes, 0, $resized, 0, $MessgeSize);
[byte[]]$resized = New-Object byte[] $MessageSize;
[array]::Copy($bytes, 0, $resized, 0, $MessageSize);
Write-IcingaDebugMessage -Message 'Network Stream message size' -Objects $MessageSize;
Write-IcingaDebugMessage -Message 'Network Stream message in bytes' -Objects $resized;
# Return our message content
return [System.Text.Encoding]::UTF8.GetString($resized);