< Summary - Kestrun — Combined Coverage

Information
Class: Public.Server.Set-KrServerNamedPipeOptions
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Server/Set-KrServerNamedPipeOptions.ps1
Tag: Kestrun/Kestrun@9d3a582b2d63930269564a7591aa77ef297cadeb
Line coverage
0%
Covered lines: 0
Uncovered lines: 25
Coverable lines: 25
Total lines: 105
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Server/Set-KrServerNamedPipeOptions.ps1

#LineLine coverage
 1<#
 2.SYNOPSIS
 3    Sets the named pipe options for a Kestrun server instance. (Windows Operating Systems only)
 4.DESCRIPTION
 5    This function sets the named pipe options for the specified Kestrun server instance, allowing for configuration of v
 6.PARAMETER Server
 7    The Kestrun server instance to configure. This parameter is mandatory and must be a valid server object.
 8.PARAMETER Options
 9    The NamedPipeTransportOptions object containing the desired named pipe configuration settings.
 10    This parameter is mandatory when using the 'Options' parameter set.
 11.PARAMETER ListenerQueueCount
 12    Specifies the number of named pipe listener queues to create for the server. This parameter is optional and can be s
 13.PARAMETER MaxReadBufferSize
 14    Specifies the maximum size, in bytes, of the read buffer for named pipe connections. This parameter is optional and 
 15.PARAMETER CurrentUserOnly
 16    If specified, the named pipe will only be accessible by the current user. This parameter is optional and can be left
 17.PARAMETER MaxWriteBufferSize
 18    Specifies the maximum size, in bytes, of the write buffer for named pipe connections. This parameter is optional and
 19.PARAMETER PipeSecurity
 20    Specifies the PipeSecurity object to apply to the named pipe. This parameter is optional and can be set to a specifi
 21.PARAMETER PassThru
 22    If specified, the cmdlet will return the modified server instance after applying the named pipe options.
 23.OUTPUTS
 24    [Kestrun.Hosting.KestrunHost]
 25    The modified Kestrun server instance with the updated named pipe options.
 26.EXAMPLE
 27    Set-KrServerNamedPipeOptions -Server $server -ListenerQueueCount 5 -MaxReadBufferSize 65536
 28    This command sets the named pipe options for the specified Kestrun server instance, configuring the listener queue c
 29.EXAMPLE
 30    Set-KrServerNamedPipeOptions -Server $server -CurrentUserOnly
 31    This command configures the named pipe options for the specified Kestrun server instance to restrict access to the c
 32.NOTES
 33    This function is for Windows Operating Systems only, as named pipes are not supported on Unix-based systems.
 34    The named pipe options will be applied to the server's options and will be used when the server is started to listen
 35    The named pipe transport options can be configured to optimize performance and security based on the specific requir
 36    The named pipe transport options can be set either by providing a complete NamedPipeTransportOptions object
 37    This function is designed to be used in the context of a Kestrun server setup and allows for flexible configuration 
 38#>
 39function Set-KrServerNamedPipeOptions {
 40    [KestrunRuntimeApi('Definition')]
 41    [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '')]
 42    [CmdletBinding(defaultParameterSetName = 'Items')]
 43    param(
 44        [Parameter(Mandatory = $false, ValueFromPipeline = $true)]
 45        [Kestrun.Hosting.KestrunHost]$Server,
 46        [Parameter(Mandatory = $true, ParameterSetName = 'Options')]
 47        [Microsoft.AspNetCore.Server.Kestrel.Transport.NamedPipes.NamedPipeTransportOptions]$Options,
 48        [Parameter( ParameterSetName = 'Items')]
 49        [int]$ListenerQueueCount,
 50        [Parameter( ParameterSetName = 'Items')]
 51        [long]$MaxReadBufferSize,
 52        [Parameter( ParameterSetName = 'Items')]
 53        [switch]$CurrentUserOnly,
 54        [Parameter( ParameterSetName = 'Items')]
 55        [long]$MaxWriteBufferSize,
 56        [Parameter( ParameterSetName = 'Items')]
 57        [System.IO.Pipes.PipeSecurity]$PipeSecurity,
 58        [Parameter()]
 59        [switch]$PassThru
 60    )
 61    begin {
 062        if (-not $IsWindows) {
 063            Write-Warning 'This function is for Windows Operating Systems only, as named pipes are not supported nativel
 64        }
 65        # Ensure the server instance is resolved
 066        $Server = Resolve-KestrunServer -Server $Server
 067        if ($null -eq $Server) {
 068            throw 'Server is not initialized. Please ensure the server is configured before setting options.'
 69        }
 70    }
 71    process {
 072        if ($PSCmdlet.ParameterSetName -eq 'Items') {
 073            $Options = [Microsoft.AspNetCore.Server.Kestrel.Transport.NamedPipes.NamedPipeTransportOptions]::new()
 074            if ($null -ne $ListenerQueueCount) {
 075                Write-KrLog -Logger $Server.HostLogger -Level Verbose -Message "Setting NamedPipeOptions.ListenerQueueCo
 076                $options.ListenerQueueCount = $ListenerQueueCount
 77            }
 078            if ($null -ne $MaxReadBufferSize) {
 079                Write-KrLog -Logger $Server.HostLogger -Level Verbose -Message "Setting NamedPipeOptions.MaxReadBufferSi
 080                $options.MaxReadBufferSize = $MaxReadBufferSize
 81            }
 082            if ($CurrentUserOnly.IsPresent) {
 083                Write-KrLog -Logger $Server.HostLogger -Level Verbose -Message "Setting NamedPipeOptions.CurrentUserOnly
 084                $Options.CurrentUserOnly = $true
 85            }
 086            if ($null -ne $MaxWriteBufferSize) {
 087                Write-KrLog -Logger $Server.HostLogger -Level Verbose -Message "Setting NamedPipeOptions.MaxWriteBufferS
 088                $Options.MaxWriteBufferSize = $MaxWriteBufferSize
 89            }
 090            if ($null -ne $PipeSecurity) {
 091                Write-KrLog -Logger $Server.HostLogger -Level Verbose -Message "Setting NamedPipeOptions.PipeSecurity to
 092                $Options.PipeSecurity = $PipeSecurity
 93            }
 94        }
 95
 096        $Server.Options.NamedPipeOptions = $Options
 97
 098        if ($PassThru.IsPresent) {
 99            # if the PassThru switch is specified, return the server instance
 100            # Return the modified server instance
 0101            return $Server
 102        }
 103    }
 104}
 105

Methods/Properties

Set-KrServerNamedPipeOptions()