icinga-powershell-framework/lib/webserver/New-IcingaTCPSocket.psm1
Lord Hepipud 3d875639e4 Feature Requests: Add Proxy Server support
Also re-arranges web content by using old content from lib/web into lib/webserver, while new lib/web contains the proxy configuration.
Fixes #19
2020-11-19 17:16:33 +01:00

33 lines
762 B
PowerShell

function New-IcingaTCPSocket()
{
param(
[int]$Port = 0,
[switch]$Start = $FALSE
);
if ($Port -eq 0) {
throw 'Please specify a valid port to open a TCP socket for';
}
$TCPSocket = [System.Net.Sockets.TcpListener]$Port;
Write-IcingaDebugMessage -Message (
[string]::Format(
'Creating new TCP socket on Port {0}. Endpoint configuration {1}',
$Port,
$TCPSocket.LocalEndpoint
)
);
if ($Start) {
Write-IcingaDebugMessage -Message (
[string]::Format(
'Starting TCP socket for endpoint {0}',
$TCPSocket.LocalEndpoint
)
);
$TCPSocket.Start();
}
return $TCPSocket;
}