diff options
| author | Bond_009 <bond.009@outlook.com> | 2019-08-09 23:16:24 +0200 |
|---|---|---|
| committer | Bond_009 <bond.009@outlook.com> | 2019-08-09 23:16:24 +0200 |
| commit | 2a58c643d24354ad8b6c45451bcedf82caa344c0 (patch) | |
| tree | 31d7cbb30889ccec40001de1cff5d0a6d326b0d4 /Emby.Server.Implementations/Networking/NetworkManager.cs | |
| parent | 779f0c637f4c280561029535a5b2160f34813b53 (diff) | |
Fix more warnings
Diffstat (limited to 'Emby.Server.Implementations/Networking/NetworkManager.cs')
| -rw-r--r-- | Emby.Server.Implementations/Networking/NetworkManager.cs | 38 |
1 files changed, 9 insertions, 29 deletions
diff --git a/Emby.Server.Implementations/Networking/NetworkManager.cs b/Emby.Server.Implementations/Networking/NetworkManager.cs index f613dc295..7d85a0666 100644 --- a/Emby.Server.Implementations/Networking/NetworkManager.cs +++ b/Emby.Server.Implementations/Networking/NetworkManager.cs @@ -425,47 +425,27 @@ namespace Emby.Server.Implementations.Networking var localEndPoint = new IPEndPoint(IPAddress.Any, 0); using (var udpClient = new UdpClient(localEndPoint)) { - var port = ((IPEndPoint)(udpClient.Client.LocalEndPoint)).Port; + var port = ((IPEndPoint)udpClient.Client.LocalEndPoint).Port; return port; } } - private List<string> _macAddresses; - public List<string> GetMacAddresses() + private List<PhysicalAddress> _macAddresses; + public List<PhysicalAddress> GetMacAddresses() { if (_macAddresses == null) { - _macAddresses = GetMacAddressesInternal(); + _macAddresses = GetMacAddressesInternal().ToList(); } + return _macAddresses; } - private static List<string> GetMacAddressesInternal() - { - return NetworkInterface.GetAllNetworkInterfaces() + private static IEnumerable<PhysicalAddress> GetMacAddressesInternal() + => NetworkInterface.GetAllNetworkInterfaces() .Where(i => i.NetworkInterfaceType != NetworkInterfaceType.Loopback) - .Select(i => - { - try - { - var physicalAddress = i.GetPhysicalAddress(); - - if (physicalAddress == null) - { - return null; - } - - return physicalAddress.ToString(); - } - catch (Exception) - { - //TODO Log exception. - return null; - } - }) - .Where(i => i != null) - .ToList(); - } + .Select(x => x.GetPhysicalAddress()) + .Where(x => x != null && x != PhysicalAddress.None); /// <summary> /// Parses the specified endpointstring. |
