update portable projects
This commit is contained in:
parent
836e1fdc30
commit
8492225dee
|
@ -69,6 +69,7 @@
|
||||||
<Compile Include="FileOrganization\OrganizerScheduledTask.cs" />
|
<Compile Include="FileOrganization\OrganizerScheduledTask.cs" />
|
||||||
<Compile Include="FileOrganization\TvFolderOrganizer.cs" />
|
<Compile Include="FileOrganization\TvFolderOrganizer.cs" />
|
||||||
<Compile Include="HttpServer\GetSwaggerResource.cs" />
|
<Compile Include="HttpServer\GetSwaggerResource.cs" />
|
||||||
|
<Compile Include="HttpServer\HttpListenerHost.cs" />
|
||||||
<Compile Include="HttpServer\HttpResultFactory.cs" />
|
<Compile Include="HttpServer\HttpResultFactory.cs" />
|
||||||
<Compile Include="HttpServer\LoggerUtils.cs" />
|
<Compile Include="HttpServer\LoggerUtils.cs" />
|
||||||
<Compile Include="HttpServer\RangeRequestWriter.cs" />
|
<Compile Include="HttpServer\RangeRequestWriter.cs" />
|
||||||
|
@ -172,6 +173,7 @@
|
||||||
<Compile Include="Notifications\WebSocketNotifier.cs" />
|
<Compile Include="Notifications\WebSocketNotifier.cs" />
|
||||||
<Compile Include="Persistence\CleanDatabaseScheduledTask.cs" />
|
<Compile Include="Persistence\CleanDatabaseScheduledTask.cs" />
|
||||||
<Compile Include="Photos\PhotoAlbumImageProvider.cs" />
|
<Compile Include="Photos\PhotoAlbumImageProvider.cs" />
|
||||||
|
<Compile Include="Playlists\ManualPlaylistsFolder.cs" />
|
||||||
<Compile Include="Playlists\PlaylistImageProvider.cs" />
|
<Compile Include="Playlists\PlaylistImageProvider.cs" />
|
||||||
<Compile Include="Playlists\PlaylistManager.cs" />
|
<Compile Include="Playlists\PlaylistManager.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
|
|
@ -8,12 +8,8 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Security;
|
|
||||||
using System.Net.Sockets;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Security.Cryptography.X509Certificates;
|
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Emby.Common.Implementations.Net;
|
|
||||||
using Emby.Server.Implementations.HttpServer;
|
using Emby.Server.Implementations.HttpServer;
|
||||||
using Emby.Server.Implementations.HttpServer.SocketSharp;
|
using Emby.Server.Implementations.HttpServer.SocketSharp;
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
|
@ -25,12 +21,12 @@ using MediaBrowser.Model.IO;
|
||||||
using MediaBrowser.Model.Net;
|
using MediaBrowser.Model.Net;
|
||||||
using MediaBrowser.Model.Serialization;
|
using MediaBrowser.Model.Serialization;
|
||||||
using MediaBrowser.Model.Services;
|
using MediaBrowser.Model.Services;
|
||||||
|
using MediaBrowser.Model.System;
|
||||||
using MediaBrowser.Model.Text;
|
using MediaBrowser.Model.Text;
|
||||||
using ServiceStack.Text.Jsv;
|
|
||||||
using SocketHttpListener.Net;
|
using SocketHttpListener.Net;
|
||||||
using SocketHttpListener.Primitives;
|
using SocketHttpListener.Primitives;
|
||||||
|
|
||||||
namespace MediaBrowser.Server.Implementations.HttpServer
|
namespace Emby.Server.Implementations.HttpServer
|
||||||
{
|
{
|
||||||
public class HttpListenerHost : ServiceStackHost, IHttpServer
|
public class HttpListenerHost : ServiceStackHost, IHttpServer
|
||||||
{
|
{
|
||||||
|
@ -46,8 +42,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||||
public event EventHandler<WebSocketConnectEventArgs> WebSocketConnected;
|
public event EventHandler<WebSocketConnectEventArgs> WebSocketConnected;
|
||||||
public event EventHandler<WebSocketConnectingEventArgs> WebSocketConnecting;
|
public event EventHandler<WebSocketConnectingEventArgs> WebSocketConnecting;
|
||||||
|
|
||||||
public string CertificatePath { get; private set; }
|
|
||||||
|
|
||||||
private readonly IServerConfigurationManager _config;
|
private readonly IServerConfigurationManager _config;
|
||||||
private readonly INetworkManager _networkManager;
|
private readonly INetworkManager _networkManager;
|
||||||
private readonly IMemoryStreamFactory _memoryStreamProvider;
|
private readonly IMemoryStreamFactory _memoryStreamProvider;
|
||||||
|
@ -60,12 +54,16 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||||
|
|
||||||
private readonly IJsonSerializer _jsonSerializer;
|
private readonly IJsonSerializer _jsonSerializer;
|
||||||
private readonly IXmlSerializer _xmlSerializer;
|
private readonly IXmlSerializer _xmlSerializer;
|
||||||
|
private readonly ICertificate _certificate;
|
||||||
|
private readonly IEnvironmentInfo _environment;
|
||||||
|
private readonly IStreamFactory _streamFactory;
|
||||||
|
private readonly Func<Type, Func<string, object>> _funcParseFn;
|
||||||
|
|
||||||
public HttpListenerHost(IServerApplicationHost applicationHost,
|
public HttpListenerHost(IServerApplicationHost applicationHost,
|
||||||
ILogManager logManager,
|
ILogger logger,
|
||||||
IServerConfigurationManager config,
|
IServerConfigurationManager config,
|
||||||
string serviceName,
|
string serviceName,
|
||||||
string defaultRedirectPath, INetworkManager networkManager, IMemoryStreamFactory memoryStreamProvider, ITextEncoding textEncoding, ISocketFactory socketFactory, ICryptoProvider cryptoProvider, IJsonSerializer jsonSerializer, IXmlSerializer xmlSerializer)
|
string defaultRedirectPath, INetworkManager networkManager, IMemoryStreamFactory memoryStreamProvider, ITextEncoding textEncoding, ISocketFactory socketFactory, ICryptoProvider cryptoProvider, IJsonSerializer jsonSerializer, IXmlSerializer xmlSerializer, IEnvironmentInfo environment, ICertificate certificate, IStreamFactory streamFactory, Func<Type, Func<string, object>> funcParseFn)
|
||||||
: base(serviceName, new Assembly[] { })
|
: base(serviceName, new Assembly[] { })
|
||||||
{
|
{
|
||||||
_appHost = applicationHost;
|
_appHost = applicationHost;
|
||||||
|
@ -77,9 +75,13 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||||
_cryptoProvider = cryptoProvider;
|
_cryptoProvider = cryptoProvider;
|
||||||
_jsonSerializer = jsonSerializer;
|
_jsonSerializer = jsonSerializer;
|
||||||
_xmlSerializer = xmlSerializer;
|
_xmlSerializer = xmlSerializer;
|
||||||
|
_environment = environment;
|
||||||
|
_certificate = certificate;
|
||||||
|
_streamFactory = streamFactory;
|
||||||
|
_funcParseFn = funcParseFn;
|
||||||
_config = config;
|
_config = config;
|
||||||
|
|
||||||
_logger = logManager.GetLogger("HttpServer");
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GlobalResponse { get; set; }
|
public string GlobalResponse { get; set; }
|
||||||
|
@ -92,11 +94,10 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||||
{typeof (NotImplementedException), 500},
|
{typeof (NotImplementedException), 500},
|
||||||
{typeof (ResourceNotFoundException), 404},
|
{typeof (ResourceNotFoundException), 404},
|
||||||
{typeof (FileNotFoundException), 404},
|
{typeof (FileNotFoundException), 404},
|
||||||
{typeof (DirectoryNotFoundException), 404},
|
//{typeof (DirectoryNotFoundException), 404},
|
||||||
{typeof (SecurityException), 401},
|
{typeof (SecurityException), 401},
|
||||||
{typeof (PaymentRequiredException), 402},
|
{typeof (PaymentRequiredException), 402},
|
||||||
{typeof (UnauthorizedAccessException), 500},
|
{typeof (UnauthorizedAccessException), 500},
|
||||||
{typeof (ApplicationException), 500},
|
|
||||||
{typeof (PlatformNotSupportedException), 500},
|
{typeof (PlatformNotSupportedException), 500},
|
||||||
{typeof (NotSupportedException), 500}
|
{typeof (NotSupportedException), 500}
|
||||||
};
|
};
|
||||||
|
@ -123,16 +124,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||||
return _appHost.Resolve<T>();
|
return _appHost.Resolve<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Type[] GetGenericArguments(Type type)
|
|
||||||
{
|
|
||||||
return type.GetGenericArguments();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool IsAssignableFrom(Type type1, Type type2)
|
|
||||||
{
|
|
||||||
return type1.IsAssignableFrom(type2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override T TryResolve<T>()
|
public override T TryResolve<T>()
|
||||||
{
|
{
|
||||||
return _appHost.TryResolve<T>();
|
return _appHost.TryResolve<T>();
|
||||||
|
@ -187,34 +178,18 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||||
|
|
||||||
private IHttpListener GetListener()
|
private IHttpListener GetListener()
|
||||||
{
|
{
|
||||||
var cert = !string.IsNullOrWhiteSpace(CertificatePath) && File.Exists(CertificatePath)
|
var enableDualMode = _environment.OperatingSystem == OperatingSystem.Windows;
|
||||||
? GetCert(CertificatePath) :
|
|
||||||
null;
|
|
||||||
|
|
||||||
var enableDualMode = Environment.OSVersion.Platform == PlatformID.Win32NT;
|
return new WebSocketSharpListener(_logger,
|
||||||
|
_certificate,
|
||||||
return new WebSocketSharpListener(_logger, cert, _memoryStreamProvider, _textEncoding, _networkManager, _socketFactory, _cryptoProvider, new StreamFactory(), enableDualMode, GetRequest);
|
_memoryStreamProvider,
|
||||||
}
|
_textEncoding,
|
||||||
|
_networkManager,
|
||||||
public ICertificate GetCert(string certificateLocation)
|
_socketFactory,
|
||||||
{
|
_cryptoProvider,
|
||||||
try
|
_streamFactory,
|
||||||
{
|
enableDualMode,
|
||||||
X509Certificate2 localCert = new X509Certificate2(certificateLocation);
|
GetRequest);
|
||||||
//localCert.PrivateKey = PrivateKey.CreateFromFile(pvk_file).RSA;
|
|
||||||
if (localCert.PrivateKey == null)
|
|
||||||
{
|
|
||||||
//throw new FileNotFoundException("Secure requested, no private key included", certificateLocation);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Certificate(localCert);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Logger.ErrorException("Error loading cert from {0}", ex, certificateLocation);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private IHttpRequest GetRequest(HttpListenerContext httpContext)
|
private IHttpRequest GetRequest(HttpListenerContext httpContext)
|
||||||
|
@ -328,7 +303,9 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||||
// this gets all the query string key value pairs as a collection
|
// this gets all the query string key value pairs as a collection
|
||||||
var newQueryString = MyHttpUtility.ParseQueryString(uri.Query);
|
var newQueryString = MyHttpUtility.ParseQueryString(uri.Query);
|
||||||
|
|
||||||
if (newQueryString.Count == 0)
|
var originalCount = newQueryString.Count;
|
||||||
|
|
||||||
|
if (originalCount == 0)
|
||||||
{
|
{
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
@ -336,8 +313,13 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||||
// this removes the key if exists
|
// this removes the key if exists
|
||||||
newQueryString.Remove(key);
|
newQueryString.Remove(key);
|
||||||
|
|
||||||
|
if (originalCount == newQueryString.Count)
|
||||||
|
{
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
// this gets the page path from root without QueryString
|
// this gets the page path from root without QueryString
|
||||||
string pagePathWithoutQueryString = uri.GetLeftPart(UriPartial.Path);
|
string pagePathWithoutQueryString = url.Split(new[] { '?' }, StringSplitOptions.RemoveEmptyEntries)[0];
|
||||||
|
|
||||||
return newQueryString.Count > 0
|
return newQueryString.Count > 0
|
||||||
? String.Format("{0}?{1}", pagePathWithoutQueryString, newQueryString)
|
? String.Format("{0}?{1}", pagePathWithoutQueryString, newQueryString)
|
||||||
|
@ -578,28 +560,28 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||||
base.Init();
|
base.Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Model.Services.RouteAttribute[] GetRouteAttributes(Type requestType)
|
public override RouteAttribute[] GetRouteAttributes(Type requestType)
|
||||||
{
|
{
|
||||||
var routes = base.GetRouteAttributes(requestType).ToList();
|
var routes = base.GetRouteAttributes(requestType).ToList();
|
||||||
var clone = routes.ToList();
|
var clone = routes.ToList();
|
||||||
|
|
||||||
foreach (var route in clone)
|
foreach (var route in clone)
|
||||||
{
|
{
|
||||||
routes.Add(new Model.Services.RouteAttribute(NormalizeEmbyRoutePath(route.Path), route.Verbs)
|
routes.Add(new RouteAttribute(NormalizeEmbyRoutePath(route.Path), route.Verbs)
|
||||||
{
|
{
|
||||||
Notes = route.Notes,
|
Notes = route.Notes,
|
||||||
Priority = route.Priority,
|
Priority = route.Priority,
|
||||||
Summary = route.Summary
|
Summary = route.Summary
|
||||||
});
|
});
|
||||||
|
|
||||||
routes.Add(new Model.Services.RouteAttribute(NormalizeRoutePath(route.Path), route.Verbs)
|
routes.Add(new RouteAttribute(NormalizeRoutePath(route.Path), route.Verbs)
|
||||||
{
|
{
|
||||||
Notes = route.Notes,
|
Notes = route.Notes,
|
||||||
Priority = route.Priority,
|
Priority = route.Priority,
|
||||||
Summary = route.Summary
|
Summary = route.Summary
|
||||||
});
|
});
|
||||||
|
|
||||||
routes.Add(new Model.Services.RouteAttribute(DoubleNormalizeEmbyRoutePath(route.Path), route.Verbs)
|
routes.Add(new RouteAttribute(DoubleNormalizeEmbyRoutePath(route.Path), route.Verbs)
|
||||||
{
|
{
|
||||||
Notes = route.Notes,
|
Notes = route.Notes,
|
||||||
Priority = route.Priority,
|
Priority = route.Priority,
|
||||||
|
@ -622,14 +604,14 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||||
|
|
||||||
task.Wait();
|
task.Wait();
|
||||||
|
|
||||||
var type = task.GetType();
|
var type = task.GetType().GetTypeInfo();
|
||||||
if (!type.IsGenericType)
|
if (!type.IsGenericType)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.Warn("Getting task result from " + requestName + " using reflection. For better performance have your api return Task<object>");
|
Logger.Warn("Getting task result from " + requestName + " using reflection. For better performance have your api return Task<object>");
|
||||||
return type.GetProperty("Result").GetValue(task);
|
return type.GetDeclaredProperty("Result").GetValue(task);
|
||||||
}
|
}
|
||||||
catch (TypeAccessException)
|
catch (TypeAccessException)
|
||||||
{
|
{
|
||||||
|
@ -639,9 +621,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||||
|
|
||||||
public override Func<string, object> GetParseFn(Type propertyType)
|
public override Func<string, object> GetParseFn(Type propertyType)
|
||||||
{
|
{
|
||||||
var fn = JsvReader.GetParseFn(propertyType);
|
return _funcParseFn(propertyType);
|
||||||
|
|
||||||
return s => fn(s);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void SerializeToJson(object o, Stream stream)
|
public override void SerializeToJson(object o, Stream stream)
|
||||||
|
@ -721,44 +701,10 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||||
GC.SuppressFinalize(this);
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StartServer(IEnumerable<string> urlPrefixes, string certificatePath)
|
public void StartServer(IEnumerable<string> urlPrefixes)
|
||||||
{
|
{
|
||||||
CertificatePath = certificatePath;
|
|
||||||
UrlPrefixes = urlPrefixes.ToList();
|
UrlPrefixes = urlPrefixes.ToList();
|
||||||
Start(UrlPrefixes.First());
|
Start(UrlPrefixes.First());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class StreamFactory : IStreamFactory
|
|
||||||
{
|
|
||||||
public Stream CreateNetworkStream(ISocket socket, bool ownsSocket)
|
|
||||||
{
|
|
||||||
var netSocket = (NetSocket)socket;
|
|
||||||
|
|
||||||
return new NetworkStream(netSocket.Socket, ownsSocket);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Task AuthenticateSslStreamAsServer(Stream stream, ICertificate certificate)
|
|
||||||
{
|
|
||||||
var sslStream = (SslStream)stream;
|
|
||||||
var cert = (Certificate)certificate;
|
|
||||||
|
|
||||||
return sslStream.AuthenticateAsServerAsync(cert.X509Certificate);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Stream CreateSslStream(Stream innerStream, bool leaveInnerStreamOpen)
|
|
||||||
{
|
|
||||||
return new SslStream(innerStream, leaveInnerStreamOpen);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Certificate : ICertificate
|
|
||||||
{
|
|
||||||
public Certificate(X509Certificate x509Certificate)
|
|
||||||
{
|
|
||||||
X509Certificate = x509Certificate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public X509Certificate X509Certificate { get; private set; }
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -1,16 +1,14 @@
|
||||||
using MediaBrowser.Common.Configuration;
|
using System.Collections.Generic;
|
||||||
using MediaBrowser.Controller.Entities;
|
|
||||||
using MediaBrowser.Controller.Playlists;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using MediaBrowser.Common.Configuration;
|
||||||
|
using MediaBrowser.Controller.Entities;
|
||||||
|
using MediaBrowser.Controller.Playlists;
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
using MediaBrowser.Model.Querying;
|
using MediaBrowser.Model.Querying;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using MediaBrowser.Common.IO;
|
|
||||||
using MediaBrowser.Controller.IO;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Server.Implementations.Playlists
|
namespace Emby.Server.Implementations.Playlists
|
||||||
{
|
{
|
||||||
public class PlaylistsFolder : BasePluginFolder
|
public class PlaylistsFolder : BasePluginFolder
|
||||||
{
|
{
|
||||||
|
@ -39,7 +37,7 @@ namespace MediaBrowser.Server.Implementations.Playlists
|
||||||
|
|
||||||
public override string CollectionType
|
public override string CollectionType
|
||||||
{
|
{
|
||||||
get { return Model.Entities.CollectionType.Playlists; }
|
get { return MediaBrowser.Model.Entities.CollectionType.Playlists; }
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Task<QueryResult<BaseItem>> GetItemsInternal(InternalItemsQuery query)
|
protected override Task<QueryResult<BaseItem>> GetItemsInternal(InternalItemsQuery query)
|
|
@ -112,22 +112,22 @@ namespace Emby.Server.Implementations.ServerManager
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Starts this instance.
|
/// Starts this instance.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Start(IEnumerable<string> urlPrefixes, string certificatePath)
|
public void Start(IEnumerable<string> urlPrefixes)
|
||||||
{
|
{
|
||||||
ReloadHttpServer(urlPrefixes, certificatePath);
|
ReloadHttpServer(urlPrefixes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Restarts the Http Server, or starts it if not currently running
|
/// Restarts the Http Server, or starts it if not currently running
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void ReloadHttpServer(IEnumerable<string> urlPrefixes, string certificatePath)
|
private void ReloadHttpServer(IEnumerable<string> urlPrefixes)
|
||||||
{
|
{
|
||||||
_logger.Info("Loading Http Server");
|
_logger.Info("Loading Http Server");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
HttpServer = _applicationHost.Resolve<IHttpServer>();
|
HttpServer = _applicationHost.Resolve<IHttpServer>();
|
||||||
HttpServer.StartServer(urlPrefixes, certificatePath);
|
HttpServer.StartServer(urlPrefixes);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,19 +15,11 @@ namespace MediaBrowser.Controller.Net
|
||||||
/// <value>The URL prefix.</value>
|
/// <value>The URL prefix.</value>
|
||||||
IEnumerable<string> UrlPrefixes { get; }
|
IEnumerable<string> UrlPrefixes { get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the certificate path.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>The certificate path.</value>
|
|
||||||
string CertificatePath { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Starts the specified server name.
|
/// Starts the specified server name.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="urlPrefixes">The URL prefixes.</param>
|
/// <param name="urlPrefixes">The URL prefixes.</param>
|
||||||
/// <param name="certificatePath">If an https prefix is specified,
|
void StartServer(IEnumerable<string> urlPrefixes);
|
||||||
/// the ssl certificate localtion on the file system.</param>
|
|
||||||
void StartServer(IEnumerable<string> urlPrefixes, string certificatePath);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stops this instance.
|
/// Stops this instance.
|
||||||
|
|
|
@ -15,9 +15,7 @@ namespace MediaBrowser.Controller.Net
|
||||||
/// Starts this instance.
|
/// Starts this instance.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="urlPrefixes">The URL prefixes.</param>
|
/// <param name="urlPrefixes">The URL prefixes.</param>
|
||||||
/// <param name="certificatePath">If an https prefix is specified,
|
void Start(IEnumerable<string> urlPrefixes);
|
||||||
/// the ssl certificate localtion on the file system.</param>
|
|
||||||
void Start(IEnumerable<string> urlPrefixes, string certificatePath);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends a message to all clients currently connected via a web socket
|
/// Sends a message to all clients currently connected via a web socket
|
||||||
|
|
|
@ -10,6 +10,7 @@ using MediaBrowser.Common.IO;
|
||||||
using MediaBrowser.Controller.IO;
|
using MediaBrowser.Controller.IO;
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
using MediaBrowser.Controller.Providers;
|
using MediaBrowser.Controller.Providers;
|
||||||
|
using MediaBrowser.Model.Serialization;
|
||||||
|
|
||||||
namespace MediaBrowser.Server.Implementations.Devices
|
namespace MediaBrowser.Server.Implementations.Devices
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
using MediaBrowser.Common.Net;
|
|
||||||
using MediaBrowser.Controller;
|
|
||||||
using MediaBrowser.Controller.Configuration;
|
|
||||||
using MediaBrowser.Controller.Net;
|
|
||||||
using MediaBrowser.Model.Cryptography;
|
|
||||||
using MediaBrowser.Model.IO;
|
|
||||||
using MediaBrowser.Model.Logging;
|
|
||||||
using MediaBrowser.Model.Net;
|
|
||||||
using MediaBrowser.Model.Serialization;
|
|
||||||
using MediaBrowser.Model.Text;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Server.Implementations.HttpServer
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Class ServerFactory
|
|
||||||
/// </summary>
|
|
||||||
public static class ServerFactory
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Creates the server.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>IHttpServer.</returns>
|
|
||||||
public static IHttpServer CreateServer(IServerApplicationHost applicationHost,
|
|
||||||
ILogManager logManager,
|
|
||||||
IServerConfigurationManager config,
|
|
||||||
INetworkManager networkmanager,
|
|
||||||
IMemoryStreamFactory streamProvider,
|
|
||||||
string serverName,
|
|
||||||
string defaultRedirectpath,
|
|
||||||
ITextEncoding textEncoding,
|
|
||||||
ISocketFactory socketFactory,
|
|
||||||
ICryptoProvider cryptoProvider,
|
|
||||||
IJsonSerializer json,
|
|
||||||
IXmlSerializer xml)
|
|
||||||
{
|
|
||||||
return new HttpListenerHost(applicationHost, logManager, config, serverName, defaultRedirectpath, networkmanager, streamProvider, textEncoding, socketFactory, cryptoProvider, json, xml);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -42,21 +42,10 @@
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Emby.Common.Implementations">
|
|
||||||
<HintPath>..\ThirdParty\emby\Emby.Common.Implementations.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Emby.XmlTv, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\packages\Emby.XmlTv.1.0.0.63\lib\portable-net45+win8\Emby.XmlTv.dll</HintPath>
|
|
||||||
<Private>True</Private>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="INIFileParser, Version=2.3.0.0, Culture=neutral, PublicKeyToken=79af7b307b65cf3c, processorArchitecture=MSIL">
|
<Reference Include="INIFileParser, Version=2.3.0.0, Culture=neutral, PublicKeyToken=79af7b307b65cf3c, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\ini-parser.2.3.0\lib\net20\INIFileParser.dll</HintPath>
|
<HintPath>..\packages\ini-parser.2.3.0\lib\net20\INIFileParser.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="MediaBrowser.Naming, Version=1.0.6151.30291, Culture=neutral, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\packages\MediaBrowser.Naming.1.0.0.59\lib\portable-net45+win8\MediaBrowser.Naming.dll</HintPath>
|
|
||||||
<Private>True</Private>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Microsoft.IO.RecyclableMemoryStream, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
<Reference Include="Microsoft.IO.RecyclableMemoryStream, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\Microsoft.IO.RecyclableMemoryStream.1.1.0.0\lib\net45\Microsoft.IO.RecyclableMemoryStream.dll</HintPath>
|
<HintPath>..\packages\Microsoft.IO.RecyclableMemoryStream.1.1.0.0\lib\net45\Microsoft.IO.RecyclableMemoryStream.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
|
@ -65,38 +54,18 @@
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\ThirdParty\emby\Mono.Nat.dll</HintPath>
|
<HintPath>..\ThirdParty\emby\Mono.Nat.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Patterns.Logging, Version=1.0.6151.30227, Culture=neutral, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\packages\Patterns.Logging.1.0.0.6\lib\portable-net45+win8\Patterns.Logging.dll</HintPath>
|
|
||||||
<Private>True</Private>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="ServiceStack.Text, Version=4.5.4.0, Culture=neutral, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\packages\ServiceStack.Text.4.5.4\lib\net45\ServiceStack.Text.dll</HintPath>
|
|
||||||
<Private>True</Private>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="SharpCompress, Version=0.10.3.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="SharpCompress, Version=0.10.3.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\ThirdParty\SharpCompress\SharpCompress.dll</HintPath>
|
<HintPath>..\ThirdParty\SharpCompress\SharpCompress.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="SocketHttpListener.Portable">
|
|
||||||
<HintPath>..\ThirdParty\emby\SocketHttpListener.Portable.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="Microsoft.CSharp" />
|
<Reference Include="Microsoft.CSharp" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.IO.Compression" />
|
<Reference Include="System.IO.Compression" />
|
||||||
<Reference Include="System.Net" />
|
<Reference Include="System.Net" />
|
||||||
<Reference Include="System.Runtime.Serialization" />
|
|
||||||
<Reference Include="System.Security" />
|
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
<Reference Include="ServiceStack">
|
|
||||||
<HintPath>..\ThirdParty\ServiceStack\ServiceStack.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
<Reference Include="UniversalDetector, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\packages\UniversalDetector.1.0.1\lib\portable-net45+sl4+wp71+win8+wpa81\UniversalDetector.dll</HintPath>
|
|
||||||
<Private>True</Private>
|
|
||||||
</Reference>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="..\SharedVersion.cs">
|
<Compile Include="..\SharedVersion.cs">
|
||||||
|
@ -105,12 +74,9 @@
|
||||||
<Compile Include="Activity\ActivityRepository.cs" />
|
<Compile Include="Activity\ActivityRepository.cs" />
|
||||||
<Compile Include="Archiving\ZipClient.cs" />
|
<Compile Include="Archiving\ZipClient.cs" />
|
||||||
<Compile Include="Collections\CollectionsDynamicFolder.cs" />
|
<Compile Include="Collections\CollectionsDynamicFolder.cs" />
|
||||||
<Compile Include="Configuration\ServerConfigurationManager.cs" />
|
|
||||||
<Compile Include="Devices\DeviceRepository.cs" />
|
<Compile Include="Devices\DeviceRepository.cs" />
|
||||||
<Compile Include="Devices\CameraUploadsFolder.cs" />
|
<Compile Include="Devices\CameraUploadsFolder.cs" />
|
||||||
<Compile Include="EntryPoints\ExternalPortForwarding.cs" />
|
<Compile Include="EntryPoints\ExternalPortForwarding.cs" />
|
||||||
<Compile Include="HttpServer\HttpListenerHost.cs" />
|
|
||||||
<Compile Include="HttpServer\ServerFactory.cs" />
|
|
||||||
<Compile Include="IO\LibraryMonitor.cs" />
|
<Compile Include="IO\LibraryMonitor.cs" />
|
||||||
<Compile Include="IO\MemoryStreamProvider.cs" />
|
<Compile Include="IO\MemoryStreamProvider.cs" />
|
||||||
<Compile Include="LiveTv\TunerHosts\SatIp\ChannelScan.cs" />
|
<Compile Include="LiveTv\TunerHosts\SatIp\ChannelScan.cs" />
|
||||||
|
@ -143,10 +109,8 @@
|
||||||
<Compile Include="Persistence\SqliteFileOrganizationRepository.cs" />
|
<Compile Include="Persistence\SqliteFileOrganizationRepository.cs" />
|
||||||
<Compile Include="Notifications\SqliteNotificationsRepository.cs" />
|
<Compile Include="Notifications\SqliteNotificationsRepository.cs" />
|
||||||
<Compile Include="Persistence\TypeMapper.cs" />
|
<Compile Include="Persistence\TypeMapper.cs" />
|
||||||
<Compile Include="Playlists\ManualPlaylistsFolder.cs" />
|
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Security\AuthenticationRepository.cs" />
|
<Compile Include="Security\AuthenticationRepository.cs" />
|
||||||
<Compile Include="ServerApplicationPaths.cs" />
|
|
||||||
<Compile Include="Persistence\SqliteDisplayPreferencesRepository.cs" />
|
<Compile Include="Persistence\SqliteDisplayPreferencesRepository.cs" />
|
||||||
<Compile Include="Persistence\SqliteItemRepository.cs" />
|
<Compile Include="Persistence\SqliteItemRepository.cs" />
|
||||||
<Compile Include="Persistence\SqliteUserDataRepository.cs" />
|
<Compile Include="Persistence\SqliteUserDataRepository.cs" />
|
||||||
|
@ -170,10 +134,6 @@
|
||||||
<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.Providers\MediaBrowser.Providers.csproj">
|
|
||||||
<Project>{442b5058-dcaf-4263-bb6a-f21e31120a1b}</Project>
|
|
||||||
<Name>MediaBrowser.Providers</Name>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="app.config" />
|
<None Include="app.config" />
|
||||||
|
@ -348,9 +308,7 @@
|
||||||
<None Include="LiveTv\TunerHosts\SatIp\ini\satellite\3594.ini" />
|
<None Include="LiveTv\TunerHosts\SatIp\ini\satellite\3594.ini" />
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup />
|
||||||
<Folder Include="Serialization\" />
|
|
||||||
</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.
|
||||||
|
|
|
@ -18,6 +18,7 @@ using System.Runtime.Serialization;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Emby.Server.Implementations.Playlists;
|
||||||
using MediaBrowser.Common.Extensions;
|
using MediaBrowser.Common.Extensions;
|
||||||
using MediaBrowser.Common.IO;
|
using MediaBrowser.Common.IO;
|
||||||
using MediaBrowser.Controller.Channels;
|
using MediaBrowser.Controller.Channels;
|
||||||
|
@ -30,7 +31,6 @@ using MediaBrowser.Model.Extensions;
|
||||||
using MediaBrowser.Model.IO;
|
using MediaBrowser.Model.IO;
|
||||||
using MediaBrowser.Model.LiveTv;
|
using MediaBrowser.Model.LiveTv;
|
||||||
using MediaBrowser.Server.Implementations.Devices;
|
using MediaBrowser.Server.Implementations.Devices;
|
||||||
using MediaBrowser.Server.Implementations.Playlists;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Server.Implementations.Persistence
|
namespace MediaBrowser.Server.Implementations.Persistence
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
<package id="Emby.XmlTv" version="1.0.0.63" targetFramework="net46" />
|
|
||||||
<package id="ini-parser" version="2.3.0" targetFramework="net45" />
|
<package id="ini-parser" version="2.3.0" targetFramework="net45" />
|
||||||
<package id="MediaBrowser.Naming" version="1.0.0.59" targetFramework="net46" />
|
|
||||||
<package id="Microsoft.IO.RecyclableMemoryStream" version="1.1.0.0" targetFramework="net46" />
|
<package id="Microsoft.IO.RecyclableMemoryStream" version="1.1.0.0" targetFramework="net46" />
|
||||||
<package id="Patterns.Logging" version="1.0.0.6" targetFramework="net46" />
|
|
||||||
<package id="ServiceStack.Text" version="4.5.4" targetFramework="net46" />
|
|
||||||
<package id="UniversalDetector" version="1.0.1" targetFramework="net46" />
|
|
||||||
</packages>
|
</packages>
|
|
@ -50,9 +50,7 @@ using MediaBrowser.Providers.Manager;
|
||||||
using MediaBrowser.Providers.Subtitles;
|
using MediaBrowser.Providers.Subtitles;
|
||||||
using MediaBrowser.Server.Implementations;
|
using MediaBrowser.Server.Implementations;
|
||||||
using MediaBrowser.Server.Implementations.Activity;
|
using MediaBrowser.Server.Implementations.Activity;
|
||||||
using MediaBrowser.Server.Implementations.Configuration;
|
|
||||||
using MediaBrowser.Server.Implementations.Devices;
|
using MediaBrowser.Server.Implementations.Devices;
|
||||||
using MediaBrowser.Server.Implementations.HttpServer;
|
|
||||||
using MediaBrowser.Server.Implementations.IO;
|
using MediaBrowser.Server.Implementations.IO;
|
||||||
using MediaBrowser.Server.Implementations.Notifications;
|
using MediaBrowser.Server.Implementations.Notifications;
|
||||||
using MediaBrowser.Server.Implementations.Persistence;
|
using MediaBrowser.Server.Implementations.Persistence;
|
||||||
|
@ -72,6 +70,7 @@ using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Security.Cryptography.X509Certificates;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Emby.Common.Implementations;
|
using Emby.Common.Implementations;
|
||||||
|
@ -133,8 +132,10 @@ using MediaBrowser.Model.Social;
|
||||||
using MediaBrowser.Model.Text;
|
using MediaBrowser.Model.Text;
|
||||||
using MediaBrowser.Model.Xml;
|
using MediaBrowser.Model.Xml;
|
||||||
using MediaBrowser.Server.Implementations.Archiving;
|
using MediaBrowser.Server.Implementations.Archiving;
|
||||||
|
using MediaBrowser.Server.Startup.Common.Configuration;
|
||||||
using OpenSubtitlesHandler;
|
using OpenSubtitlesHandler;
|
||||||
using ServiceStack;
|
using ServiceStack;
|
||||||
|
using SocketHttpListener.Primitives;
|
||||||
using StringExtensions = MediaBrowser.Controller.Extensions.StringExtensions;
|
using StringExtensions = MediaBrowser.Controller.Extensions.StringExtensions;
|
||||||
|
|
||||||
namespace MediaBrowser.Server.Startup.Common
|
namespace MediaBrowser.Server.Startup.Common
|
||||||
|
@ -613,7 +614,7 @@ namespace MediaBrowser.Server.Startup.Common
|
||||||
|
|
||||||
RegisterSingleInstance<ISearchEngine>(() => new SearchEngine(LogManager, LibraryManager, UserManager));
|
RegisterSingleInstance<ISearchEngine>(() => new SearchEngine(LogManager, LibraryManager, UserManager));
|
||||||
|
|
||||||
HttpServer = ServerFactory.CreateServer(this, LogManager, ServerConfigurationManager, NetworkManager, MemoryStreamProvider, "Emby", "web/index.html", textEncoding, SocketFactory, CryptographyProvider, JsonSerializer, XmlSerializer);
|
HttpServer = HttpServerFactory.CreateServer(this, LogManager, ServerConfigurationManager, NetworkManager, MemoryStreamProvider, "Emby", "web/index.html", textEncoding, SocketFactory, CryptographyProvider, JsonSerializer, XmlSerializer, EnvironmentInfo, Certificate);
|
||||||
HttpServer.GlobalResponse = LocalizationManager.GetLocalizedString("StartupEmbyServerIsLoading");
|
HttpServer.GlobalResponse = LocalizationManager.GetLocalizedString("StartupEmbyServerIsLoading");
|
||||||
RegisterSingleInstance(HttpServer, false);
|
RegisterSingleInstance(HttpServer, false);
|
||||||
progress.Report(10);
|
progress.Report(10);
|
||||||
|
@ -736,6 +737,32 @@ namespace MediaBrowser.Server.Startup.Common
|
||||||
await ((UserManager)UserManager).Initialize().ConfigureAwait(false);
|
await ((UserManager)UserManager).Initialize().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ICertificate GetCertificate(string certificateLocation)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(certificateLocation))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
X509Certificate2 localCert = new X509Certificate2(certificateLocation);
|
||||||
|
//localCert.PrivateKey = PrivateKey.CreateFromFile(pvk_file).RSA;
|
||||||
|
if (localCert.PrivateKey == null)
|
||||||
|
{
|
||||||
|
//throw new FileNotFoundException("Secure requested, no private key included", certificateLocation);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Certificate(localCert);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.ErrorException("Error loading cert from {0}", ex, certificateLocation);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private IImageProcessor GetImageProcessor()
|
private IImageProcessor GetImageProcessor()
|
||||||
{
|
{
|
||||||
var maxConcurrentImageProcesses = Math.Max(Environment.ProcessorCount, 4);
|
var maxConcurrentImageProcesses = Math.Max(Environment.ProcessorCount, 4);
|
||||||
|
@ -969,6 +996,7 @@ namespace MediaBrowser.Server.Startup.Common
|
||||||
}
|
}
|
||||||
|
|
||||||
private string CertificatePath { get; set; }
|
private string CertificatePath { get; set; }
|
||||||
|
private ICertificate Certificate { get; set; }
|
||||||
|
|
||||||
private IEnumerable<string> GetUrlPrefixes()
|
private IEnumerable<string> GetUrlPrefixes()
|
||||||
{
|
{
|
||||||
|
@ -998,10 +1026,11 @@ namespace MediaBrowser.Server.Startup.Common
|
||||||
private void StartServer()
|
private void StartServer()
|
||||||
{
|
{
|
||||||
CertificatePath = GetCertificatePath(true);
|
CertificatePath = GetCertificatePath(true);
|
||||||
|
Certificate = GetCertificate(CertificatePath);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ServerManager.Start(GetUrlPrefixes(), CertificatePath);
|
ServerManager.Start(GetUrlPrefixes());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -1018,7 +1047,7 @@ namespace MediaBrowser.Server.Startup.Common
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ServerManager.Start(GetUrlPrefixes(), CertificatePath);
|
ServerManager.Start(GetUrlPrefixes());
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -1298,7 +1327,7 @@ namespace MediaBrowser.Server.Startup.Common
|
||||||
|
|
||||||
public bool SupportsHttps
|
public bool SupportsHttps
|
||||||
{
|
{
|
||||||
get { return !string.IsNullOrWhiteSpace(HttpServer.CertificatePath); }
|
get { return Certificate != null; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<string> GetLocalApiUrl()
|
public async Task<string> GetLocalApiUrl()
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using Emby.Common.Implementations.Configuration;
|
||||||
using MediaBrowser.Common.Configuration;
|
using MediaBrowser.Common.Configuration;
|
||||||
using MediaBrowser.Common.Events;
|
using MediaBrowser.Common.Events;
|
||||||
using Emby.Common.Implementations.Configuration;
|
|
||||||
using MediaBrowser.Controller;
|
using MediaBrowser.Controller;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
|
@ -10,16 +13,11 @@ using MediaBrowser.Controller.Entities.Movies;
|
||||||
using MediaBrowser.Controller.Entities.TV;
|
using MediaBrowser.Controller.Entities.TV;
|
||||||
using MediaBrowser.Model.Configuration;
|
using MediaBrowser.Model.Configuration;
|
||||||
using MediaBrowser.Model.Events;
|
using MediaBrowser.Model.Events;
|
||||||
|
using MediaBrowser.Model.IO;
|
||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
using MediaBrowser.Model.Serialization;
|
using MediaBrowser.Model.Serialization;
|
||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using MediaBrowser.Common.IO;
|
|
||||||
using MediaBrowser.Controller.IO;
|
|
||||||
using MediaBrowser.Model.IO;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Server.Implementations.Configuration
|
namespace MediaBrowser.Server.Startup.Common.Configuration
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Class ServerConfigurationManager
|
/// Class ServerConfigurationManager
|
107
MediaBrowser.Server.Startup.Common/HttpServerFactory.cs
Normal file
107
MediaBrowser.Server.Startup.Common/HttpServerFactory.cs
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Net.Security;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using System.Security.Cryptography.X509Certificates;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Emby.Common.Implementations.Net;
|
||||||
|
using Emby.Server.Implementations.HttpServer;
|
||||||
|
using MediaBrowser.Common.Net;
|
||||||
|
using MediaBrowser.Controller;
|
||||||
|
using MediaBrowser.Controller.Configuration;
|
||||||
|
using MediaBrowser.Controller.Net;
|
||||||
|
using MediaBrowser.Model.Cryptography;
|
||||||
|
using MediaBrowser.Model.IO;
|
||||||
|
using MediaBrowser.Model.Logging;
|
||||||
|
using MediaBrowser.Model.Net;
|
||||||
|
using MediaBrowser.Model.Serialization;
|
||||||
|
using MediaBrowser.Model.System;
|
||||||
|
using MediaBrowser.Model.Text;
|
||||||
|
using ServiceStack.Text.Jsv;
|
||||||
|
using SocketHttpListener.Primitives;
|
||||||
|
|
||||||
|
namespace MediaBrowser.Server.Startup.Common
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Class ServerFactory
|
||||||
|
/// </summary>
|
||||||
|
public static class HttpServerFactory
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Creates the server.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>IHttpServer.</returns>
|
||||||
|
public static IHttpServer CreateServer(IServerApplicationHost applicationHost,
|
||||||
|
ILogManager logManager,
|
||||||
|
IServerConfigurationManager config,
|
||||||
|
INetworkManager networkmanager,
|
||||||
|
IMemoryStreamFactory streamProvider,
|
||||||
|
string serverName,
|
||||||
|
string defaultRedirectpath,
|
||||||
|
ITextEncoding textEncoding,
|
||||||
|
ISocketFactory socketFactory,
|
||||||
|
ICryptoProvider cryptoProvider,
|
||||||
|
IJsonSerializer json,
|
||||||
|
IXmlSerializer xml,
|
||||||
|
IEnvironmentInfo environment,
|
||||||
|
ICertificate certificate)
|
||||||
|
{
|
||||||
|
var logger = logManager.GetLogger("HttpServer");
|
||||||
|
|
||||||
|
return new HttpListenerHost(applicationHost,
|
||||||
|
logger,
|
||||||
|
config,
|
||||||
|
serverName,
|
||||||
|
defaultRedirectpath,
|
||||||
|
networkmanager,
|
||||||
|
streamProvider,
|
||||||
|
textEncoding,
|
||||||
|
socketFactory,
|
||||||
|
cryptoProvider,
|
||||||
|
json,
|
||||||
|
xml,
|
||||||
|
environment,
|
||||||
|
certificate,
|
||||||
|
new StreamFactory(),
|
||||||
|
GetParseFn);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Func<string, object> GetParseFn(Type propertyType)
|
||||||
|
{
|
||||||
|
return s => JsvReader.GetParseFn(propertyType)(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class StreamFactory : IStreamFactory
|
||||||
|
{
|
||||||
|
public Stream CreateNetworkStream(ISocket socket, bool ownsSocket)
|
||||||
|
{
|
||||||
|
var netSocket = (NetSocket)socket;
|
||||||
|
|
||||||
|
return new NetworkStream(netSocket.Socket, ownsSocket);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task AuthenticateSslStreamAsServer(Stream stream, ICertificate certificate)
|
||||||
|
{
|
||||||
|
var sslStream = (SslStream)stream;
|
||||||
|
var cert = (Certificate)certificate;
|
||||||
|
|
||||||
|
return sslStream.AuthenticateAsServerAsync(cert.X509Certificate);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Stream CreateSslStream(Stream innerStream, bool leaveInnerStreamOpen)
|
||||||
|
{
|
||||||
|
return new SslStream(innerStream, leaveInnerStreamOpen);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Certificate : ICertificate
|
||||||
|
{
|
||||||
|
public Certificate(X509Certificate x509Certificate)
|
||||||
|
{
|
||||||
|
X509Certificate = x509Certificate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public X509Certificate X509Certificate { get; private set; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -49,14 +49,22 @@
|
||||||
<HintPath>..\packages\Patterns.Logging.1.0.0.6\lib\portable-net45+win8\Patterns.Logging.dll</HintPath>
|
<HintPath>..\packages\Patterns.Logging.1.0.0.6\lib\portable-net45+win8\Patterns.Logging.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="ServiceStack.Text, Version=4.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="ServiceStack, Version=4.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\ThirdParty\ServiceStack.Text\ServiceStack.Text.dll</HintPath>
|
<HintPath>..\ThirdParty\ServiceStack\ServiceStack.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="ServiceStack.Text, Version=4.5.4.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\ServiceStack.Text.4.5.4\lib\net45\ServiceStack.Text.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="SimpleInjector, Version=3.2.4.0, Culture=neutral, PublicKeyToken=984cb50dea722e99, processorArchitecture=MSIL">
|
<Reference Include="SimpleInjector, Version=3.2.4.0, Culture=neutral, PublicKeyToken=984cb50dea722e99, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\SimpleInjector.3.2.4\lib\net45\SimpleInjector.dll</HintPath>
|
<HintPath>..\packages\SimpleInjector.3.2.4\lib\net45\SimpleInjector.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="SocketHttpListener.Portable, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\ThirdParty\emby\SocketHttpListener.Portable.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Configuration" />
|
<Reference Include="System.Configuration" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
|
@ -73,10 +81,12 @@
|
||||||
<Compile Include="ApplicationHost.cs" />
|
<Compile Include="ApplicationHost.cs" />
|
||||||
<Compile Include="ApplicationPathHelper.cs" />
|
<Compile Include="ApplicationPathHelper.cs" />
|
||||||
<Compile Include="Browser\BrowserLauncher.cs" />
|
<Compile Include="Browser\BrowserLauncher.cs" />
|
||||||
|
<Compile Include="Configuration\ServerConfigurationManager.cs" />
|
||||||
<Compile Include="EntryPoints\StartupWizard.cs" />
|
<Compile Include="EntryPoints\StartupWizard.cs" />
|
||||||
<Compile Include="FFMpeg\FFMpegLoader.cs" />
|
<Compile Include="FFMpeg\FFMpegLoader.cs" />
|
||||||
<Compile Include="FFMpeg\FFMpegInstallInfo.cs" />
|
<Compile Include="FFMpeg\FFMpegInstallInfo.cs" />
|
||||||
<Compile Include="FFMpeg\FFMpegInfo.cs" />
|
<Compile Include="FFMpeg\FFMpegInfo.cs" />
|
||||||
|
<Compile Include="HttpServerFactory.cs" />
|
||||||
<Compile Include="INativeApp.cs" />
|
<Compile Include="INativeApp.cs" />
|
||||||
<Compile Include="MbLinkShortcutHandler.cs" />
|
<Compile Include="MbLinkShortcutHandler.cs" />
|
||||||
<Compile Include="Migrations\IVersionMigration.cs" />
|
<Compile Include="Migrations\IVersionMigration.cs" />
|
||||||
|
@ -103,6 +113,7 @@
|
||||||
<Compile Include="Security\X509Extension.cs" />
|
<Compile Include="Security\X509Extension.cs" />
|
||||||
<Compile Include="Security\X509Extensions.cs" />
|
<Compile Include="Security\X509Extensions.cs" />
|
||||||
<Compile Include="Security\X520Attributes.cs" />
|
<Compile Include="Security\X520Attributes.cs" />
|
||||||
|
<Compile Include="ServerApplicationPaths.cs" />
|
||||||
<Compile Include="StartupOptions.cs" />
|
<Compile Include="StartupOptions.cs" />
|
||||||
<Compile Include="SystemEvents.cs" />
|
<Compile Include="SystemEvents.cs" />
|
||||||
<Compile Include="TextLocalizer.cs" />
|
<Compile Include="TextLocalizer.cs" />
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
using Emby.Common.Implementations;
|
using System.IO;
|
||||||
|
using Emby.Common.Implementations;
|
||||||
using MediaBrowser.Controller;
|
using MediaBrowser.Controller;
|
||||||
using System.IO;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Server.Implementations
|
namespace MediaBrowser.Server.Startup.Common
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Extends BaseApplicationPaths to add paths that are only applicable on the server
|
/// Extends BaseApplicationPaths to add paths that are only applicable on the server
|
|
@ -3,5 +3,6 @@
|
||||||
<package id="MediaBrowser.Naming" version="1.0.0.59" targetFramework="net46" />
|
<package id="MediaBrowser.Naming" version="1.0.0.59" targetFramework="net46" />
|
||||||
<package id="Mono.Posix" version="4.0.0.0" targetFramework="net45" />
|
<package id="Mono.Posix" version="4.0.0.0" targetFramework="net45" />
|
||||||
<package id="Patterns.Logging" version="1.0.0.6" targetFramework="net46" />
|
<package id="Patterns.Logging" version="1.0.0.6" targetFramework="net46" />
|
||||||
|
<package id="ServiceStack.Text" version="4.5.4" targetFramework="net46" />
|
||||||
<package id="SimpleInjector" version="3.2.4" targetFramework="net46" />
|
<package id="SimpleInjector" version="3.2.4" targetFramework="net46" />
|
||||||
</packages>
|
</packages>
|
Loading…
Reference in New Issue
Block a user