mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
moved some network code to the networking assembly
This commit is contained in:
parent
17c1fd5760
commit
465f0cc1e2
@ -32,13 +32,10 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
<Reference Include="System.Data" />
|
|
||||||
<Reference Include="System.Xml" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="BdInfoExaminer.cs" />
|
||||||
<Compile Include="BDInfoSettings.cs" />
|
<Compile Include="BDInfoSettings.cs" />
|
||||||
<Compile Include="BDROM.cs" />
|
<Compile Include="BDROM.cs" />
|
||||||
<Compile Include="LanguageCodes.cs" />
|
<Compile Include="LanguageCodes.cs" />
|
||||||
@ -63,6 +60,12 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="ReadMe.txt" />
|
<Content Include="ReadMe.txt" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\MediaBrowser.Model\MediaBrowser.Model.csproj">
|
||||||
|
<Project>{7eeeb4bb-f3e8-48fc-b4c5-70f0fff8329b}</Project>
|
||||||
|
<Name>MediaBrowser.Model</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
using BDInfo;
|
using MediaBrowser.Model.Entities;
|
||||||
using MediaBrowser.Model.Entities;
|
|
||||||
using MediaBrowser.Model.MediaInfo;
|
using MediaBrowser.Model.MediaInfo;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace MediaBrowser.ServerApplication.Implementations
|
namespace BDInfo
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Class BdInfoExaminer
|
/// Class BdInfoExaminer
|
@ -1,6 +1,7 @@
|
|||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Controller.IO;
|
using MediaBrowser.Controller.IO;
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
|
using MediaBrowser.Model.Net;
|
||||||
using ServiceStack.ServiceHost;
|
using ServiceStack.ServiceHost;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -59,6 +60,26 @@ namespace MediaBrowser.Api
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class EnvironmentService : BaseRestService
|
public class EnvironmentService : BaseRestService
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The _network manager
|
||||||
|
/// </summary>
|
||||||
|
private readonly INetworkManager _networkManager;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="EnvironmentService" /> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="networkManager">The network manager.</param>
|
||||||
|
/// <exception cref="System.ArgumentNullException">networkManager</exception>
|
||||||
|
public EnvironmentService(INetworkManager networkManager)
|
||||||
|
{
|
||||||
|
if (networkManager == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("networkManager");
|
||||||
|
}
|
||||||
|
|
||||||
|
_networkManager = networkManager;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the specified request.
|
/// Gets the specified request.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -131,7 +152,7 @@ namespace MediaBrowser.Api
|
|||||||
/// <returns>IEnumerable{FileSystemEntryInfo}.</returns>
|
/// <returns>IEnumerable{FileSystemEntryInfo}.</returns>
|
||||||
private IEnumerable<FileSystemEntryInfo> GetNetworkComputers()
|
private IEnumerable<FileSystemEntryInfo> GetNetworkComputers()
|
||||||
{
|
{
|
||||||
return NetUtils.GetNetworkComputers().Select(c => new FileSystemEntryInfo
|
return _networkManager.GetNetworkDevices().Select(c => new FileSystemEntryInfo
|
||||||
{
|
{
|
||||||
Name = c,
|
Name = c,
|
||||||
Path = NetworkPrefix + c,
|
Path = NetworkPrefix + c,
|
||||||
@ -156,10 +177,10 @@ namespace MediaBrowser.Api
|
|||||||
/// <returns>IEnumerable{FileSystemEntryInfo}.</returns>
|
/// <returns>IEnumerable{FileSystemEntryInfo}.</returns>
|
||||||
private IEnumerable<FileSystemEntryInfo> GetNetworkShares(string path)
|
private IEnumerable<FileSystemEntryInfo> GetNetworkShares(string path)
|
||||||
{
|
{
|
||||||
return new ShareCollection(path).OfType<Share>().Where(s => s.ShareType == ShareType.Disk).Select(c => new FileSystemEntryInfo
|
return _networkManager.GetNetworkShares(path).Where(s => s.ShareType == NetworkShareType.Disk).Select(c => new FileSystemEntryInfo
|
||||||
{
|
{
|
||||||
Name = c.NetName,
|
Name = c.Name,
|
||||||
Path = Path.Combine(path, c.NetName),
|
Path = Path.Combine(path, c.Name),
|
||||||
Type = FileSystemEntryType.NetworkShare
|
Type = FileSystemEntryType.NetworkShare
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -65,8 +65,6 @@
|
|||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Drawing" />
|
|
||||||
<Reference Include="System.Runtime.Serialization" />
|
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.XML" />
|
<Reference Include="System.XML" />
|
||||||
|
@ -69,11 +69,7 @@
|
|||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
<Reference Include="System.Data" />
|
|
||||||
<Reference Include="System.Xml" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="..\SharedVersion.cs">
|
<Compile Include="..\SharedVersion.cs">
|
||||||
@ -87,14 +83,6 @@
|
|||||||
<Project>{9142eefa-7570-41e1-bfcc-468bb571af2f}</Project>
|
<Project>{9142eefa-7570-41e1-bfcc-468bb571af2f}</Project>
|
||||||
<Name>MediaBrowser.Common</Name>
|
<Name>MediaBrowser.Common</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\MediaBrowser.Controller\MediaBrowser.Controller.csproj">
|
|
||||||
<Project>{17e1f4e6-8abd-4fe5-9ecf-43d4b6087ba2}</Project>
|
|
||||||
<Name>MediaBrowser.Controller</Name>
|
|
||||||
</ProjectReference>
|
|
||||||
<ProjectReference Include="..\MediaBrowser.Model\MediaBrowser.Model.csproj">
|
|
||||||
<Project>{7eeeb4bb-f3e8-48fc-b4c5-70f0fff8329b}</Project>
|
|
||||||
<Name>MediaBrowser.Model</Name>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="ApiClient.js" />
|
<EmbeddedResource Include="ApiClient.js" />
|
||||||
|
@ -33,11 +33,7 @@
|
|||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Deployment" />
|
<Reference Include="System.Deployment" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
<Reference Include="System.Data" />
|
|
||||||
<Reference Include="System.Xml" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="..\SharedVersion.cs">
|
<Compile Include="..\SharedVersion.cs">
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Common.Extensions
|
namespace MediaBrowser.Common.Extensions
|
||||||
{
|
{
|
||||||
@ -45,23 +43,6 @@ namespace MediaBrowser.Common.Extensions
|
|||||||
return val.Split(new[] { separator }, options);
|
return val.Split(new[] { separator }, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Provides a non-blocking method to start a process and wait asynchronously for it to exit
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="process">The process.</param>
|
|
||||||
/// <returns>Task{System.Boolean}.</returns>
|
|
||||||
public static Task<bool> RunAsync(this Process process)
|
|
||||||
{
|
|
||||||
var tcs = new TaskCompletionSource<bool>();
|
|
||||||
|
|
||||||
process.EnableRaisingEvents = true;
|
|
||||||
process.Exited += (sender, args) => tcs.SetResult(true);
|
|
||||||
|
|
||||||
process.Start();
|
|
||||||
|
|
||||||
return tcs.Task;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Shuffles an IEnumerable
|
/// Shuffles an IEnumerable
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using MediaBrowser.Common.Events;
|
using MediaBrowser.Common.Events;
|
||||||
using MediaBrowser.Common.IO;
|
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Common.Plugins;
|
using MediaBrowser.Common.Plugins;
|
||||||
using MediaBrowser.Common.ScheduledTasks;
|
using MediaBrowser.Common.ScheduledTasks;
|
||||||
@ -396,7 +395,7 @@ namespace MediaBrowser.Common.Kernel
|
|||||||
await ReloadComposableParts().ConfigureAwait(false);
|
await ReloadComposableParts().ConfigureAwait(false);
|
||||||
|
|
||||||
DisposeTcpManager();
|
DisposeTcpManager();
|
||||||
TcpManager = new TcpManager(ApplicationHost, this, Logger);
|
TcpManager = new TcpManager(ApplicationHost, this, ApplicationHost.Resolve<INetworkManager>(), Logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -58,6 +58,13 @@ namespace MediaBrowser.Common.Kernel
|
|||||||
/// <param name="obj">The obj.</param>
|
/// <param name="obj">The obj.</param>
|
||||||
void Register<T>(T obj) where T : class;
|
void Register<T>(T obj) where T : class;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Registers the specified service type.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="serviceType">Type of the service.</param>
|
||||||
|
/// <param name="implementation">Type of the implementation.</param>
|
||||||
|
void Register(Type serviceType, Type implementation);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Resolves this instance.
|
/// Resolves this instance.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -22,7 +22,7 @@ namespace MediaBrowser.Common.Kernel
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Manages the Http Server, Udp Server and WebSocket connections
|
/// Manages the Http Server, Udp Server and WebSocket connections
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class TcpManager : BaseManager<IKernel>
|
public class TcpManager : IDisposable
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This is the udp server used for server discovery by clients
|
/// This is the udp server used for server discovery by clients
|
||||||
@ -65,6 +65,11 @@ namespace MediaBrowser.Common.Kernel
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The _network manager
|
||||||
|
/// </summary>
|
||||||
|
private readonly INetworkManager _networkManager;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The _application host
|
/// The _application host
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -75,6 +80,11 @@ namespace MediaBrowser.Common.Kernel
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private bool? _supportsNativeWebSocket;
|
private bool? _supportsNativeWebSocket;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The _kernel
|
||||||
|
/// </summary>
|
||||||
|
private readonly IKernel _kernel;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value indicating whether [supports web socket].
|
/// Gets a value indicating whether [supports web socket].
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -107,7 +117,7 @@ namespace MediaBrowser.Common.Kernel
|
|||||||
/// <value>The web socket port number.</value>
|
/// <value>The web socket port number.</value>
|
||||||
public int WebSocketPortNumber
|
public int WebSocketPortNumber
|
||||||
{
|
{
|
||||||
get { return SupportsNativeWebSocket ? Kernel.Configuration.HttpServerPortNumber : Kernel.Configuration.LegacyWebSocketPortNumber; }
|
get { return SupportsNativeWebSocket ? _kernel.Configuration.HttpServerPortNumber : _kernel.Configuration.LegacyWebSocketPortNumber; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -115,12 +125,31 @@ namespace MediaBrowser.Common.Kernel
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="applicationHost">The application host.</param>
|
/// <param name="applicationHost">The application host.</param>
|
||||||
/// <param name="kernel">The kernel.</param>
|
/// <param name="kernel">The kernel.</param>
|
||||||
|
/// <param name="networkManager">The network manager.</param>
|
||||||
/// <param name="logger">The logger.</param>
|
/// <param name="logger">The logger.</param>
|
||||||
public TcpManager(IApplicationHost applicationHost, IKernel kernel, ILogger logger)
|
public TcpManager(IApplicationHost applicationHost, IKernel kernel, INetworkManager networkManager, ILogger logger)
|
||||||
: base(kernel)
|
|
||||||
{
|
{
|
||||||
|
if (applicationHost == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("applicationHost");
|
||||||
|
}
|
||||||
|
if (kernel == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("kernel");
|
||||||
|
}
|
||||||
|
if (networkManager == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("networkManager");
|
||||||
|
}
|
||||||
|
if (logger == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("logger");
|
||||||
|
}
|
||||||
|
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
_kernel = kernel;
|
||||||
_applicationHost = applicationHost;
|
_applicationHost = applicationHost;
|
||||||
|
_networkManager = networkManager;
|
||||||
|
|
||||||
if (kernel.IsFirstRun)
|
if (kernel.IsFirstRun)
|
||||||
{
|
{
|
||||||
@ -142,14 +171,14 @@ namespace MediaBrowser.Common.Kernel
|
|||||||
private void ReloadExternalWebSocketServer()
|
private void ReloadExternalWebSocketServer()
|
||||||
{
|
{
|
||||||
// Avoid windows firewall prompts in the ui
|
// Avoid windows firewall prompts in the ui
|
||||||
if (Kernel.KernelContext != KernelContext.Server)
|
if (_kernel.KernelContext != KernelContext.Server)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DisposeExternalWebSocketServer();
|
DisposeExternalWebSocketServer();
|
||||||
|
|
||||||
ExternalWebSocketServer = new WebSocketServer(Kernel.Configuration.LegacyWebSocketPortNumber, IPAddress.Any)
|
ExternalWebSocketServer = new WebSocketServer(_kernel.Configuration.LegacyWebSocketPortNumber, IPAddress.Any)
|
||||||
{
|
{
|
||||||
OnConnected = OnAlchemyWebSocketClientConnected,
|
OnConnected = OnAlchemyWebSocketClientConnected,
|
||||||
TimeOut = TimeSpan.FromMinutes(60)
|
TimeOut = TimeSpan.FromMinutes(60)
|
||||||
@ -178,7 +207,7 @@ namespace MediaBrowser.Common.Kernel
|
|||||||
public void ReloadHttpServer(bool registerServerOnFailure = true)
|
public void ReloadHttpServer(bool registerServerOnFailure = true)
|
||||||
{
|
{
|
||||||
// Only reload if the port has changed, so that we don't disconnect any active users
|
// Only reload if the port has changed, so that we don't disconnect any active users
|
||||||
if (HttpServer != null && HttpServer.UrlPrefix.Equals(Kernel.HttpServerUrlPrefix, StringComparison.OrdinalIgnoreCase))
|
if (HttpServer != null && HttpServer.UrlPrefix.Equals(_kernel.HttpServerUrlPrefix, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -189,7 +218,7 @@ namespace MediaBrowser.Common.Kernel
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
HttpServer = new HttpServer(Kernel.HttpServerUrlPrefix, "Media Browser", _applicationHost, Kernel, _logger);
|
HttpServer = new HttpServer(_kernel.HttpServerUrlPrefix, "Media Browser", _applicationHost, _kernel, _logger);
|
||||||
}
|
}
|
||||||
catch (HttpListenerException ex)
|
catch (HttpListenerException ex)
|
||||||
{
|
{
|
||||||
@ -229,7 +258,7 @@ namespace MediaBrowser.Common.Kernel
|
|||||||
/// <param name="result">The result.</param>
|
/// <param name="result">The result.</param>
|
||||||
private async void ProcessWebSocketMessageReceived(WebSocketMessageInfo result)
|
private async void ProcessWebSocketMessageReceived(WebSocketMessageInfo result)
|
||||||
{
|
{
|
||||||
var tasks = Kernel.WebSocketListeners.Select(i => Task.Run(async () =>
|
var tasks = _kernel.WebSocketListeners.Select(i => Task.Run(async () =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -256,7 +285,7 @@ namespace MediaBrowser.Common.Kernel
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Avoid windows firewall prompts in the ui
|
// Avoid windows firewall prompts in the ui
|
||||||
if (Kernel.KernelContext != KernelContext.Server)
|
if (_kernel.KernelContext != KernelContext.Server)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -266,7 +295,7 @@ namespace MediaBrowser.Common.Kernel
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// The port number can't be in configuration because we don't want it to ever change
|
// The port number can't be in configuration because we don't want it to ever change
|
||||||
UdpServer = new UdpServer(new IPEndPoint(IPAddress.Any, Kernel.UdpServerPortNumber));
|
UdpServer = new UdpServer(new IPEndPoint(IPAddress.Any, _kernel.UdpServerPortNumber));
|
||||||
}
|
}
|
||||||
catch (SocketException ex)
|
catch (SocketException ex)
|
||||||
{
|
{
|
||||||
@ -276,7 +305,7 @@ namespace MediaBrowser.Common.Kernel
|
|||||||
|
|
||||||
UdpListener = UdpServer.Subscribe(async res =>
|
UdpListener = UdpServer.Subscribe(async res =>
|
||||||
{
|
{
|
||||||
var expectedMessage = String.Format("who is MediaBrowser{0}?", Kernel.KernelContext);
|
var expectedMessage = String.Format("who is MediaBrowser{0}?", _kernel.KernelContext);
|
||||||
var expectedMessageBytes = Encoding.UTF8.GetBytes(expectedMessage);
|
var expectedMessageBytes = Encoding.UTF8.GetBytes(expectedMessage);
|
||||||
|
|
||||||
if (expectedMessageBytes.SequenceEqual(res.Buffer))
|
if (expectedMessageBytes.SequenceEqual(res.Buffer))
|
||||||
@ -284,7 +313,7 @@ namespace MediaBrowser.Common.Kernel
|
|||||||
_logger.Info("Received UDP server request from " + res.RemoteEndPoint.ToString());
|
_logger.Info("Received UDP server request from " + res.RemoteEndPoint.ToString());
|
||||||
|
|
||||||
// Send a response back with our ip address and port
|
// Send a response back with our ip address and port
|
||||||
var response = String.Format("MediaBrowser{0}|{1}:{2}", Kernel.KernelContext, NetUtils.GetLocalIpAddress(), Kernel.UdpServerPortNumber);
|
var response = String.Format("MediaBrowser{0}|{1}:{2}", _kernel.KernelContext, _networkManager.GetLocalIpAddress(), _kernel.UdpServerPortNumber);
|
||||||
|
|
||||||
await UdpServer.SendAsync(response, res.RemoteEndPoint);
|
await UdpServer.SendAsync(response, res.RemoteEndPoint);
|
||||||
}
|
}
|
||||||
@ -422,7 +451,7 @@ namespace MediaBrowser.Common.Kernel
|
|||||||
private void RegisterServerWithAdministratorAccess()
|
private void RegisterServerWithAdministratorAccess()
|
||||||
{
|
{
|
||||||
// Create a temp file path to extract the bat file to
|
// Create a temp file path to extract the bat file to
|
||||||
var tmpFile = Path.Combine(Kernel.ApplicationPaths.TempDirectory, Guid.NewGuid() + ".bat");
|
var tmpFile = Path.Combine(_kernel.ApplicationPaths.TempDirectory, Guid.NewGuid() + ".bat");
|
||||||
|
|
||||||
// Extract the bat file
|
// Extract the bat file
|
||||||
using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("MediaBrowser.Common.Kernel.RegisterServer.bat"))
|
using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("MediaBrowser.Common.Kernel.RegisterServer.bat"))
|
||||||
@ -437,10 +466,10 @@ namespace MediaBrowser.Common.Kernel
|
|||||||
{
|
{
|
||||||
FileName = tmpFile,
|
FileName = tmpFile,
|
||||||
|
|
||||||
Arguments = string.Format("{0} {1} {2} {3}", Kernel.Configuration.HttpServerPortNumber,
|
Arguments = string.Format("{0} {1} {2} {3}", _kernel.Configuration.HttpServerPortNumber,
|
||||||
Kernel.HttpServerUrlPrefix,
|
_kernel.HttpServerUrlPrefix,
|
||||||
Kernel.UdpServerPortNumber,
|
_kernel.UdpServerPortNumber,
|
||||||
Kernel.Configuration.LegacyWebSocketPortNumber),
|
_kernel.Configuration.LegacyWebSocketPortNumber),
|
||||||
|
|
||||||
CreateNoWindow = true,
|
CreateNoWindow = true,
|
||||||
WindowStyle = ProcessWindowStyle.Hidden,
|
WindowStyle = ProcessWindowStyle.Hidden,
|
||||||
@ -454,19 +483,26 @@ namespace MediaBrowser.Common.Kernel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
||||||
|
/// </summary>
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Dispose(true);
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Releases unmanaged and - optionally - managed resources.
|
/// Releases unmanaged and - optionally - managed resources.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
|
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
|
||||||
protected override void Dispose(bool dispose)
|
protected virtual void Dispose(bool dispose)
|
||||||
{
|
{
|
||||||
if (dispose)
|
if (dispose)
|
||||||
{
|
{
|
||||||
DisposeUdpServer();
|
DisposeUdpServer();
|
||||||
DisposeHttpServer();
|
DisposeHttpServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
base.Dispose(dispose);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -45,7 +45,6 @@
|
|||||||
<HintPath>..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll</HintPath>
|
<HintPath>..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="PresentationCore" />
|
<Reference Include="PresentationCore" />
|
||||||
<Reference Include="PresentationFramework" />
|
|
||||||
<Reference Include="protobuf-net, Version=2.0.0.621, Culture=neutral, PublicKeyToken=257b51d87d2e4d67, processorArchitecture=MSIL">
|
<Reference Include="protobuf-net, Version=2.0.0.621, Culture=neutral, PublicKeyToken=257b51d87d2e4d67, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\packages\protobuf-net.2.0.0.621\lib\net40\protobuf-net.dll</HintPath>
|
<HintPath>..\packages\protobuf-net.2.0.0.621\lib\net40\protobuf-net.dll</HintPath>
|
||||||
@ -91,7 +90,6 @@
|
|||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Configuration" />
|
<Reference Include="System.Configuration" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Management" />
|
|
||||||
<Reference Include="System.Net" />
|
<Reference Include="System.Net" />
|
||||||
<Reference Include="System.Net.Http" />
|
<Reference Include="System.Net.Http" />
|
||||||
<Reference Include="System.Net.Http.WebRequest" />
|
<Reference Include="System.Net.Http.WebRequest" />
|
||||||
@ -107,12 +105,8 @@
|
|||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\packages\Rx-Linq.2.0.21114\lib\Net45\System.Reactive.Linq.dll</HintPath>
|
<HintPath>..\packages\Rx-Linq.2.0.21114\lib\Net45\System.Reactive.Linq.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.Runtime.Remoting" />
|
|
||||||
<Reference Include="System.Runtime.Serialization" />
|
|
||||||
<Reference Include="System.Web" />
|
<Reference Include="System.Web" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
<Reference Include="System.Data" />
|
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -130,7 +124,6 @@
|
|||||||
<Compile Include="IO\ProgressStream.cs" />
|
<Compile Include="IO\ProgressStream.cs" />
|
||||||
<Compile Include="IO\StreamDefaults.cs" />
|
<Compile Include="IO\StreamDefaults.cs" />
|
||||||
<Compile Include="Kernel\BaseApplicationPaths.cs" />
|
<Compile Include="Kernel\BaseApplicationPaths.cs" />
|
||||||
<Compile Include="Kernel\BaseManager.cs" />
|
|
||||||
<Compile Include="Kernel\BasePeriodicWebSocketListener.cs" />
|
<Compile Include="Kernel\BasePeriodicWebSocketListener.cs" />
|
||||||
<Compile Include="Kernel\IWebSocketListener.cs" />
|
<Compile Include="Kernel\IWebSocketListener.cs" />
|
||||||
<Compile Include="Kernel\IApplicationHost.cs" />
|
<Compile Include="Kernel\IApplicationHost.cs" />
|
||||||
@ -142,12 +135,12 @@
|
|||||||
<Compile Include="Net\Handlers\IHttpServerHandler.cs" />
|
<Compile Include="Net\Handlers\IHttpServerHandler.cs" />
|
||||||
<Compile Include="Net\Handlers\StaticFileHandler.cs" />
|
<Compile Include="Net\Handlers\StaticFileHandler.cs" />
|
||||||
<Compile Include="Net\HttpManager.cs" />
|
<Compile Include="Net\HttpManager.cs" />
|
||||||
|
<Compile Include="Net\INetworkManager.cs" />
|
||||||
<Compile Include="Net\IRestfulService.cs" />
|
<Compile Include="Net\IRestfulService.cs" />
|
||||||
<Compile Include="Net\IUdpServer.cs" />
|
<Compile Include="Net\IUdpServer.cs" />
|
||||||
<Compile Include="Net\IWebSocket.cs" />
|
<Compile Include="Net\IWebSocket.cs" />
|
||||||
<Compile Include="Net\MimeTypes.cs" />
|
<Compile Include="Net\MimeTypes.cs" />
|
||||||
<Compile Include="Net\NativeWebSocket.cs" />
|
<Compile Include="Net\NativeWebSocket.cs" />
|
||||||
<Compile Include="Net\NetUtils.cs" />
|
|
||||||
<Compile Include="Net\UdpServer.cs" />
|
<Compile Include="Net\UdpServer.cs" />
|
||||||
<Compile Include="Net\WebSocketConnection.cs" />
|
<Compile Include="Net\WebSocketConnection.cs" />
|
||||||
<Compile Include="Plugins\BaseUiPlugin.cs" />
|
<Compile Include="Plugins\BaseUiPlugin.cs" />
|
||||||
@ -184,7 +177,6 @@
|
|||||||
<Compile Include="ScheduledTasks\IntervalTrigger.cs" />
|
<Compile Include="ScheduledTasks\IntervalTrigger.cs" />
|
||||||
<Compile Include="ScheduledTasks\IScheduledTask.cs" />
|
<Compile Include="ScheduledTasks\IScheduledTask.cs" />
|
||||||
<Compile Include="ScheduledTasks\WeeklyTrigger.cs" />
|
<Compile Include="ScheduledTasks\WeeklyTrigger.cs" />
|
||||||
<Compile Include="Win32\NativeMethods.cs" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="app.config" />
|
<None Include="app.config" />
|
||||||
|
@ -19,22 +19,36 @@ namespace MediaBrowser.Common.Net
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Class HttpManager
|
/// Class HttpManager
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class HttpManager : BaseManager<IKernel>
|
public class HttpManager : IDisposable
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The _logger
|
/// The _logger
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The _kernel
|
||||||
|
/// </summary>
|
||||||
|
private readonly IKernel _kernel;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="HttpManager" /> class.
|
/// Initializes a new instance of the <see cref="HttpManager" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="kernel">The kernel.</param>
|
/// <param name="kernel">The kernel.</param>
|
||||||
/// <param name="logger">The logger.</param>
|
/// <param name="logger">The logger.</param>
|
||||||
public HttpManager(IKernel kernel, ILogger logger)
|
public HttpManager(IKernel kernel, ILogger logger)
|
||||||
: base(kernel)
|
|
||||||
{
|
{
|
||||||
|
if (kernel == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("kernel");
|
||||||
|
}
|
||||||
|
if (logger == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("logger");
|
||||||
|
}
|
||||||
|
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
_kernel = kernel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -196,7 +210,7 @@ namespace MediaBrowser.Common.Net
|
|||||||
|
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
var tempFile = Path.Combine(Kernel.ApplicationPaths.TempDirectory, Guid.NewGuid() + ".tmp");
|
var tempFile = Path.Combine(_kernel.ApplicationPaths.TempDirectory, Guid.NewGuid() + ".tmp");
|
||||||
|
|
||||||
var message = new HttpRequestMessage(HttpMethod.Get, url);
|
var message = new HttpRequestMessage(HttpMethod.Get, url);
|
||||||
|
|
||||||
@ -402,11 +416,20 @@ namespace MediaBrowser.Common.Net
|
|||||||
return url.Substring(start, len);
|
return url.Substring(start, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
||||||
|
/// </summary>
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Dispose(true);
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Releases unmanaged and - optionally - managed resources.
|
/// Releases unmanaged and - optionally - managed resources.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
|
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
|
||||||
protected override void Dispose(bool dispose)
|
protected virtual void Dispose(bool dispose)
|
||||||
{
|
{
|
||||||
if (dispose)
|
if (dispose)
|
||||||
{
|
{
|
||||||
@ -417,8 +440,6 @@ namespace MediaBrowser.Common.Net
|
|||||||
|
|
||||||
_httpClients.Clear();
|
_httpClients.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
base.Dispose(dispose);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
72
MediaBrowser.Common/Net/INetworkManager.cs
Normal file
72
MediaBrowser.Common/Net/INetworkManager.cs
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using MediaBrowser.Model.Net;
|
||||||
|
|
||||||
|
namespace MediaBrowser.Common.Net
|
||||||
|
{
|
||||||
|
public interface INetworkManager
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the machine's local ip address
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>IPAddress.</returns>
|
||||||
|
string GetLocalIpAddress();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a random port number that is currently available
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>System.Int32.</returns>
|
||||||
|
int GetRandomUnusedPort();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates the netsh URL registration.
|
||||||
|
/// </summary>
|
||||||
|
void AuthorizeHttpListening(string url);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds the windows firewall rule.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="port">The port.</param>
|
||||||
|
/// <param name="protocol">The protocol.</param>
|
||||||
|
void AddSystemFirewallRule(int port, NetworkProtocol protocol);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes the windows firewall rule.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="port">The port.</param>
|
||||||
|
/// <param name="protocol">The protocol.</param>
|
||||||
|
void RemoveSystemFirewallRule(int port, NetworkProtocol protocol);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns MAC Address from first Network Card in Computer
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>[string] MAC Address</returns>
|
||||||
|
string GetMacAddress();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets available devices within the domain
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>PC's in the Domain</returns>
|
||||||
|
IEnumerable<string> GetNetworkDevices();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the network shares.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">The path.</param>
|
||||||
|
/// <returns>IEnumerable{NetworkShare}.</returns>
|
||||||
|
IEnumerable<NetworkShare> GetNetworkShares(string path);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Enum NetworkProtocol
|
||||||
|
/// </summary>
|
||||||
|
public enum NetworkProtocol
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The TCP
|
||||||
|
/// </summary>
|
||||||
|
Tcp,
|
||||||
|
/// <summary>
|
||||||
|
/// The UDP
|
||||||
|
/// </summary>
|
||||||
|
Udp
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using MediaBrowser.Common.Kernel;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace MediaBrowser.Common.Kernel
|
namespace MediaBrowser.Controller
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Class BaseManager
|
/// Class BaseManager
|
@ -1,6 +1,4 @@
|
|||||||
using MediaBrowser.Common.Extensions;
|
using MediaBrowser.Common.Extensions;
|
||||||
using MediaBrowser.Common.IO;
|
|
||||||
using MediaBrowser.Common.Win32;
|
|
||||||
using MediaBrowser.Controller.IO;
|
using MediaBrowser.Controller.IO;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.Localization;
|
using MediaBrowser.Controller.Localization;
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
using MediaBrowser.Common.Extensions;
|
using MediaBrowser.Common.Extensions;
|
||||||
using MediaBrowser.Common.Win32;
|
using MediaBrowser.Controller.IO;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.Localization;
|
using MediaBrowser.Controller.Localization;
|
||||||
using MediaBrowser.Controller.Resolvers;
|
using MediaBrowser.Controller.Resolvers;
|
||||||
using MediaBrowser.Controller.Sorting;
|
using MediaBrowser.Controller.Sorting;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using MediaBrowser.Model.Tasks;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
using MediaBrowser.Common.Extensions;
|
using MediaBrowser.Common.Extensions;
|
||||||
using MediaBrowser.Common.IO;
|
|
||||||
using MediaBrowser.Common.Win32;
|
|
||||||
using MediaBrowser.Controller.IO;
|
using MediaBrowser.Controller.IO;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using System;
|
using System;
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using MediaBrowser.Common.Extensions;
|
using MediaBrowser.Common.Extensions;
|
||||||
using MediaBrowser.Common.IO;
|
|
||||||
using MediaBrowser.Common.Win32;
|
|
||||||
using MediaBrowser.Controller.IO;
|
using MediaBrowser.Controller.IO;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.Localization;
|
using MediaBrowser.Controller.Localization;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
using MediaBrowser.Common.Extensions;
|
using MediaBrowser.Common.Extensions;
|
||||||
using MediaBrowser.Common.Win32;
|
using MediaBrowser.Controller.IO;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.Localization;
|
using MediaBrowser.Controller.Localization;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
using MediaBrowser.Common.IO;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Common.Win32;
|
|
||||||
using MediaBrowser.Controller.Library;
|
|
||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using MediaBrowser.Common.Win32;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
@ -4,7 +4,7 @@ using System.Runtime.InteropServices;
|
|||||||
using System.Security;
|
using System.Security;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace MediaBrowser.Common.Win32
|
namespace MediaBrowser.Controller.IO
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Class NativeMethods
|
/// Class NativeMethods
|
@ -1,6 +1,4 @@
|
|||||||
using MediaBrowser.Common.IO;
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Common.Win32;
|
|
||||||
using MediaBrowser.Controller.Entities;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
@ -1,14 +1,10 @@
|
|||||||
using MediaBrowser.Common.Events;
|
using MediaBrowser.Common.Events;
|
||||||
using MediaBrowser.Common.Extensions;
|
using MediaBrowser.Common.Extensions;
|
||||||
using MediaBrowser.Common.IO;
|
|
||||||
using MediaBrowser.Common.Kernel;
|
|
||||||
using MediaBrowser.Common.Win32;
|
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Controller.IO;
|
using MediaBrowser.Controller.IO;
|
||||||
using MediaBrowser.Controller.Resolvers;
|
using MediaBrowser.Controller.Resolvers;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
using MediaBrowser.Model.Tasks;
|
|
||||||
using MoreLinq;
|
using MoreLinq;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
|
@ -77,6 +77,7 @@
|
|||||||
<Compile Include="..\SharedVersion.cs">
|
<Compile Include="..\SharedVersion.cs">
|
||||||
<Link>Properties\SharedVersion.cs</Link>
|
<Link>Properties\SharedVersion.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="BaseManager.cs" />
|
||||||
<Compile Include="Drawing\ImageExtensions.cs" />
|
<Compile Include="Drawing\ImageExtensions.cs" />
|
||||||
<Compile Include="Drawing\ImageHeader.cs" />
|
<Compile Include="Drawing\ImageHeader.cs" />
|
||||||
<Compile Include="Drawing\ImageManager.cs" />
|
<Compile Include="Drawing\ImageManager.cs" />
|
||||||
@ -109,7 +110,7 @@
|
|||||||
<Compile Include="Extensions\XmlExtensions.cs" />
|
<Compile Include="Extensions\XmlExtensions.cs" />
|
||||||
<Compile Include="IO\FileSystem.cs" />
|
<Compile Include="IO\FileSystem.cs" />
|
||||||
<Compile Include="IO\FileSystemManager.cs" />
|
<Compile Include="IO\FileSystemManager.cs" />
|
||||||
<Compile Include="IO\NetworkShares.cs" />
|
<Compile Include="IO\NativeMethods.cs" />
|
||||||
<Compile Include="Library\ChildrenChangedEventArgs.cs" />
|
<Compile Include="Library\ChildrenChangedEventArgs.cs" />
|
||||||
<Compile Include="Library\DtoBuilder.cs" />
|
<Compile Include="Library\DtoBuilder.cs" />
|
||||||
<Compile Include="Library\Profiler.cs" />
|
<Compile Include="Library\Profiler.cs" />
|
||||||
|
@ -634,7 +634,7 @@ namespace MediaBrowser.Controller.MediaInfo
|
|||||||
|
|
||||||
await AudioImageResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);
|
await AudioImageResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
await process.RunAsync().ConfigureAwait(false);
|
await RunAsync(process).ConfigureAwait(false);
|
||||||
|
|
||||||
AudioImageResourcePool.Release();
|
AudioImageResourcePool.Release();
|
||||||
|
|
||||||
@ -713,7 +713,7 @@ namespace MediaBrowser.Controller.MediaInfo
|
|||||||
|
|
||||||
await AudioImageResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);
|
await AudioImageResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
await process.RunAsync().ConfigureAwait(false);
|
await RunAsync(process).ConfigureAwait(false);
|
||||||
|
|
||||||
AudioImageResourcePool.Release();
|
AudioImageResourcePool.Release();
|
||||||
|
|
||||||
@ -768,7 +768,7 @@ namespace MediaBrowser.Controller.MediaInfo
|
|||||||
|
|
||||||
await AudioImageResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);
|
await AudioImageResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
await process.RunAsync().ConfigureAwait(false);
|
await RunAsync(process).ConfigureAwait(false);
|
||||||
|
|
||||||
AudioImageResourcePool.Release();
|
AudioImageResourcePool.Release();
|
||||||
|
|
||||||
@ -971,6 +971,23 @@ namespace MediaBrowser.Controller.MediaInfo
|
|||||||
((Process)sender).Dispose();
|
((Process)sender).Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Provides a non-blocking method to start a process and wait asynchronously for it to exit
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="process">The process.</param>
|
||||||
|
/// <returns>Task{System.Boolean}.</returns>
|
||||||
|
private static Task<bool> RunAsync(Process process)
|
||||||
|
{
|
||||||
|
var tcs = new TaskCompletionSource<bool>();
|
||||||
|
|
||||||
|
process.EnableRaisingEvents = true;
|
||||||
|
process.Exited += (sender, args) => tcs.SetResult(true);
|
||||||
|
|
||||||
|
process.Start();
|
||||||
|
|
||||||
|
return tcs.Task;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets the error mode.
|
/// Sets the error mode.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
using Mediabrowser.Model.Entities;
|
using Mediabrowser.Model.Entities;
|
||||||
using Mediabrowser.PluginSecurity;
|
using Mediabrowser.PluginSecurity;
|
||||||
using MediaBrowser.Common.Kernel;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
using MediaBrowser.Common.Win32;
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.IO;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using MediaBrowser.Common.Win32;
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Controller.Entities;
|
|
||||||
using MediaBrowser.Controller.IO;
|
using MediaBrowser.Controller.IO;
|
||||||
using System;
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
using MediaBrowser.Common.IO;
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Common.Win32;
|
|
||||||
using MediaBrowser.Controller.Entities;
|
|
||||||
using MediaBrowser.Controller.IO;
|
using MediaBrowser.Controller.IO;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using System;
|
using System;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using MediaBrowser.Common.Win32;
|
using MediaBrowser.Controller.IO;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -103,21 +103,36 @@ namespace MediaBrowser.Controller.Updates
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The _network manager
|
||||||
|
/// </summary>
|
||||||
|
private readonly INetworkManager _networkManager;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="InstallationManager" /> class.
|
/// Initializes a new instance of the <see cref="InstallationManager" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="kernel">The kernel.</param>
|
/// <param name="kernel">The kernel.</param>
|
||||||
/// <param name="zipClient">The zip client.</param>
|
/// <param name="zipClient">The zip client.</param>
|
||||||
|
/// <param name="networkManager">The network manager.</param>
|
||||||
/// <param name="logger">The logger.</param>
|
/// <param name="logger">The logger.</param>
|
||||||
/// <exception cref="System.ArgumentNullException">zipClient</exception>
|
/// <exception cref="System.ArgumentNullException">zipClient</exception>
|
||||||
public InstallationManager(Kernel kernel, IZipClient zipClient, ILogger logger)
|
public InstallationManager(Kernel kernel, IZipClient zipClient, INetworkManager networkManager, ILogger logger)
|
||||||
: base(kernel)
|
: base(kernel)
|
||||||
{
|
{
|
||||||
if (zipClient == null)
|
if (zipClient == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("zipClient");
|
throw new ArgumentNullException("zipClient");
|
||||||
}
|
}
|
||||||
|
if (networkManager == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("networkManager");
|
||||||
|
}
|
||||||
|
if (logger == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("logger");
|
||||||
|
}
|
||||||
|
|
||||||
|
_networkManager = networkManager;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
ZipClient = zipClient;
|
ZipClient = zipClient;
|
||||||
}
|
}
|
||||||
@ -133,7 +148,7 @@ namespace MediaBrowser.Controller.Updates
|
|||||||
PackageType? packageType = null,
|
PackageType? packageType = null,
|
||||||
Version applicationVersion = null)
|
Version applicationVersion = null)
|
||||||
{
|
{
|
||||||
var data = new Dictionary<string, string> { { "key", Kernel.PluginSecurityManager.SupporterKey }, { "mac", NetUtils.GetMacAddress() } };
|
var data = new Dictionary<string, string> { { "key", Kernel.PluginSecurityManager.SupporterKey }, { "mac", _networkManager.GetMacAddress() } };
|
||||||
|
|
||||||
using (var json = await Kernel.HttpManager.Post(Controller.Kernel.MBAdminUrl + "service/package/retrieveall", data, Kernel.ResourcePools.Mb, cancellationToken).ConfigureAwait(false))
|
using (var json = await Kernel.HttpManager.Post(Controller.Kernel.MBAdminUrl + "service/package/retrieveall", data, Kernel.ResourcePools.Mb, cancellationToken).ConfigureAwait(false))
|
||||||
{
|
{
|
||||||
|
@ -73,6 +73,8 @@
|
|||||||
<Compile Include="Logging\LogSeverity.cs" />
|
<Compile Include="Logging\LogSeverity.cs" />
|
||||||
<Compile Include="MediaInfo\IBlurayExaminer.cs" />
|
<Compile Include="MediaInfo\IBlurayExaminer.cs" />
|
||||||
<Compile Include="Net\HttpException.cs" />
|
<Compile Include="Net\HttpException.cs" />
|
||||||
|
<Compile Include="Net\NetworkShare.cs" />
|
||||||
|
<Compile Include="Net\NetworkShareType.cs" />
|
||||||
<Compile Include="Updates\CheckForUpdateResult.cs" />
|
<Compile Include="Updates\CheckForUpdateResult.cs" />
|
||||||
<Compile Include="Updates\InstallationInfo.cs" />
|
<Compile Include="Updates\InstallationInfo.cs" />
|
||||||
<Compile Include="Updates\PackageType.cs" />
|
<Compile Include="Updates\PackageType.cs" />
|
||||||
|
31
MediaBrowser.Model/Net/NetworkShare.cs
Normal file
31
MediaBrowser.Model/Net/NetworkShare.cs
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
namespace MediaBrowser.Model.Net
|
||||||
|
{
|
||||||
|
public class NetworkShare
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The name of the computer that this share belongs to
|
||||||
|
/// </summary>
|
||||||
|
public string Server { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Share name
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Local path
|
||||||
|
/// </summary>
|
||||||
|
public string Path { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Share type
|
||||||
|
/// </summary>
|
||||||
|
public NetworkShareType ShareType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Comment
|
||||||
|
/// </summary>
|
||||||
|
public string Remark { get; set; }
|
||||||
|
}
|
||||||
|
}
|
30
MediaBrowser.Model/Net/NetworkShareType.cs
Normal file
30
MediaBrowser.Model/Net/NetworkShareType.cs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
|
||||||
|
namespace MediaBrowser.Model.Net
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Enum NetworkShareType
|
||||||
|
/// </summary>
|
||||||
|
public enum NetworkShareType
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Disk share
|
||||||
|
/// </summary>
|
||||||
|
Disk,
|
||||||
|
/// <summary>
|
||||||
|
/// Printer share
|
||||||
|
/// </summary>
|
||||||
|
Printer,
|
||||||
|
/// <summary>
|
||||||
|
/// Device share
|
||||||
|
/// </summary>
|
||||||
|
Device,
|
||||||
|
/// <summary>
|
||||||
|
/// IPC share
|
||||||
|
/// </summary>
|
||||||
|
Ipc,
|
||||||
|
/// <summary>
|
||||||
|
/// Special share
|
||||||
|
/// </summary>
|
||||||
|
Special
|
||||||
|
}
|
||||||
|
}
|
72
MediaBrowser.Networking/Management/NativeMethods.cs
Normal file
72
MediaBrowser.Networking/Management/NativeMethods.cs
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Security;
|
||||||
|
|
||||||
|
namespace MediaBrowser.Networking.Management
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Class NativeMethods
|
||||||
|
/// </summary>
|
||||||
|
[SuppressUnmanagedCodeSecurity]
|
||||||
|
public static class NativeMethods
|
||||||
|
{
|
||||||
|
//declare the Netapi32 : NetServerEnum method import
|
||||||
|
/// <summary>
|
||||||
|
/// Nets the server enum.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ServerName">Name of the server.</param>
|
||||||
|
/// <param name="dwLevel">The dw level.</param>
|
||||||
|
/// <param name="pBuf">The p buf.</param>
|
||||||
|
/// <param name="dwPrefMaxLen">The dw pref max len.</param>
|
||||||
|
/// <param name="dwEntriesRead">The dw entries read.</param>
|
||||||
|
/// <param name="dwTotalEntries">The dw total entries.</param>
|
||||||
|
/// <param name="dwServerType">Type of the dw server.</param>
|
||||||
|
/// <param name="domain">The domain.</param>
|
||||||
|
/// <param name="dwResumeHandle">The dw resume handle.</param>
|
||||||
|
/// <returns>System.Int32.</returns>
|
||||||
|
[DllImport("Netapi32", CharSet = CharSet.Auto, SetLastError = true),
|
||||||
|
SuppressUnmanagedCodeSecurityAttribute]
|
||||||
|
|
||||||
|
public static extern int NetServerEnum(
|
||||||
|
string ServerName, // must be null
|
||||||
|
int dwLevel,
|
||||||
|
ref IntPtr pBuf,
|
||||||
|
int dwPrefMaxLen,
|
||||||
|
out int dwEntriesRead,
|
||||||
|
out int dwTotalEntries,
|
||||||
|
int dwServerType,
|
||||||
|
string domain, // null for login domain
|
||||||
|
out int dwResumeHandle
|
||||||
|
);
|
||||||
|
|
||||||
|
//declare the Netapi32 : NetApiBufferFree method import
|
||||||
|
/// <summary>
|
||||||
|
/// Nets the API buffer free.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pBuf">The p buf.</param>
|
||||||
|
/// <returns>System.Int32.</returns>
|
||||||
|
[DllImport("Netapi32", SetLastError = true),
|
||||||
|
SuppressUnmanagedCodeSecurityAttribute]
|
||||||
|
|
||||||
|
public static extern int NetApiBufferFree(
|
||||||
|
IntPtr pBuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
//create a _SERVER_INFO_100 STRUCTURE
|
||||||
|
/// <summary>
|
||||||
|
/// Struct _SERVER_INFO_100
|
||||||
|
/// </summary>
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct _SERVER_INFO_100
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The sv100_platform_id
|
||||||
|
/// </summary>
|
||||||
|
internal int sv100_platform_id;
|
||||||
|
/// <summary>
|
||||||
|
/// The sv100_name
|
||||||
|
/// </summary>
|
||||||
|
[MarshalAs(UnmanagedType.LPWStr)]
|
||||||
|
internal string sv100_name;
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using MediaBrowser.Common.Win32;
|
using MediaBrowser.Common.Net;
|
||||||
|
using MediaBrowser.Model.Net;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
@ -8,29 +9,36 @@ using System.Net;
|
|||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace MediaBrowser.Common.Net
|
namespace MediaBrowser.Networking.Management
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Class NetUtils
|
/// Class NetUtils
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class NetUtils
|
public class NetworkManager : INetworkManager
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the machine's local ip address
|
/// Gets the machine's local ip address
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>IPAddress.</returns>
|
/// <returns>IPAddress.</returns>
|
||||||
public static IPAddress GetLocalIpAddress()
|
public string GetLocalIpAddress()
|
||||||
{
|
{
|
||||||
var host = Dns.GetHostEntry(Dns.GetHostName());
|
var host = Dns.GetHostEntry(Dns.GetHostName());
|
||||||
|
|
||||||
return host.AddressList.FirstOrDefault(i => i.AddressFamily == AddressFamily.InterNetwork);
|
var ip = host.AddressList.FirstOrDefault(i => i.AddressFamily == AddressFamily.InterNetwork);
|
||||||
|
|
||||||
|
if (ip == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ip.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a random port number that is currently available
|
/// Gets a random port number that is currently available
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>System.Int32.</returns>
|
/// <returns>System.Int32.</returns>
|
||||||
public static int GetRandomUnusedPort()
|
public int GetRandomUnusedPort()
|
||||||
{
|
{
|
||||||
var listener = new TcpListener(IPAddress.Any, 0);
|
var listener = new TcpListener(IPAddress.Any, 0);
|
||||||
listener.Start();
|
listener.Start();
|
||||||
@ -42,13 +50,12 @@ namespace MediaBrowser.Common.Net
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates the netsh URL registration.
|
/// Creates the netsh URL registration.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="urlPrefix">The URL prefix.</param>
|
public void AuthorizeHttpListening(string url)
|
||||||
public static void CreateNetshUrlRegistration(string urlPrefix)
|
|
||||||
{
|
{
|
||||||
var startInfo = new ProcessStartInfo
|
var startInfo = new ProcessStartInfo
|
||||||
{
|
{
|
||||||
FileName = "netsh",
|
FileName = "netsh",
|
||||||
Arguments = string.Format("http add urlacl url={0} user=\"NT AUTHORITY\\Authenticated Users\"", urlPrefix),
|
Arguments = string.Format("http add urlacl url={0} user=\"NT AUTHORITY\\Authenticated Users\"", url),
|
||||||
CreateNoWindow = true,
|
CreateNoWindow = true,
|
||||||
WindowStyle = ProcessWindowStyle.Hidden,
|
WindowStyle = ProcessWindowStyle.Hidden,
|
||||||
Verb = "runas",
|
Verb = "runas",
|
||||||
@ -66,10 +73,10 @@ namespace MediaBrowser.Common.Net
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="port">The port.</param>
|
/// <param name="port">The port.</param>
|
||||||
/// <param name="protocol">The protocol.</param>
|
/// <param name="protocol">The protocol.</param>
|
||||||
public static void AddWindowsFirewallRule(int port, NetworkProtocol protocol)
|
public void AddSystemFirewallRule(int port, NetworkProtocol protocol)
|
||||||
{
|
{
|
||||||
// First try to remove it so we don't end up creating duplicates
|
// First try to remove it so we don't end up creating duplicates
|
||||||
RemoveWindowsFirewallRule(port, protocol);
|
RemoveSystemFirewallRule(port, protocol);
|
||||||
|
|
||||||
var args = string.Format("advfirewall firewall add rule name=\"Port {0}\" dir=in action=allow protocol={1} localport={0}", port, protocol);
|
var args = string.Format("advfirewall firewall add rule name=\"Port {0}\" dir=in action=allow protocol={1} localport={0}", port, protocol);
|
||||||
|
|
||||||
@ -81,7 +88,7 @@ namespace MediaBrowser.Common.Net
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="port">The port.</param>
|
/// <param name="port">The port.</param>
|
||||||
/// <param name="protocol">The protocol.</param>
|
/// <param name="protocol">The protocol.</param>
|
||||||
public static void RemoveWindowsFirewallRule(int port, NetworkProtocol protocol)
|
public void RemoveSystemFirewallRule(int port, NetworkProtocol protocol)
|
||||||
{
|
{
|
||||||
var args = string.Format("advfirewall firewall delete rule name=\"Port {0}\" protocol={1} localport={0}", port, protocol);
|
var args = string.Format("advfirewall firewall delete rule name=\"Port {0}\" protocol={1} localport={0}", port, protocol);
|
||||||
|
|
||||||
@ -92,7 +99,7 @@ namespace MediaBrowser.Common.Net
|
|||||||
/// Runs the netsh.
|
/// Runs the netsh.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="args">The args.</param>
|
/// <param name="args">The args.</param>
|
||||||
private static void RunNetsh(string args)
|
private void RunNetsh(string args)
|
||||||
{
|
{
|
||||||
var startInfo = new ProcessStartInfo
|
var startInfo = new ProcessStartInfo
|
||||||
{
|
{
|
||||||
@ -115,7 +122,7 @@ namespace MediaBrowser.Common.Net
|
|||||||
/// Returns MAC Address from first Network Card in Computer
|
/// Returns MAC Address from first Network Card in Computer
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>[string] MAC Address</returns>
|
/// <returns>[string] MAC Address</returns>
|
||||||
public static string GetMacAddress()
|
public string GetMacAddress()
|
||||||
{
|
{
|
||||||
var mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
|
var mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
|
||||||
var moc = mc.GetInstances();
|
var moc = mc.GetInstances();
|
||||||
@ -148,7 +155,7 @@ namespace MediaBrowser.Common.Net
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Arraylist that represents all the SV_TYPE_WORKSTATION and SV_TYPE_SERVER
|
/// <returns>Arraylist that represents all the SV_TYPE_WORKSTATION and SV_TYPE_SERVER
|
||||||
/// PC's in the Domain</returns>
|
/// PC's in the Domain</returns>
|
||||||
public static IEnumerable<string> GetNetworkComputers()
|
public IEnumerable<string> GetNetworkDevices()
|
||||||
{
|
{
|
||||||
//local fields
|
//local fields
|
||||||
const int MAX_PREFERRED_LENGTH = -1;
|
const int MAX_PREFERRED_LENGTH = -1;
|
||||||
@ -200,20 +207,59 @@ namespace MediaBrowser.Common.Net
|
|||||||
NativeMethods.NetApiBufferFree(buffer);
|
NativeMethods.NetApiBufferFree(buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the network shares.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">The path.</param>
|
||||||
|
/// <returns>IEnumerable{NetworkShare}.</returns>
|
||||||
|
public IEnumerable<NetworkShare> GetNetworkShares(string path)
|
||||||
|
{
|
||||||
|
return new ShareCollection(path).OfType<Share>().Select(ToNetworkShare);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// To the network share.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="share">The share.</param>
|
||||||
|
/// <returns>NetworkShare.</returns>
|
||||||
|
private NetworkShare ToNetworkShare(Share share)
|
||||||
|
{
|
||||||
|
return new NetworkShare
|
||||||
|
{
|
||||||
|
Name = share.NetName,
|
||||||
|
Path = share.Path,
|
||||||
|
Remark = share.Remark,
|
||||||
|
Server = share.Server,
|
||||||
|
ShareType = ToNetworkShareType(share.ShareType)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// To the type of the network share.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="shareType">Type of the share.</param>
|
||||||
|
/// <returns>NetworkShareType.</returns>
|
||||||
|
/// <exception cref="System.ArgumentException">Unknown share type</exception>
|
||||||
|
private NetworkShareType ToNetworkShareType(ShareType shareType)
|
||||||
|
{
|
||||||
|
switch (shareType)
|
||||||
|
{
|
||||||
|
case ShareType.Device:
|
||||||
|
return NetworkShareType.Device;
|
||||||
|
case ShareType.Disk :
|
||||||
|
return NetworkShareType.Disk;
|
||||||
|
case ShareType.IPC :
|
||||||
|
return NetworkShareType.Ipc;
|
||||||
|
case ShareType.Printer :
|
||||||
|
return NetworkShareType.Printer;
|
||||||
|
case ShareType.Special:
|
||||||
|
return NetworkShareType.Special;
|
||||||
|
default:
|
||||||
|
throw new ArgumentException("Unknown share type");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Enum NetworkProtocol
|
|
||||||
/// </summary>
|
|
||||||
public enum NetworkProtocol
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// The TCP
|
|
||||||
/// </summary>
|
|
||||||
Tcp,
|
|
||||||
/// <summary>
|
|
||||||
/// The UDP
|
|
||||||
/// </summary>
|
|
||||||
Udp
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -3,7 +3,7 @@ using System.IO;
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.IO
|
namespace MediaBrowser.Networking.Management
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Type of share
|
/// Type of share
|
||||||
@ -123,10 +123,7 @@ namespace MediaBrowser.Controller.IO
|
|||||||
if (0 == (_shareType & ShareType.Special)) return true;
|
if (0 == (_shareType & ShareType.Special)) return true;
|
||||||
|
|
||||||
// Special disk share (e.g. C$)
|
// Special disk share (e.g. C$)
|
||||||
if (ShareType.Special == _shareType && null != _netName && 0 != _netName.Length)
|
return ShareType.Special == _shareType && !string.IsNullOrEmpty(_netName);
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,16 +136,14 @@ namespace MediaBrowser.Controller.IO
|
|||||||
{
|
{
|
||||||
if (IsFileSystem)
|
if (IsFileSystem)
|
||||||
{
|
{
|
||||||
if (null == _server || 0 == _server.Length)
|
if (string.IsNullOrEmpty(_server))
|
||||||
if (null == _path || 0 == _path.Length)
|
if (string.IsNullOrEmpty(_path))
|
||||||
return new DirectoryInfo(ToString());
|
return new DirectoryInfo(ToString());
|
||||||
else
|
else
|
||||||
return new DirectoryInfo(_path);
|
return new DirectoryInfo(_path);
|
||||||
else
|
return new DirectoryInfo(ToString());
|
||||||
return new DirectoryInfo(ToString());
|
|
||||||
}
|
}
|
||||||
else
|
return null;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,12 +155,11 @@ namespace MediaBrowser.Controller.IO
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
if (null == _server || 0 == _server.Length)
|
if (string.IsNullOrEmpty(_server))
|
||||||
{
|
{
|
||||||
return string.Format(@"\\{0}\{1}", Environment.MachineName, _netName);
|
return string.Format(@"\\{0}\{1}", Environment.MachineName, _netName);
|
||||||
}
|
}
|
||||||
else
|
return string.Format(@"\\{0}\{1}", _server, _netName);
|
||||||
return string.Format(@"\\{0}\{1}", _server, _netName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -176,7 +170,7 @@ namespace MediaBrowser.Controller.IO
|
|||||||
public bool MatchesPath(string path)
|
public bool MatchesPath(string path)
|
||||||
{
|
{
|
||||||
if (!IsFileSystem) return false;
|
if (!IsFileSystem) return false;
|
||||||
if (null == path || 0 == path.Length) return true;
|
if (string.IsNullOrEmpty(path)) return true;
|
||||||
|
|
||||||
return path.ToLower().StartsWith(_path.ToLower());
|
return path.ToLower().StartsWith(_path.ToLower());
|
||||||
}
|
}
|
@ -32,6 +32,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Management" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
@ -42,8 +43,21 @@
|
|||||||
<Compile Include="..\SharedVersion.cs">
|
<Compile Include="..\SharedVersion.cs">
|
||||||
<Link>Properties\SharedVersion.cs</Link>
|
<Link>Properties\SharedVersion.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Management\NativeMethods.cs" />
|
||||||
|
<Compile Include="Management\NetworkManager.cs" />
|
||||||
|
<Compile Include="Management\NetworkShares.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\MediaBrowser.Common\MediaBrowser.Common.csproj">
|
||||||
|
<Project>{9142eefa-7570-41e1-bfcc-468bb571af2f}</Project>
|
||||||
|
<Name>MediaBrowser.Common</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\MediaBrowser.Model\MediaBrowser.Model.csproj">
|
||||||
|
<Project>{7eeeb4bb-f3e8-48fc-b4c5-70f0fff8329b}</Project>
|
||||||
|
<Name>MediaBrowser.Model</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
@ -43,11 +43,8 @@
|
|||||||
<Reference Include="System.Data.SQLite.Linq">
|
<Reference Include="System.Data.SQLite.Linq">
|
||||||
<HintPath>..\packages\System.Data.SQLite.1.0.84.0\lib\net45\System.Data.SQLite.Linq.dll</HintPath>
|
<HintPath>..\packages\System.Data.SQLite.1.0.84.0\lib\net45\System.Data.SQLite.Linq.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.Xml.Linq" />
|
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.Xml" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="..\SharedVersion.cs">
|
<Compile Include="..\SharedVersion.cs">
|
||||||
|
@ -35,11 +35,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
<Reference Include="System.Data" />
|
|
||||||
<Reference Include="System.Xml" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="..\SharedVersion.cs">
|
<Compile Include="..\SharedVersion.cs">
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
using MediaBrowser.ClickOnce;
|
using BDInfo;
|
||||||
|
using MediaBrowser.ClickOnce;
|
||||||
using MediaBrowser.Common.IO;
|
using MediaBrowser.Common.IO;
|
||||||
using MediaBrowser.Common.Kernel;
|
using MediaBrowser.Common.Kernel;
|
||||||
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Controller;
|
using MediaBrowser.Controller;
|
||||||
using MediaBrowser.IsoMounter;
|
using MediaBrowser.IsoMounter;
|
||||||
using MediaBrowser.Logging.Nlog;
|
using MediaBrowser.Logging.Nlog;
|
||||||
@ -8,6 +10,7 @@ using MediaBrowser.Model.IO;
|
|||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
using MediaBrowser.Model.MediaInfo;
|
using MediaBrowser.Model.MediaInfo;
|
||||||
using MediaBrowser.Model.Updates;
|
using MediaBrowser.Model.Updates;
|
||||||
|
using MediaBrowser.Networking.Management;
|
||||||
using MediaBrowser.Server.Uninstall;
|
using MediaBrowser.Server.Uninstall;
|
||||||
using MediaBrowser.ServerApplication.Implementations;
|
using MediaBrowser.ServerApplication.Implementations;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
@ -513,9 +516,10 @@ namespace MediaBrowser.ServerApplication
|
|||||||
|
|
||||||
IsoManager = new PismoIsoManager(Logger);
|
IsoManager = new PismoIsoManager(Logger);
|
||||||
|
|
||||||
Register<IIsoManager>(IsoManager);
|
Register(IsoManager);
|
||||||
Register<IBlurayExaminer>(new BdInfoExaminer());
|
Register<IBlurayExaminer>(new BdInfoExaminer());
|
||||||
Register<IZipClient>(new DotNetZipClient());
|
Register<IZipClient>(new DotNetZipClient());
|
||||||
|
Register(typeof (INetworkManager), typeof (NetworkManager));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -573,5 +577,15 @@ namespace MediaBrowser.ServerApplication
|
|||||||
}
|
}
|
||||||
return (T)result.GetInstance();
|
return (T)result.GetInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Registers the specified service type.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="serviceType">Type of the service.</param>
|
||||||
|
/// <param name="implementation">Type of the concrete.</param>
|
||||||
|
public void Register(Type serviceType, Type implementation)
|
||||||
|
{
|
||||||
|
_container.Register(serviceType, implementation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -196,7 +196,6 @@
|
|||||||
<Compile Include="Controls\MultiItemUpdateNotification.xaml.cs">
|
<Compile Include="Controls\MultiItemUpdateNotification.xaml.cs">
|
||||||
<DependentUpon>MultiItemUpdateNotification.xaml</DependentUpon>
|
<DependentUpon>MultiItemUpdateNotification.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Implementations\BdInfoExaminer.cs" />
|
|
||||||
<Compile Include="Implementations\DotNetZipClient.cs" />
|
<Compile Include="Implementations\DotNetZipClient.cs" />
|
||||||
<Compile Include="LibraryExplorer.xaml.cs">
|
<Compile Include="LibraryExplorer.xaml.cs">
|
||||||
<DependentUpon>LibraryExplorer.xaml</DependentUpon>
|
<DependentUpon>LibraryExplorer.xaml</DependentUpon>
|
||||||
@ -270,6 +269,10 @@
|
|||||||
<Project>{7eeeb4bb-f3e8-48fc-b4c5-70f0fff8329b}</Project>
|
<Project>{7eeeb4bb-f3e8-48fc-b4c5-70f0fff8329b}</Project>
|
||||||
<Name>MediaBrowser.Model</Name>
|
<Name>MediaBrowser.Model</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\MediaBrowser.Networking\MediaBrowser.Networking.csproj">
|
||||||
|
<Project>{7c11010e-179a-49b7-bfb2-f1656f5e71ad}</Project>
|
||||||
|
<Name>MediaBrowser.Networking</Name>
|
||||||
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\MediaBrowser.Server.Uninstall\MediaBrowser.Server.Uninstall.csproj">
|
<ProjectReference Include="..\MediaBrowser.Server.Uninstall\MediaBrowser.Server.Uninstall.csproj">
|
||||||
<Project>{5443422f-9548-417a-90dd-2fc91f2b5999}</Project>
|
<Project>{5443422f-9548-417a-90dd-2fc91f2b5999}</Project>
|
||||||
<Name>MediaBrowser.Server.Uninstall</Name>
|
<Name>MediaBrowser.Server.Uninstall</Name>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user