Skip to content

Commit

Permalink
NetworkTarget - Dual Mode IPv4 mapped addresses over IPv6 (#4922)
Browse files Browse the repository at this point in the history
  • Loading branch information
snakefoot authored May 13, 2022
1 parent eb1f8d3 commit 4091315
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/NLog/Internal/NetworkSenders/SocketProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ internal sealed class SocketProxy : ISocket, IDisposable
internal SocketProxy(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType)
{
_socket = new Socket(addressFamily, socketType, protocolType);
#if !NET35
if (addressFamily == AddressFamily.InterNetworkV6)
{
_socket.DualMode = true; // Allow for IPv4 mapped addresses over IPv6
}
#endif
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/NLog/Internal/NetworkSenders/UdpNetworkSender.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public UdpNetworkSender(string url, AddressFamily addressFamily)
protected internal virtual ISocket CreateSocket(IPAddress ipAddress)
{
var proxy = new SocketProxy(ipAddress.AddressFamily, SocketType.Dgram, ProtocolType.Udp);
if (ipAddress.Equals(IPAddress.Broadcast))
if (ipAddress.AddressFamily != AddressFamily.InterNetworkV6 && ipAddress.Equals(IPAddress.Broadcast))
{
proxy.UnderlyingSocket.EnableBroadcast = true;
}
Expand Down

0 comments on commit 4091315

Please sign in to comment.