aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Networking
diff options
context:
space:
mode:
authorBaronGreenback <jimcartlidge@yahoo.co.uk>2021-01-08 00:05:15 +0000
committerBaronGreenback <jimcartlidge@yahoo.co.uk>2021-01-12 13:07:34 +0000
commit35a30c9d098e7ac5fcaf7d86a4cc616deb8a2cfa (patch)
tree37a216071211071c691cdac3a086bee425a122e7 /Jellyfin.Networking
parent7acee4070e425b9060faa893d61a5e2d2f387bfc (diff)
Impliments KnownNetworks and KnownProxies
Diffstat (limited to 'Jellyfin.Networking')
-rw-r--r--Jellyfin.Networking/Configuration/NetworkConfiguration.cs2
-rw-r--r--Jellyfin.Networking/Manager/NetworkManager.cs95
2 files changed, 62 insertions, 35 deletions
diff --git a/Jellyfin.Networking/Configuration/NetworkConfiguration.cs b/Jellyfin.Networking/Configuration/NetworkConfiguration.cs
index 792e57f6a..91bf0015f 100644
--- a/Jellyfin.Networking/Configuration/NetworkConfiguration.cs
+++ b/Jellyfin.Networking/Configuration/NetworkConfiguration.cs
@@ -224,7 +224,7 @@ namespace Jellyfin.Networking.Configuration
public string[] LocalNetworkAddresses { get; set; } = Array.Empty<string>();
/// <summary>
- /// Gets or sets the known proxies.
+ /// Gets or sets the known proxies. If the proxy is a network, it's added to the KnownNetworks.
/// </summary>
public string[] KnownProxies { get; set; } = Array.Empty<string>();
}
diff --git a/Jellyfin.Networking/Manager/NetworkManager.cs b/Jellyfin.Networking/Manager/NetworkManager.cs
index 60b899519..e2fe44060 100644
--- a/Jellyfin.Networking/Manager/NetworkManager.cs
+++ b/Jellyfin.Networking/Manager/NetworkManager.cs
@@ -139,6 +139,16 @@ namespace Jellyfin.Networking.Manager
/// </summary>
public bool IsIP4Enabled { get; set; }
+ /// <summary>
+ /// Gets or sets a value indicating whether the system has IP4 is enabled.
+ /// </summary>
+ public bool SystemIP4Enabled { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether the system has IP6 is enabled.
+ /// </summary>
+ public bool SystemIP6Enabled { get; set; }
+
/// <inheritdoc/>
public Collection<IPObject> RemoteAddressFilter { get; private set; }
@@ -185,6 +195,15 @@ namespace Jellyfin.Networking.Manager
return _macAddresses;
}
+ /// <summary>
+ /// REMOVE after debugging.
+ /// </summary>
+ /// <param name="msg">Message.</param>
+ public void Log(string msg)
+ {
+ _logger.LogInformation(msg);
+ }
+
/// <inheritdoc/>
public bool IsGatewayInterface(IPObject? addressObj)
{
@@ -1047,47 +1066,55 @@ namespace Jellyfin.Networking.Manager
// populate interface address list
foreach (UnicastIPAddressInformation info in ipProperties.UnicastAddresses)
{
- if (IsIP4Enabled && info.Address.AddressFamily == AddressFamily.InterNetwork)
+ if (info.Address.AddressFamily == AddressFamily.InterNetwork)
{
- IPNetAddress nw = new IPNetAddress(info.Address, IPObject.MaskToCidr(info.IPv4Mask))
- {
- // Keep the number of gateways on this interface, along with its index.
- Tag = ipProperties.GetIPv4Properties().Index
- };
-
- int tag = nw.Tag;
- if (ipProperties.GatewayAddresses.Count > 0 && !nw.IsLoopback())
+ SystemIP4Enabled = true;
+ if (IsIP4Enabled)
{
- // -ve Tags signify the interface has a gateway.
- nw.Tag *= -1;
+ IPNetAddress nw = new IPNetAddress(info.Address, IPObject.MaskToCidr(info.IPv4Mask))
+ {
+ // Keep the number of gateways on this interface, along with its index.
+ Tag = ipProperties.GetIPv4Properties().Index
+ };
+
+ int tag = nw.Tag;
+ if (ipProperties.GatewayAddresses.Count > 0 && !nw.IsLoopback())
+ {
+ // -ve Tags signify the interface has a gateway.
+ nw.Tag *= -1;
+ }
+
+ _interfaceAddresses.AddItem(nw);
+
+ // Store interface name so we can use the name in Collections.
+ _interfaceNames[adapter.Description.ToLower(CultureInfo.InvariantCulture)] = tag;
+ _interfaceNames["eth" + tag.ToString(CultureInfo.InvariantCulture)] = tag;
}
-
- _interfaceAddresses.AddItem(nw);
-
- // Store interface name so we can use the name in Collections.
- _interfaceNames[adapter.Description.ToLower(CultureInfo.InvariantCulture)] = tag;
- _interfaceNames["eth" + tag.ToString(CultureInfo.InvariantCulture)] = tag;
}
- else if (IsIP6Enabled && info.Address.AddressFamily == AddressFamily.InterNetworkV6)
+ else if (info.Address.AddressFamily == AddressFamily.InterNetworkV6)
{
- IPNetAddress nw = new IPNetAddress(info.Address, (byte)info.PrefixLength)
+ SystemIP6Enabled = true;
+ if (IsIP6Enabled)
{
- // Keep the number of gateways on this interface, along with its index.
- Tag = ipProperties.GetIPv6Properties().Index
- };
-
- int tag = nw.Tag;
- if (ipProperties.GatewayAddresses.Count > 0 && !nw.IsLoopback())
- {
- // -ve Tags signify the interface has a gateway.
- nw.Tag *= -1;
+ IPNetAddress nw = new IPNetAddress(info.Address, (byte)info.PrefixLength)
+ {
+ // Keep the number of gateways on this interface, along with its index.
+ Tag = ipProperties.GetIPv6Properties().Index
+ };
+
+ int tag = nw.Tag;
+ if (ipProperties.GatewayAddresses.Count > 0 && !nw.IsLoopback())
+ {
+ // -ve Tags signify the interface has a gateway.
+ nw.Tag *= -1;
+ }
+
+ _interfaceAddresses.AddItem(nw);
+
+ // Store interface name so we can use the name in Collections.
+ _interfaceNames[adapter.Description.ToLower(CultureInfo.InvariantCulture)] = tag;
+ _interfaceNames["eth" + tag.ToString(CultureInfo.InvariantCulture)] = tag;
}
-
- _interfaceAddresses.AddItem(nw);
-
- // Store interface name so we can use the name in Collections.
- _interfaceNames[adapter.Description.ToLower(CultureInfo.InvariantCulture)] = tag;
- _interfaceNames["eth" + tag.ToString(CultureInfo.InvariantCulture)] = tag;
}
}
}