Fixed selection of correct interface ip
This commit is contained in:
parent
b1f0c5eb49
commit
6087831aa6
|
@ -274,7 +274,7 @@ namespace Jellyfin.Networking.Manager
|
||||||
if (_bindExclusions.Count > 0)
|
if (_bindExclusions.Count > 0)
|
||||||
{
|
{
|
||||||
// Return all the interfaces except the ones specifically excluded.
|
// Return all the interfaces except the ones specifically excluded.
|
||||||
return _interfaceAddresses.Exclude(_bindExclusions);
|
return _interfaceAddresses.Exclude(_bindExclusions, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (individualInterfaces)
|
if (individualInterfaces)
|
||||||
|
@ -299,7 +299,7 @@ namespace Jellyfin.Networking.Manager
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove any excluded bind interfaces.
|
// Remove any excluded bind interfaces.
|
||||||
return _bindAddresses.Exclude(_bindExclusions);
|
return _bindAddresses.Exclude(_bindExclusions, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
@ -388,7 +388,7 @@ namespace Jellyfin.Networking.Manager
|
||||||
// Get the first LAN interface address that isn't a loopback.
|
// Get the first LAN interface address that isn't a loopback.
|
||||||
var interfaces = CreateCollection(
|
var interfaces = CreateCollection(
|
||||||
_interfaceAddresses
|
_interfaceAddresses
|
||||||
.Exclude(_bindExclusions)
|
.Exclude(_bindExclusions, false)
|
||||||
.Where(IsInLocalNetwork)
|
.Where(IsInLocalNetwork)
|
||||||
.OrderBy(p => p.Tag));
|
.OrderBy(p => p.Tag));
|
||||||
|
|
||||||
|
@ -396,6 +396,16 @@ namespace Jellyfin.Networking.Manager
|
||||||
{
|
{
|
||||||
if (haveSource)
|
if (haveSource)
|
||||||
{
|
{
|
||||||
|
foreach (var intf in interfaces)
|
||||||
|
{
|
||||||
|
if (intf.Address.Equals(source.Address))
|
||||||
|
{
|
||||||
|
result = FormatIP6String(intf.Address);
|
||||||
|
_logger.LogDebug("{Source}: GetBindInterface: Has found matching interface. {Result}", source, result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Does the request originate in one of the interface subnets?
|
// Does the request originate in one of the interface subnets?
|
||||||
// (For systems with multiple internal network cards, and multiple subnets)
|
// (For systems with multiple internal network cards, and multiple subnets)
|
||||||
foreach (var intf in interfaces)
|
foreach (var intf in interfaces)
|
||||||
|
@ -522,10 +532,10 @@ namespace Jellyfin.Networking.Manager
|
||||||
{
|
{
|
||||||
if (filter == null)
|
if (filter == null)
|
||||||
{
|
{
|
||||||
return _lanSubnets.Exclude(_excludedSubnets).AsNetworks();
|
return _lanSubnets.Exclude(_excludedSubnets, true).AsNetworks();
|
||||||
}
|
}
|
||||||
|
|
||||||
return _lanSubnets.Exclude(filter);
|
return _lanSubnets.Exclude(filter, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
@ -1018,7 +1028,7 @@ namespace Jellyfin.Networking.Manager
|
||||||
|
|
||||||
_logger.LogInformation("Defined LAN addresses : {0}", _lanSubnets.AsString());
|
_logger.LogInformation("Defined LAN addresses : {0}", _lanSubnets.AsString());
|
||||||
_logger.LogInformation("Defined LAN exclusions : {0}", _excludedSubnets.AsString());
|
_logger.LogInformation("Defined LAN exclusions : {0}", _excludedSubnets.AsString());
|
||||||
_logger.LogInformation("Using LAN addresses: {0}", _lanSubnets.Exclude(_excludedSubnets).AsNetworks().AsString());
|
_logger.LogInformation("Using LAN addresses: {0}", _lanSubnets.Exclude(_excludedSubnets, true).AsNetworks().AsString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1207,7 +1217,7 @@ namespace Jellyfin.Networking.Manager
|
||||||
private bool MatchesBindInterface(IPObject source, bool isInExternalSubnet, out string result)
|
private bool MatchesBindInterface(IPObject source, bool isInExternalSubnet, out string result)
|
||||||
{
|
{
|
||||||
result = string.Empty;
|
result = string.Empty;
|
||||||
var addresses = _bindAddresses.Exclude(_bindExclusions);
|
var addresses = _bindAddresses.Exclude(_bindExclusions, false);
|
||||||
|
|
||||||
int count = addresses.Count;
|
int count = addresses.Count;
|
||||||
if (count == 1 && (_bindAddresses[0].Equals(IPAddress.Any) || _bindAddresses[0].Equals(IPAddress.IPv6Any)))
|
if (count == 1 && (_bindAddresses[0].Equals(IPAddress.Any) || _bindAddresses[0].Equals(IPAddress.IPv6Any)))
|
||||||
|
@ -1292,7 +1302,7 @@ namespace Jellyfin.Networking.Manager
|
||||||
result = string.Empty;
|
result = string.Empty;
|
||||||
// Get the first WAN interface address that isn't a loopback.
|
// Get the first WAN interface address that isn't a loopback.
|
||||||
var extResult = _interfaceAddresses
|
var extResult = _interfaceAddresses
|
||||||
.Exclude(_bindExclusions)
|
.Exclude(_bindExclusions, false)
|
||||||
.Where(p => !IsInLocalNetwork(p))
|
.Where(p => !IsInLocalNetwork(p))
|
||||||
.OrderBy(p => p.Tag);
|
.OrderBy(p => p.Tag);
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace MediaBrowser.Common.Net
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="source">The <see cref="Collection{IPObject}"/>.</param>
|
/// <param name="source">The <see cref="Collection{IPObject}"/>.</param>
|
||||||
/// <param name="item">Item to add.</param>
|
/// <param name="item">Item to add.</param>
|
||||||
/// <param name="itemsAreNetworks">If <c>true</c> the values are treated as subnets.
|
/// <param name="itemsAreNetworks">If <c>true</c> the values are treated as subnets.
|
||||||
/// If <b>false</b> items are addresses.</param>
|
/// If <b>false</b> items are addresses.</param>
|
||||||
public static void AddItem(this Collection<IPObject> source, IPObject item, bool itemsAreNetworks = true)
|
public static void AddItem(this Collection<IPObject> source, IPObject item, bool itemsAreNetworks = true)
|
||||||
{
|
{
|
||||||
|
@ -192,8 +192,9 @@ namespace MediaBrowser.Common.Net
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="source">The <see cref="Collection{IPObject}"/>.</param>
|
/// <param name="source">The <see cref="Collection{IPObject}"/>.</param>
|
||||||
/// <param name="excludeList">Items to exclude.</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>
|
/// <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)
|
if (source.Count == 0 || excludeList == null)
|
||||||
{
|
{
|
||||||
|
@ -218,7 +219,7 @@ namespace MediaBrowser.Common.Net
|
||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
{
|
{
|
||||||
results.AddItem(outer);
|
results.AddItem(outer, isNetwork);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user