diff options
Diffstat (limited to 'Emby.Server.Implementations/Networking')
5 files changed, 29 insertions, 23 deletions
diff --git a/Emby.Server.Implementations/Networking/IPNetwork/BigIntegerExt.cs b/Emby.Server.Implementations/Networking/IPNetwork/BigIntegerExt.cs index 447cbf403..e4e944839 100644 --- a/Emby.Server.Implementations/Networking/IPNetwork/BigIntegerExt.cs +++ b/Emby.Server.Implementations/Networking/IPNetwork/BigIntegerExt.cs @@ -1,11 +1,10 @@ +using System; using System.Collections.Generic; +using System.Numerics; +using System.Text; -namespace System.Net +namespace Emby.Server.Implementations.Networking.IPNetwork { - using System; - using System.Numerics; - using System.Text; - /// <summary> /// Extension methods to convert <see cref="BigInteger"/> /// instances to hexadecimal, octal, and binary strings. diff --git a/Emby.Server.Implementations/Networking/IPNetwork/IPAddressCollection.cs b/Emby.Server.Implementations/Networking/IPNetwork/IPAddressCollection.cs index c5853135c..a0c5f73af 100644 --- a/Emby.Server.Implementations/Networking/IPNetwork/IPAddressCollection.cs +++ b/Emby.Server.Implementations/Networking/IPNetwork/IPAddressCollection.cs @@ -1,8 +1,10 @@ +using System; using System.Collections; using System.Collections.Generic; +using System.Net; using System.Numerics; -namespace System.Net +namespace Emby.Server.Implementations.Networking.IPNetwork { public class IPAddressCollection : IEnumerable<IPAddress>, IEnumerator<IPAddress> { @@ -29,7 +31,7 @@ namespace System.Net { throw new ArgumentOutOfRangeException(nameof(i)); } - byte width = this._ipnetwork.AddressFamily == Sockets.AddressFamily.InterNetwork ? (byte)32 : (byte)128; + byte width = this._ipnetwork.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork ? (byte)32 : (byte)128; var ipn = this._ipnetwork.Subnet(width); return ipn[i].Network; } diff --git a/Emby.Server.Implementations/Networking/IPNetwork/IPNetwork.cs b/Emby.Server.Implementations/Networking/IPNetwork/IPNetwork.cs index 16f39daf7..d6de61c0c 100644 --- a/Emby.Server.Implementations/Networking/IPNetwork/IPNetwork.cs +++ b/Emby.Server.Implementations/Networking/IPNetwork/IPNetwork.cs @@ -1,10 +1,12 @@ +using System; using System.Collections.Generic; using System.IO; +using System.Net; using System.Net.Sockets; using System.Numerics; using System.Text.RegularExpressions; -namespace System.Net +namespace Emby.Server.Implementations.Networking.IPNetwork { /// <summary> /// IP Network utility class. @@ -60,7 +62,7 @@ namespace System.Net get { - int width = this._family == Sockets.AddressFamily.InterNetwork ? 4 : 16; + int width = this._family == System.Net.Sockets.AddressFamily.InterNetwork ? 4 : 16; var uintBroadcast = this._network + this._netmask.PositiveReverse(width); return uintBroadcast; } @@ -73,7 +75,7 @@ namespace System.Net { get { - if (this._family == Sockets.AddressFamily.InterNetworkV6) + if (this._family == System.Net.Sockets.AddressFamily.InterNetworkV6) { return null; } @@ -88,7 +90,7 @@ namespace System.Net { get { - var fisrt = this._family == Sockets.AddressFamily.InterNetworkV6 + var fisrt = this._family == System.Net.Sockets.AddressFamily.InterNetworkV6 ? this._network : (this.Usable <= 0) ? this._network : this._network + 1; return IPNetwork.ToIPAddress(fisrt, this._family); @@ -102,7 +104,7 @@ namespace System.Net { get { - var last = this._family == Sockets.AddressFamily.InterNetworkV6 + var last = this._family == System.Net.Sockets.AddressFamily.InterNetworkV6 ? this._broadcast : (this.Usable <= 0) ? this._network : this._broadcast - 1; return IPNetwork.ToIPAddress(last, this._family); @@ -117,7 +119,7 @@ namespace System.Net get { - if (this._family == Sockets.AddressFamily.InterNetworkV6) + if (this._family == System.Net.Sockets.AddressFamily.InterNetworkV6) { return this.Total; } @@ -136,7 +138,7 @@ namespace System.Net get { - int max = this._family == Sockets.AddressFamily.InterNetwork ? 32 : 128; + int max = this._family == System.Net.Sockets.AddressFamily.InterNetwork ? 32 : 128; var count = BigInteger.Pow(2, (max - _cidr)); return count; } @@ -161,7 +163,7 @@ namespace System.Net IPNetwork(BigInteger ipaddress, AddressFamily family, byte cidr) { - int maxCidr = family == Sockets.AddressFamily.InterNetwork ? 32 : 128; + int maxCidr = family == System.Net.Sockets.AddressFamily.InterNetwork ? 32 : 128; if (cidr > maxCidr) { throw new ArgumentOutOfRangeException(nameof(cidr)); @@ -930,7 +932,7 @@ namespace System.Net /// return; /// } - int maxCidr = family == Sockets.AddressFamily.InterNetwork ? 32 : 128; + int maxCidr = family == System.Net.Sockets.AddressFamily.InterNetwork ? 32 : 128; if (cidr > maxCidr) { if (tryParse == false) @@ -1303,7 +1305,7 @@ namespace System.Net return; } - int maxCidr = network._family == Sockets.AddressFamily.InterNetwork ? 32 : 128; + int maxCidr = network._family == System.Net.Sockets.AddressFamily.InterNetwork ? 32 : 128; if (cidr > maxCidr) { if (trySubnet == false) diff --git a/Emby.Server.Implementations/Networking/IPNetwork/IPNetworkCollection.cs b/Emby.Server.Implementations/Networking/IPNetwork/IPNetworkCollection.cs index 7d3106624..4cda421e5 100644 --- a/Emby.Server.Implementations/Networking/IPNetwork/IPNetworkCollection.cs +++ b/Emby.Server.Implementations/Networking/IPNetwork/IPNetworkCollection.cs @@ -1,8 +1,9 @@ +using System; using System.Collections; using System.Collections.Generic; using System.Numerics; -namespace System.Net +namespace Emby.Server.Implementations.Networking.IPNetwork { public class IPNetworkCollection : IEnumerable<IPNetwork>, IEnumerator<IPNetwork> { @@ -25,7 +26,7 @@ namespace System.Net IPNetworkCollection(IPNetwork ipnetwork, byte cidrSubnet) { - int maxCidr = ipnetwork.AddressFamily == Sockets.AddressFamily.InterNetwork ? 32 : 128; + int maxCidr = ipnetwork.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork ? 32 : 128; if (cidrSubnet > maxCidr) { throw new ArgumentOutOfRangeException(nameof(cidrSubnet)); @@ -61,7 +62,7 @@ namespace System.Net throw new ArgumentOutOfRangeException(nameof(i)); } - var last = this._ipnetwork.AddressFamily == Sockets.AddressFamily.InterNetworkV6 + var last = this._ipnetwork.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6 ? this._lastUsable : this._broadcast; var increment = (last - this._network) / this.Count; var uintNetwork = this._network + ((increment + 1) * i); diff --git a/Emby.Server.Implementations/Networking/NetworkManager.cs b/Emby.Server.Implementations/Networking/NetworkManager.cs index f4b9f84dc..60cc9b88e 100644 --- a/Emby.Server.Implementations/Networking/NetworkManager.cs +++ b/Emby.Server.Implementations/Networking/NetworkManager.cs @@ -111,7 +111,8 @@ namespace Emby.Server.Implementations.Networking .OrderBy(i => i.AddressFamily == AddressFamily.InterNetwork ? 0 : 1) .ThenBy(i => listClone.IndexOf(i)) .Where(FilterIpAddress) - .DistinctBy(i => i.ToString()) + .GroupBy(i => i.ToString()) + .Select(x => x.First()) .ToList(); } @@ -280,7 +281,7 @@ namespace Emby.Server.Implementations.Networking if (normalizedSubnet.IndexOf('/') != -1) { - var ipnetwork = IPNetwork.Parse(normalizedSubnet); + var ipnetwork = IPNetwork.IPNetwork.Parse(normalizedSubnet); if (ipnetwork.Contains(address)) { return true; @@ -429,7 +430,8 @@ namespace Emby.Server.Implementations.Networking return new List<IPAddress>(); } - }).DistinctBy(i => i.ToString()) + }).GroupBy(i => i.ToString()) + .Select(x => x.First()) .ToList(); } |
