Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jdomnitz committed May 4, 2023
1 parent 53e99cf commit 7ef60f6
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/MulticastService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,16 @@ public MulticastService(Func<IEnumerable<NetworkInterface>, IEnumerable<NetworkI
/// </remarks>
public bool IgnoreDuplicateMessages { get; set; }

/// <summary>
/// Determines whether loopback interfaces should be excluded when other network interfaces are available
/// </summary>
/// <value>
/// <b>true</b> to always include loopback interfaces.
/// <b>false</b> to only include loopback interfaces when no other interfaces exist.
/// Defaults to <b>false</b>.
/// </value>
public static bool IncludeLoopbackInterfaces { get; set; } = false;

/// <summary>
/// Get the network interfaces that are useable.
/// </summary>
Expand All @@ -182,7 +192,7 @@ public static IEnumerable<NetworkInterface> GetNetworkInterfaces()
{
var nics = NetworkInterface.GetAllNetworkInterfaces()
.Where(nic => nic.OperationalStatus == OperationalStatus.Up)
.Where(nic => nic.NetworkInterfaceType != NetworkInterfaceType.Loopback)
.Where(nic => IncludeLoopbackInterfaces || (nic.NetworkInterfaceType != NetworkInterfaceType.Loopback))
.ToArray();
if (nics.Length > 0)
return nics;
Expand Down

0 comments on commit 7ef60f6

Please sign in to comment.