Pārlūkot izejas kodu

Merge pull request #13382 from Shadowghost/fix-published-url-override

Fix interface selection
Joshua M. Boniface 4 mēneši atpakaļ
vecāks
revīzija
0394965753
1 mainītis faili ar 6 papildinājumiem un 3 dzēšanām
  1. 6 3
      src/Jellyfin.Networking/Manager/NetworkManager.cs

+ 6 - 3
src/Jellyfin.Networking/Manager/NetworkManager.cs

@@ -997,7 +997,9 @@ public class NetworkManager : INetworkManager, IDisposable
             // Get interface matching override subnet
             // Get interface matching override subnet
             var intf = _interfaces.OrderBy(x => x.Index).FirstOrDefault(x => data.Data.Subnet.Contains(x.Address));
             var intf = _interfaces.OrderBy(x => x.Index).FirstOrDefault(x => data.Data.Subnet.Contains(x.Address));
 
 
-            if (intf?.Address is not null)
+            if (intf?.Address is not null
+                || (data.Data.AddressFamily == AddressFamily.InterNetwork && data.Data.Address.Equals(IPAddress.Any))
+                || (data.Data.AddressFamily == AddressFamily.InterNetworkV6 && data.Data.Address.Equals(IPAddress.IPv6Any)))
             {
             {
                 // If matching interface is found, use override
                 // If matching interface is found, use override
                 bindPreference = data.OverrideUri;
                 bindPreference = data.OverrideUri;
@@ -1025,6 +1027,7 @@ public class NetworkManager : INetworkManager, IDisposable
         }
         }
 
 
         _logger.LogDebug("{Source}: Matching bind address override found: {Address}", source, bindPreference);
         _logger.LogDebug("{Source}: Matching bind address override found: {Address}", source, bindPreference);
+
         return true;
         return true;
     }
     }
 
 
@@ -1062,7 +1065,7 @@ public class NetworkManager : INetworkManager, IDisposable
                 // Check to see if any of the external bind interfaces are in the same subnet as the source.
                 // Check to see if any of the external bind interfaces are in the same subnet as the source.
                 // If none exists, this will select the first external interface if there is one.
                 // If none exists, this will select the first external interface if there is one.
                 bindAddress = externalInterfaces
                 bindAddress = externalInterfaces
-                    .OrderByDescending(x => x.Subnet.Contains(source))
+                    .OrderBy(x => x.Subnet.Contains(source))
                     .ThenBy(x => x.Index)
                     .ThenBy(x => x.Index)
                     .Select(x => x.Address)
                     .Select(x => x.Address)
                     .First();
                     .First();
@@ -1079,7 +1082,7 @@ public class NetworkManager : INetworkManager, IDisposable
             // Check to see if any of the internal bind interfaces are in the same subnet as the source.
             // Check to see if any of the internal bind interfaces are in the same subnet as the source.
             // If none exists, this will select the first internal interface if there is one.
             // If none exists, this will select the first internal interface if there is one.
             bindAddress = _interfaces.Where(x => IsInLocalNetwork(x.Address))
             bindAddress = _interfaces.Where(x => IsInLocalNetwork(x.Address))
-                .OrderByDescending(x => x.Subnet.Contains(source))
+                .OrderBy(x => x.Subnet.Contains(source))
                 .ThenBy(x => x.Index)
                 .ThenBy(x => x.Index)
                 .Select(x => x.Address)
                 .Select(x => x.Address)
                 .FirstOrDefault();
                 .FirstOrDefault();