Merge pull request #5416 from BaronGreenback/SubnetOverlappFix

(cherry picked from commit 19e7ebb279)
Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
This commit is contained in:
Joshua M. Boniface
2021-04-11 13:29:00 -04:00
parent d63fb437c6
commit e78fa8c3ef
3 changed files with 39 additions and 23 deletions

View File

@@ -32,9 +32,11 @@ namespace MediaBrowser.Common.Net
/// </summary>
/// <param name="source">The <see cref="Collection{IPObject}"/>.</param>
/// <param name="item">Item to add.</param>
public static void AddItem(this Collection<IPObject> source, IPObject item)
/// <param name="itemsAreNetworks">If <c>true</c> the values are treated as subnets.
/// If <b>false</b> items are addresses.</param>
public static void AddItem(this Collection<IPObject> source, IPObject item, bool itemsAreNetworks = true)
{
if (!source.ContainsAddress(item))
if (!source.ContainsAddress(item) || !itemsAreNetworks)
{
source.Add(item);
}
@@ -195,8 +197,9 @@ namespace MediaBrowser.Common.Net
/// </summary>
/// <param name="source">The <see cref="Collection{IPObject}"/>.</param>
/// <param name="excludeList">Items to exclude.</param>
/// <param name="isNetwork">Collection is a network collection.</param>
/// <returns>A new collection, with the items excluded.</returns>
public static Collection<IPObject> Exclude(this Collection<IPObject> source, Collection<IPObject> excludeList)
public static Collection<IPObject> Exclude(this Collection<IPObject> source, Collection<IPObject> excludeList, bool isNetwork)
{
if (source.Count == 0 || excludeList == null)
{
@@ -221,7 +224,7 @@ namespace MediaBrowser.Common.Net
if (!found)
{
results.AddItem(outer);
results.AddItem(outer, isNetwork);
}
}