aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common
diff options
context:
space:
mode:
authorDavid <daullmer@gmail.com>2020-07-21 21:56:24 +0200
committerDavid <daullmer@gmail.com>2020-07-21 21:56:24 +0200
commitbe8cf1e9ef5f24903c406f5cdbe985e84ffeb102 (patch)
treeb3a925ec3cf8afd8a04eeaad94861b258dfec70f /MediaBrowser.Common
parent9a2bcd6266fb222491abe6ea31d5e7e734699d5f (diff)
parent5b57c81ee14ce585161b9ac331e6e3528826b815 (diff)
Merge branch 'api-migration' into api-syncplay
# Conflicts: # MediaBrowser.Api/SyncPlay/SyncPlayService.cs
Diffstat (limited to 'MediaBrowser.Common')
-rw-r--r--MediaBrowser.Common/MediaBrowser.Common.csproj4
-rw-r--r--MediaBrowser.Common/Net/INetworkManager.cs49
-rw-r--r--MediaBrowser.Common/Plugins/BasePlugin.cs10
-rw-r--r--MediaBrowser.Common/Plugins/IPlugin.cs5
-rw-r--r--MediaBrowser.Common/Updates/IInstallationManager.cs9
5 files changed, 71 insertions, 6 deletions
diff --git a/MediaBrowser.Common/MediaBrowser.Common.csproj b/MediaBrowser.Common/MediaBrowser.Common.csproj
index c9ca153c7..7380f39fd 100644
--- a/MediaBrowser.Common/MediaBrowser.Common.csproj
+++ b/MediaBrowser.Common/MediaBrowser.Common.csproj
@@ -17,8 +17,8 @@
</ItemGroup>
<ItemGroup>
- <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="3.1.5" />
- <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.5" />
+ <PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="3.1.6" />
+ <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.6" />
<PackageReference Include="Microsoft.Net.Http.Headers" Version="2.2.8" />
</ItemGroup>
diff --git a/MediaBrowser.Common/Net/INetworkManager.cs b/MediaBrowser.Common/Net/INetworkManager.cs
index 3ba75abd8..a0330afef 100644
--- a/MediaBrowser.Common/Net/INetworkManager.cs
+++ b/MediaBrowser.Common/Net/INetworkManager.cs
@@ -11,14 +11,21 @@ namespace MediaBrowser.Common.Net
{
event EventHandler NetworkChanged;
+ /// <summary>
+ /// Gets or sets a function to return the list of user defined LAN addresses.
+ /// </summary>
Func<string[]> LocalSubnetsFn { get; set; }
/// <summary>
- /// Gets a random port number that is currently available.
+ /// Gets a random port TCP number that is currently available.
/// </summary>
/// <returns>System.Int32.</returns>
int GetRandomUnusedTcpPort();
+ /// <summary>
+ /// Gets a random port UDP number that is currently available.
+ /// </summary>
+ /// <returns>System.Int32.</returns>
int GetRandomUnusedUdpPort();
/// <summary>
@@ -35,18 +42,56 @@ namespace MediaBrowser.Common.Net
bool IsInPrivateAddressSpace(string endpoint);
/// <summary>
+ /// Determines whether [is in private address space 10.x.x.x] [the specified endpoint] and exists in the subnets returned by GetSubnets().
+ /// </summary>
+ /// <param name="endpoint">The endpoint.</param>
+ /// <returns><c>true</c> if [is in private address space 10.x.x.x] [the specified endpoint]; otherwise, <c>false</c>.</returns>
+ bool IsInPrivateAddressSpaceAndLocalSubnet(string endpoint);
+
+ /// <summary>
/// Determines whether [is in local network] [the specified endpoint].
/// </summary>
/// <param name="endpoint">The endpoint.</param>
/// <returns><c>true</c> if [is in local network] [the specified endpoint]; otherwise, <c>false</c>.</returns>
bool IsInLocalNetwork(string endpoint);
- IPAddress[] GetLocalIpAddresses(bool ignoreVirtualInterface);
+ /// <summary>
+ /// Investigates an caches a list of interface addresses, excluding local link and LAN excluded addresses.
+ /// </summary>
+ /// <returns>The list of ipaddresses.</returns>
+ IPAddress[] GetLocalIpAddresses();
+ /// <summary>
+ /// Checks if the given address falls within the ranges given in [subnets]. The addresses in subnets can be hosts or subnets in the CIDR format.
+ /// </summary>
+ /// <param name="addressString">The address to check.</param>
+ /// <param name="subnets">If true, check against addresses in the LAN settings surrounded by brackets ([]).</param>
+ /// <returns><c>true</c>if the address is in at least one of the given subnets, <c>false</c> otherwise.</returns>
bool IsAddressInSubnets(string addressString, string[] subnets);
+ /// <summary>
+ /// Returns true if address is in the LAN list in the config file.
+ /// </summary>
+ /// <param name="address">The address to check.</param>
+ /// <param name="excludeInterfaces">If true, check against addresses in the LAN settings which have [] arroud and return true if it matches the address give in address.</param>
+ /// <param name="excludeRFC">If true, returns false if address is in the 127.x.x.x or 169.128.x.x range.</param>
+ /// <returns><c>false</c>if the address isn't in the LAN list, <c>true</c> if the address has been defined as a LAN address.</returns>
+ bool IsAddressInSubnets(IPAddress address, bool excludeInterfaces, bool excludeRFC);
+
+ /// <summary>
+ /// Checks if address is in the LAN list in the config file.
+ /// </summary>
+ /// <param name="address1">Source address to check.</param>
+ /// <param name="address2">Destination address to check against.</param>
+ /// <param name="subnetMask">Destination subnet to check against.</param>
+ /// <returns><c>true/false</c>depending on whether address1 is in the same subnet as IPAddress2 with subnetMask.</returns>
bool IsInSameSubnet(IPAddress address1, IPAddress address2, IPAddress subnetMask);
+ /// <summary>
+ /// Returns the subnet mask of an interface with the given address.
+ /// </summary>
+ /// <param name="address">The address to check.</param>
+ /// <returns>Returns the subnet mask of an interface with the given address, or null if an interface match cannot be found.</returns>
IPAddress GetLocalIpSubnetMask(IPAddress address);
}
}
diff --git a/MediaBrowser.Common/Plugins/BasePlugin.cs b/MediaBrowser.Common/Plugins/BasePlugin.cs
index 9e4a360c3..f10a1918f 100644
--- a/MediaBrowser.Common/Plugins/BasePlugin.cs
+++ b/MediaBrowser.Common/Plugins/BasePlugin.cs
@@ -2,6 +2,7 @@
using System;
using System.IO;
+using System.Reflection;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Model.Plugins;
using MediaBrowser.Model.Serialization;
@@ -50,6 +51,12 @@ namespace MediaBrowser.Common.Plugins
public string DataFolderPath { get; private set; }
/// <summary>
+ /// Gets a value indicating whether the plugin can be uninstalled.
+ /// </summary>
+ public bool CanUninstall => !Path.GetDirectoryName(AssemblyFilePath)
+ .Equals(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), StringComparison.InvariantCulture);
+
+ /// <summary>
/// Gets the plugin info.
/// </summary>
/// <returns>PluginInfo.</returns>
@@ -60,7 +67,8 @@ namespace MediaBrowser.Common.Plugins
Name = Name,
Version = Version.ToString(),
Description = Description,
- Id = Id.ToString()
+ Id = Id.ToString(),
+ CanUninstall = CanUninstall
};
return info;
diff --git a/MediaBrowser.Common/Plugins/IPlugin.cs b/MediaBrowser.Common/Plugins/IPlugin.cs
index d34820961..7bd37d210 100644
--- a/MediaBrowser.Common/Plugins/IPlugin.cs
+++ b/MediaBrowser.Common/Plugins/IPlugin.cs
@@ -41,6 +41,11 @@ namespace MediaBrowser.Common.Plugins
string AssemblyFilePath { get; }
/// <summary>
+ /// Gets a value indicating whether the plugin can be uninstalled.
+ /// </summary>
+ bool CanUninstall { get; }
+
+ /// <summary>
/// Gets the full path to the data folder, where the plugin can store any miscellaneous files needed.
/// </summary>
/// <value>The data folder path.</value>
diff --git a/MediaBrowser.Common/Updates/IInstallationManager.cs b/MediaBrowser.Common/Updates/IInstallationManager.cs
index 965ffe0ec..4b4030bc2 100644
--- a/MediaBrowser.Common/Updates/IInstallationManager.cs
+++ b/MediaBrowser.Common/Updates/IInstallationManager.cs
@@ -5,7 +5,6 @@ using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Common.Plugins;
-using MediaBrowser.Model.Events;
using MediaBrowser.Model.Updates;
namespace MediaBrowser.Common.Updates
@@ -41,6 +40,14 @@ namespace MediaBrowser.Common.Updates
IEnumerable<InstallationInfo> CompletedInstallations { get; }
/// <summary>
+ /// Parses a plugin manifest at the supplied URL.
+ /// </summary>
+ /// <param name="manifest">The URL to query.</param>
+ /// <param name="cancellationToken">The cancellation token.</param>
+ /// <returns>Task{IReadOnlyList{PackageInfo}}.</returns>
+ Task<IReadOnlyList<PackageInfo>> GetPackages(string manifest, CancellationToken cancellationToken = default);
+
+ /// <summary>
/// Gets all available packages.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>