aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Networking
diff options
context:
space:
mode:
Diffstat (limited to 'Jellyfin.Networking')
-rw-r--r--Jellyfin.Networking/Jellyfin.Networking.csproj2
-rw-r--r--Jellyfin.Networking/Manager/NetworkManager.cs35
2 files changed, 19 insertions, 18 deletions
diff --git a/Jellyfin.Networking/Jellyfin.Networking.csproj b/Jellyfin.Networking/Jellyfin.Networking.csproj
index d05072152..975d1c8ce 100644
--- a/Jellyfin.Networking/Jellyfin.Networking.csproj
+++ b/Jellyfin.Networking/Jellyfin.Networking.csproj
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFramework>net6.0</TargetFramework>
+ <TargetFramework>net7.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
diff --git a/Jellyfin.Networking/Manager/NetworkManager.cs b/Jellyfin.Networking/Manager/NetworkManager.cs
index 9e06cdfe7..5520e2f04 100644
--- a/Jellyfin.Networking/Manager/NetworkManager.cs
+++ b/Jellyfin.Networking/Manager/NetworkManager.cs
@@ -161,7 +161,7 @@ namespace Jellyfin.Networking.Manager
public static Collection<IPObject> CreateCollection(IEnumerable<IPObject>? source = null)
{
var result = new Collection<IPObject>();
- if (source != null)
+ if (source is not null)
{
foreach (var item in source)
{
@@ -225,14 +225,14 @@ namespace Jellyfin.Networking.Manager
/// <inheritdoc/>
public bool IsExcluded(EndPoint ip)
{
- return ip != null && IsExcluded(((IPEndPoint)ip).Address);
+ return ip is not null && IsExcluded(((IPEndPoint)ip).Address);
}
/// <inheritdoc/>
public Collection<IPObject> CreateIPCollection(string[] values, bool negated = false)
{
Collection<IPObject> col = new Collection<IPObject>();
- if (values == null)
+ if (values is null)
{
return col;
}
@@ -335,7 +335,7 @@ namespace Jellyfin.Networking.Manager
{
string result;
- if (source != null && IPHost.TryParse(source.Host.Host, out IPHost host))
+ if (source is not null && IPHost.TryParse(source.Host.Host, out IPHost host))
{
result = GetBindInterface(host, out port);
port ??= source.Host.Port;
@@ -515,7 +515,7 @@ namespace Jellyfin.Networking.Manager
/// <inheritdoc/>
public Collection<IPObject> GetFilteredLANSubnets(Collection<IPObject>? filter = null)
{
- if (filter == null)
+ if (filter is null)
{
return _lanSubnets.Exclude(_excludedSubnets, true).AsNetworks();
}
@@ -538,7 +538,7 @@ namespace Jellyfin.Networking.Manager
return false;
}
- if (_interfaceNames != null && _interfaceNames.TryGetValue(token.ToLower(CultureInfo.InvariantCulture), out int index))
+ if (_interfaceNames is not null && _interfaceNames.TryGetValue(token.ToLower(CultureInfo.InvariantCulture), out int index))
{
result = new Collection<IPObject>();
@@ -718,7 +718,7 @@ namespace Jellyfin.Networking.Manager
// Is it the name of an interface (windows) eg, Wireless LAN adapter Wireless Network Connection 1.
// Null check required here for automated testing.
- if (_interfaceNames != null && token.Length > 1)
+ if (_interfaceNames is not null && token.Length > 1)
{
bool partial = token[^1] == '*';
if (partial)
@@ -737,7 +737,7 @@ namespace Jellyfin.Networking.Manager
}
}
- return index != null;
+ return index is not null;
}
/// <summary>
@@ -880,7 +880,7 @@ namespace Jellyfin.Networking.Manager
{
_publishedServerUrls.Clear();
string[] overrides = config.PublishedServerUriBySubnet;
- if (overrides == null)
+ if (overrides is null)
{
return;
}
@@ -903,7 +903,7 @@ namespace Jellyfin.Networking.Manager
{
_publishedServerUrls[new IPNetAddress(IPAddress.Any)] = replacement;
}
- else if (TryParseInterface(parts[0], out Collection<IPObject>? addresses) && addresses != null)
+ else if (TryParseInterface(parts[0], out Collection<IPObject>? addresses) && addresses is not null)
{
foreach (IPNetAddress na in addresses)
{
@@ -1052,7 +1052,7 @@ namespace Jellyfin.Networking.Manager
PhysicalAddress mac = adapter.GetPhysicalAddress();
// populate mac list
- if (adapter.NetworkInterfaceType != NetworkInterfaceType.Loopback && mac != null && mac != PhysicalAddress.None)
+ if (adapter.NetworkInterfaceType != NetworkInterfaceType.Loopback && mac is not null && mac != PhysicalAddress.None)
{
_macAddresses.Add(mac);
}
@@ -1235,17 +1235,17 @@ namespace Jellyfin.Networking.Manager
// Find all external bind addresses. Store the default gateway, but check to see if there is a better match first.
foreach (var addr in addresses.OrderBy(p => p.Tag))
{
- if (defaultGateway == null && !IsInLocalNetwork(addr))
+ if (defaultGateway is null && !IsInLocalNetwork(addr))
{
defaultGateway = addr.Address;
}
- if (bindAddress == null && addr.Contains(source))
+ if (bindAddress is null && addr.Contains(source))
{
bindAddress = addr.Address;
}
- if (defaultGateway != null && bindAddress != null)
+ if (defaultGateway is not null && bindAddress is not null)
{
break;
}
@@ -1260,14 +1260,14 @@ namespace Jellyfin.Networking.Manager
.FirstOrDefault()?.Address;
}
- if (bindAddress != null)
+ if (bindAddress is not null)
{
result = FormatIP6String(bindAddress);
_logger.LogDebug("{Source}: GetBindInterface: Has source, found a match bind interface subnets. {Result}", source, result);
return true;
}
- if (isInExternalSubnet && defaultGateway != null)
+ if (isInExternalSubnet && defaultGateway is not null)
{
result = FormatIP6String(defaultGateway);
_logger.LogDebug("{Source}: GetBindInterface: Using first user defined external interface. {Result}", source, result);
@@ -1301,7 +1301,8 @@ namespace Jellyfin.Networking.Manager
var extResult = _interfaceAddresses
.Exclude(_bindExclusions, false)
.Where(p => !IsInLocalNetwork(p))
- .OrderBy(p => p.Tag);
+ .OrderBy(p => p.Tag)
+ .ToList();
if (extResult.Any())
{