Fix testing
This commit is contained in:
parent
605bd80251
commit
b03bd7a299
|
@ -691,11 +691,11 @@ namespace Jellyfin.Networking.Manager
|
||||||
/// Checks the string to see if it matches any interface names.
|
/// Checks the string to see if it matches any interface names.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="token">String to check.</param>
|
/// <param name="token">String to check.</param>
|
||||||
/// <param name="index">Interface index number.</param>
|
/// <param name="index">Interface index numbers that match.</param>
|
||||||
/// <returns><c>true</c> if an interface name matches the token, <c>False</c> otherwise.</returns>
|
/// <returns><c>true</c> if an interface name matches the token, <c>False</c> otherwise.</returns>
|
||||||
private bool IsInterface(string token, out int index)
|
private bool IsInterface(string token, out List<int>? index)
|
||||||
{
|
{
|
||||||
index = -1;
|
index = null;
|
||||||
|
|
||||||
// Is it the name of an interface (windows) eg, Wireless LAN adapter Wireless Network Connection 1.
|
// Is it the name of an interface (windows) eg, Wireless LAN adapter Wireless Network Connection 1.
|
||||||
// Null check required here for automated testing.
|
// Null check required here for automated testing.
|
||||||
|
@ -712,13 +712,17 @@ namespace Jellyfin.Networking.Manager
|
||||||
if ((!partial && string.Equals(interfc, token, StringComparison.OrdinalIgnoreCase))
|
if ((!partial && string.Equals(interfc, token, StringComparison.OrdinalIgnoreCase))
|
||||||
|| (partial && interfc.StartsWith(token, true, CultureInfo.InvariantCulture)))
|
|| (partial && interfc.StartsWith(token, true, CultureInfo.InvariantCulture)))
|
||||||
{
|
{
|
||||||
index = interfcIndex;
|
if (index == null)
|
||||||
return true;
|
{
|
||||||
|
index = new List<int>();
|
||||||
|
}
|
||||||
|
|
||||||
|
index.Add(interfcIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return index != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -730,14 +734,14 @@ namespace Jellyfin.Networking.Manager
|
||||||
{
|
{
|
||||||
// Is it the name of an interface (windows) eg, Wireless LAN adapter Wireless Network Connection 1.
|
// Is it the name of an interface (windows) eg, Wireless LAN adapter Wireless Network Connection 1.
|
||||||
// Null check required here for automated testing.
|
// Null check required here for automated testing.
|
||||||
if (IsInterface(token, out int index))
|
if (IsInterface(token, out var index))
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Interface {Token} used in settings. Using its interface addresses.", token);
|
_logger.LogInformation("Interface {Token} used in settings. Using its interface addresses.", token);
|
||||||
|
|
||||||
// Replace interface tags with the interface IP's.
|
// Replace all the interface tags with the interface IP's.
|
||||||
foreach (IPNetAddress iface in _interfaceAddresses)
|
foreach (IPNetAddress iface in _interfaceAddresses)
|
||||||
{
|
{
|
||||||
if (Math.Abs(iface.Tag) == index
|
if (index!.Contains(Math.Abs(iface.Tag))
|
||||||
&& ((IsIP4Enabled && iface.Address.AddressFamily == AddressFamily.InterNetwork)
|
&& ((IsIP4Enabled && iface.Address.AddressFamily == AddressFamily.InterNetwork)
|
||||||
|| (IsIP6Enabled && iface.Address.AddressFamily == AddressFamily.InterNetworkV6)))
|
|| (IsIP6Enabled && iface.Address.AddressFamily == AddressFamily.InterNetworkV6)))
|
||||||
{
|
{
|
||||||
|
@ -918,10 +922,17 @@ namespace Jellyfin.Networking.Manager
|
||||||
{
|
{
|
||||||
// each virtual interface name must be pre-pended with the exclusion symbol !
|
// each virtual interface name must be pre-pended with the exclusion symbol !
|
||||||
var virtualInterfaceNames = config.VirtualInterfaceNames.Split(',').Select(p => '!' + p).ToArray();
|
var virtualInterfaceNames = config.VirtualInterfaceNames.Split(',').Select(p => '!' + p).ToArray();
|
||||||
var newList = new string[lanAddresses.Length + virtualInterfaceNames.Length];
|
if (lanAddresses.Length > 0)
|
||||||
Array.Copy(lanAddresses, newList, lanAddresses.Length);
|
{
|
||||||
Array.Copy(virtualInterfaceNames, 0, newList, lanAddresses.Length, virtualInterfaceNames.Length);
|
var newList = new string[lanAddresses.Length + virtualInterfaceNames.Length];
|
||||||
lanAddresses = newList;
|
Array.Copy(lanAddresses, newList, lanAddresses.Length);
|
||||||
|
Array.Copy(virtualInterfaceNames, 0, newList, lanAddresses.Length, virtualInterfaceNames.Length);
|
||||||
|
lanAddresses = newList;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lanAddresses = virtualInterfaceNames;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read and parse bind addresses and exclusions, removing ones that don't exist.
|
// Read and parse bind addresses and exclusions, removing ones that don't exist.
|
||||||
|
|
|
@ -60,7 +60,8 @@ namespace Jellyfin.Networking.Tests
|
||||||
[Theory]
|
[Theory]
|
||||||
[InlineData("192.168.1.208/24,-16,eth16:200.200.200.200/24,11,eth11", "192.168.1.0/24;200.200.200.0/24", "[192.168.1.208/24,200.200.200.200/24]")]
|
[InlineData("192.168.1.208/24,-16,eth16:200.200.200.200/24,11,eth11", "192.168.1.0/24;200.200.200.0/24", "[192.168.1.208/24,200.200.200.200/24]")]
|
||||||
[InlineData("192.168.1.208/24,-16,eth16:200.200.200.200/24,11,eth11", "192.168.1.0/24", "[192.168.1.208/24]")]
|
[InlineData("192.168.1.208/24,-16,eth16:200.200.200.200/24,11,eth11", "192.168.1.0/24", "[192.168.1.208/24]")]
|
||||||
[InlineData("192.168.1.208/24,-16,vEthernet1:192.168.1.208/24,-16,vEthernet212;200.200.200.200/24,11,eth11", "192.168.1.0/24", "[192.168.1.208/24]")]
|
[InlineData("192.168.1.208/24,-16,vEthernet1:192.168.1.208/24,-16,vEthernet212:200.200.200.200/24,11,eth11", "192.168.1.0/24", "[]")]
|
||||||
|
[InlineData("192.168.1.200/24,-20,vEthernet1:192.168.1.208/24,-16,vEthernet212:200.200.200.200/24,11,eth11", "192.168.1.0/24;200.200.200.200/24", "[200.200.200.200/24]")]
|
||||||
public void IgnoreVirtualInterfaces(string interfaces, string lan, string value)
|
public void IgnoreVirtualInterfaces(string interfaces, string lan, string value)
|
||||||
{
|
{
|
||||||
var conf = new NetworkConfiguration()
|
var conf = new NetworkConfiguration()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user