From d515b22255c0cfd1d0034a880034f5b57f003efd Mon Sep 17 00:00:00 2001 From: LordHepipud Date: Thu, 22 Nov 2018 11:40:40 +0100 Subject: [PATCH] [#6]: Optimise message building for hello message --- core/include/ClientJobs.ps1 | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/core/include/ClientJobs.ps1 b/core/include/ClientJobs.ps1 index bcd8d19..d54c084 100644 --- a/core/include/ClientJobs.ps1 +++ b/core/include/ClientJobs.ps1 @@ -13,26 +13,26 @@ $ClientJobs | Add-Member -membertype ScriptMethod -name 'AddTicks' -value { $ClientJobs | Add-Member -membertype ScriptMethod -name 'WindowsHello' -value { param([string]$os, [string]$fqdn, [string]$version, [bool]$force); - [hashtable]$hello = @{ - 'os' = $os; - 'fqdn' = $fqdn; - 'version' = $version; - 'port' = $Icinga2.Config.'tcp.socket.port'; - }; - - [string]$token = $this.getAuthToken(); - if ([string]::isNullOrEmpty($token) -eq $FALSE) { - $hello.Add( - 'modules', - (New-Icinga-Monitoring -ListModules) - ) - } - if ($this.hello_counter -ge 30) { $this.hello_counter = 0; } if ($this.hello_counter -eq 0 -Or $force -eq $TRUE) { + [hashtable]$hello = @{ + 'os' = $os; + 'fqdn' = $fqdn; + 'version' = $version; + 'port' = $Icinga2.Config.'tcp.socket.port'; + }; + + [string]$token = $this.getAuthToken(); + if ([string]::isNullOrEmpty($token) -eq $FALSE) { + $hello.Add( + 'modules', + (New-Icinga-Monitoring -ListModules) + ) + } + $response = $Icinga2.ClientProtocol.NewRequest( @('X-Windows-Hello: 1'), ($hello | ConvertTo-Json -Depth 2 -Compress),