hi,
your code is not IPv6 save:
if($GelfServer -notmatch "^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$")
{
$GelfServer = [String]$([System.Net.Dns]::GetHostAddressesAsync($GelfServer)).Result[0]
}
# Create a UDP client to be used to send data
$Address = [system.net.IPAddress]::Parse($GelfServer)
$EndPoint = New-Object System.Net.IPEndPoint($Address, $Port)
$UdpClient = new-Object System.Net.Sockets.UdpClient
....
$UDPclient.SendAsync($CompressedJSON, $CompressedJSON.Length,$EndPoint) | Out-Null
- The regex did not match IPv6 addresses
- New-Object System.Net.IPEndPoint($Address, $Port) need the right address family
Why not use [system.net.IPAddress]::Parse($GelfServer) instead of the regex?
Then check if Address is IPv4 or IPv6 and set the right address family?
hi,
your code is not IPv6 save:
Why not use [system.net.IPAddress]::Parse($GelfServer) instead of the regex?
Then check if Address is IPv4 or IPv6 and set the right address family?