Przeglądaj źródła

Cleanup and fixes

Shadowghost 2 lat temu
rodzic
commit
59a86568d9

+ 10 - 2
Jellyfin.Networking/Manager/NetworkManager.cs

@@ -263,7 +263,7 @@ namespace Jellyfin.Networking.Manager
 
                 if (_interfaces.Count == 0)
                 {
-                    _logger.LogWarning("No interfaces information available. Using loopback.");
+                    _logger.LogWarning("No interface information available. Using loopback interface(s).");
 
                     if (IsIpv4Enabled && !IsIpv6Enabled)
                     {
@@ -450,6 +450,14 @@ namespace Jellyfin.Networking.Manager
                             _publishedServerUrls[new IPData(IPAddress.Any, new IPNetwork(IPAddress.Any, 0))] = replacement;
                             _publishedServerUrls[new IPData(IPAddress.IPv6Any, new IPNetwork(IPAddress.IPv6Any, 0))] = replacement;
                         }
+                        else if (string.Equals(parts[0], "internal", StringComparison.OrdinalIgnoreCase))
+                        {
+                            foreach (var lan in _lanSubnets)
+                            {
+                                var lanPrefix = lan.Prefix;
+                                _publishedServerUrls[new IPData(lanPrefix, new IPNetwork(lanPrefix, lan.PrefixLength))] = replacement;
+                            }
+                        }
                         else if (IPAddress.TryParse(ipParts[0], out IPAddress? result))
                         {
                             var data = new IPData(result, null);
@@ -469,7 +477,7 @@ namespace Jellyfin.Networking.Manager
                         }
                         else
                         {
-                            _logger.LogError("Unable to parse bind ip address. {Parts}", parts[1]);
+                            _logger.LogError("Unable to parse bind override: {Entry}", entry);
                         }
                     }
                 }

+ 4 - 4
Jellyfin.Server/Extensions/ApiServiceCollectionExtensions.cs

@@ -350,14 +350,14 @@ namespace Jellyfin.Server.Extensions
                 }
                 else if (NetworkExtensions.TryParseSubnets(new[] { allowedProxies[i] }, out var subnets))
                 {
-                    for (var j = 0; j < subnets.Count; j++)
+                    foreach (var subnet in subnets)
                     {
-                        AddIpAddress(config, options, subnets[j].Prefix, subnets[j].PrefixLength);
+                        AddIpAddress(config, options, subnet.Prefix, subnet.PrefixLength);
                     }
                 }
-                else if (NetworkExtensions.TryParseHost(allowedProxies[i], out var host))
+                else if (NetworkExtensions.TryParseHost(allowedProxies[i], out var addresses))
                 {
-                    foreach (var address in host)
+                    foreach (var address in addresses)
                     {
                         AddIpAddress(config, options, address, address.AddressFamily == AddressFamily.InterNetwork ? 32 : 128);
                     }

+ 20 - 22
MediaBrowser.Common/Net/INetworkManager.cs

@@ -17,14 +17,14 @@ namespace MediaBrowser.Common.Net
         event EventHandler NetworkChanged;
 
         /// <summary>
-        /// Gets a value indicating whether IPv6 is enabled.
+        /// Gets a value indicating whether IPv4 is enabled.
         /// </summary>
-        bool IsIpv6Enabled { get; }
+        bool IsIpv4Enabled { get; }
 
         /// <summary>
-        /// Gets a value indicating whether IPv4 is enabled.
+        /// Gets a value indicating whether IPv6 is enabled.
         /// </summary>
-        bool IsIpv4Enabled { get; }
+        bool IsIpv6Enabled { get; }
 
         /// <summary>
         /// Calculates the list of interfaces to use for Kestrel.
@@ -42,7 +42,7 @@ namespace MediaBrowser.Common.Net
         IReadOnlyList<IPData> GetLoopbacks();
 
         /// <summary>
-        /// Retrieves the bind address to use in system url's. (Server Discovery, PlayTo, LiveTV, SystemInfo)
+        /// Retrieves the bind address to use in system URLs. (Server Discovery, PlayTo, LiveTV, SystemInfo)
         /// If no bind addresses are specified, an internal interface address is selected.
         /// The priority of selection is as follows:-
         ///
@@ -56,40 +56,40 @@ namespace MediaBrowser.Common.Net
         ///
         /// If the source is from a public subnet address range and the user hasn't specified any bind addresses:-
         ///  The first public interface that isn't a loopback and contains the source subnet.
-        ///  The first public interface that isn't a loopback. Priority is given to interfaces with gateways.
-        ///  An internal interface if there are no public ip addresses.
+        ///  The first public interface that isn't a loopback.
+        ///  The first internal interface that isn't a loopback.
         ///
         /// If the source is from a private subnet address range and the user hasn't specified any bind addresses:-
         ///  The first private interface that contains the source subnet.
-        ///  The first private interface that isn't a loopback. Priority is given to interfaces with gateways.
+        ///  The first private interface that isn't a loopback.
         ///
         /// If no interfaces meet any of these criteria, then a loopback address is returned.
         ///
-        /// Interface that have been specifically excluded from binding are not used in any of the calculations.
+        /// Interfaces that have been specifically excluded from binding are not used in any of the calculations.
         /// </summary>
         /// <param name="source">Source of the request.</param>
         /// <param name="port">Optional port returned, if it's part of an override.</param>
-        /// <returns>IP Address to use, or loopback address if all else fails.</returns>
+        /// <returns>IP address to use, or loopback address if all else fails.</returns>
         string GetBindInterface(HttpRequest source, out int? port);
 
         /// <summary>
-        /// Retrieves the bind address to use in system url's. (Server Discovery, PlayTo, LiveTV, SystemInfo)
+        /// Retrieves the bind address to use in system URLs. (Server Discovery, PlayTo, LiveTV, SystemInfo)
         /// If no bind addresses are specified, an internal interface address is selected.
         /// (See <see cref="GetBindInterface(IPAddress, out int?)"/>.
         /// </summary>
         /// <param name="source">IP address of the request.</param>
         /// <param name="port">Optional port returned, if it's part of an override.</param>
-        /// <returns>IP Address to use, or loopback address if all else fails.</returns>
+        /// <returns>IP address to use, or loopback address if all else fails.</returns>
         string GetBindInterface(IPAddress source, out int? port);
 
         /// <summary>
-        /// Retrieves the bind address to use in system url's. (Server Discovery, PlayTo, LiveTV, SystemInfo)
+        /// Retrieves the bind address to use in system URLs. (Server Discovery, PlayTo, LiveTV, SystemInfo)
         /// If no bind addresses are specified, an internal interface address is selected.
         /// (See <see cref="GetBindInterface(IPAddress, out int?)"/>.
         /// </summary>
         /// <param name="source">Source of the request.</param>
         /// <param name="port">Optional port returned, if it's part of an override.</param>
-        /// <returns>IP Address to use, or loopback address if all else fails.</returns>
+        /// <returns>IP address to use, or loopback address if all else fails.</returns>
         string GetBindInterface(string source, out int? port);
 
         /// <summary>
@@ -100,7 +100,6 @@ namespace MediaBrowser.Common.Net
 
         /// <summary>
         /// Returns true if the address is part of the user defined LAN.
-        /// The configuration option TrustIP6Interfaces overrides this functions behaviour.
         /// </summary>
         /// <param name="address">IP to check.</param>
         /// <returns>True if endpoint is within the LAN range.</returns>
@@ -108,7 +107,6 @@ namespace MediaBrowser.Common.Net
 
         /// <summary>
         /// Returns true if the address is part of the user defined LAN.
-        /// The configuration option TrustIP6Interfaces overrides this functions behaviour.
         /// </summary>
         /// <param name="address">IP to check.</param>
         /// <returns>True if endpoint is within the LAN range.</returns>
@@ -119,21 +117,21 @@ namespace MediaBrowser.Common.Net
         /// eg. "eth1", or "enp3s5".
         /// </summary>
         /// <param name="intf">Interface name.</param>
-        /// <param name="result">Resultant object's ip addresses, if successful.</param>
+        /// <param name="result">Resulting object's IP addresses, if successful.</param>
         /// <returns>Success of the operation.</returns>
         bool TryParseInterface(string intf, out List<IPData>? result);
 
         /// <summary>
-        /// Returns all the internal bind interface addresses.
+        /// Returns all internal (LAN) bind interface addresses.
         /// </summary>
-        /// <returns>An internal list of interfaces addresses.</returns>
+        /// <returns>An list of internal (LAN) interfaces addresses.</returns>
         IReadOnlyList<IPData> GetInternalBindAddresses();
 
         /// <summary>
-        /// Checks to see if <paramref name="remoteIp"/> has access.
+        /// Checks if <paramref name="remoteIp"/> has access to the server.
         /// </summary>
-        /// <param name="remoteIp">IP Address of client.</param>
-        /// <returns><b>True</b> if has access, otherwise <b>false</b>.</returns>
+        /// <param name="remoteIp">IP address of the client.</param>
+        /// <returns><b>True</b> if it has access, otherwise <b>false</b>.</returns>
         bool HasRemoteAccess(IPAddress remoteIp);
     }
 }

+ 4 - 4
MediaBrowser.Common/Net/IPData.cs

@@ -12,9 +12,9 @@ namespace MediaBrowser.Common.Net
         /// <summary>
         /// Initializes a new instance of the <see cref="IPData"/> class.
         /// </summary>
-        /// <param name="address">An <see cref="IPAddress"/>.</param>
+        /// <param name="address">The <see cref="IPAddress"/>.</param>
         /// <param name="subnet">The <see cref="IPNetwork"/>.</param>
-        /// <param name="name">The object's name.</param>
+        /// <param name="name">The interface name.</param>
         public IPData(IPAddress address, IPNetwork? subnet, string name)
         {
             Address = address;
@@ -25,7 +25,7 @@ namespace MediaBrowser.Common.Net
         /// <summary>
         /// Initializes a new instance of the <see cref="IPData"/> class.
         /// </summary>
-        /// <param name="address">An <see cref="IPAddress"/>.</param>
+        /// <param name="address">The <see cref="IPAddress"/>.</param>
         /// <param name="subnet">The <see cref="IPNetwork"/>.</param>
         public IPData(IPAddress address, IPNetwork? subnet)
             : this(address, subnet, string.Empty)
@@ -53,7 +53,7 @@ namespace MediaBrowser.Common.Net
         public string Name { get; set; }
 
         /// <summary>
-        /// Gets the AddressFamily of this object.
+        /// Gets the AddressFamily of the object.
         /// </summary>
         public AddressFamily AddressFamily
         {

+ 0 - 1
MediaBrowser.Model/Net/ISocketFactory.cs

@@ -1,6 +1,5 @@
 #pragma warning disable CS1591
 
-using System.Collections.Generic;
 using System.Net;
 
 namespace MediaBrowser.Model.Net

+ 1 - 5
RSSDP/SsdpCommunicationsServer.cs

@@ -142,11 +142,7 @@ namespace Rssdp.Infrastructure
                 if (_BroadcastListenSockets != null)
                 {
                     _logger.LogInformation("{0} disposing _BroadcastListenSocket", GetType().Name);
-                    foreach (var socket in _BroadcastListenSockets)
-                    {
-                        socket.Dispose();
-                    }
-
+                    _BroadcastListenSockets.ForEach(s => s.Dispose());
                     _BroadcastListenSockets = null;
                 }
             }