aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2016-11-10 22:29:51 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2016-11-10 22:29:51 -0500
commit8492225deef59b4548976e162f6fa147abf923be (patch)
tree07d34cac573c69e3a8163026785043ea6a167f9b
parent836e1fdc30f149d3548dc0b529d31ba96de28734 (diff)
update portable projects
-rw-r--r--Emby.Server.Implementations/Emby.Server.Implementations.csproj2
-rw-r--r--Emby.Server.Implementations/HttpServer/HttpListenerHost.cs (renamed from MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs)138
-rw-r--r--Emby.Server.Implementations/Playlists/ManualPlaylistsFolder.cs (renamed from MediaBrowser.Server.Implementations/Playlists/ManualPlaylistsFolder.cs)16
-rw-r--r--Emby.Server.Implementations/ServerManager/ServerManager.cs8
-rw-r--r--MediaBrowser.Controller/Net/IHttpServer.cs10
-rw-r--r--MediaBrowser.Controller/Net/IServerManager.cs4
-rw-r--r--MediaBrowser.Server.Implementations/Devices/CameraUploadsFolder.cs1
-rw-r--r--MediaBrowser.Server.Implementations/HttpServer/ServerFactory.cs39
-rw-r--r--MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj44
-rw-r--r--MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs2
-rw-r--r--MediaBrowser.Server.Implementations/packages.config5
-rw-r--r--MediaBrowser.Server.Startup.Common/ApplicationHost.cs43
-rw-r--r--MediaBrowser.Server.Startup.Common/Configuration/ServerConfigurationManager.cs (renamed from MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs)16
-rw-r--r--MediaBrowser.Server.Startup.Common/HttpServerFactory.cs107
-rw-r--r--MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj15
-rw-r--r--MediaBrowser.Server.Startup.Common/ServerApplicationPaths.cs (renamed from MediaBrowser.Server.Implementations/ServerApplicationPaths.cs)6
-rw-r--r--MediaBrowser.Server.Startup.Common/packages.config1
17 files changed, 227 insertions, 230 deletions
diff --git a/Emby.Server.Implementations/Emby.Server.Implementations.csproj b/Emby.Server.Implementations/Emby.Server.Implementations.csproj
index 07f3bd020..ccdecbf7b 100644
--- a/Emby.Server.Implementations/Emby.Server.Implementations.csproj
+++ b/Emby.Server.Implementations/Emby.Server.Implementations.csproj
@@ -69,6 +69,7 @@
<Compile Include="FileOrganization\OrganizerScheduledTask.cs" />
<Compile Include="FileOrganization\TvFolderOrganizer.cs" />
<Compile Include="HttpServer\GetSwaggerResource.cs" />
+ <Compile Include="HttpServer\HttpListenerHost.cs" />
<Compile Include="HttpServer\HttpResultFactory.cs" />
<Compile Include="HttpServer\LoggerUtils.cs" />
<Compile Include="HttpServer\RangeRequestWriter.cs" />
@@ -172,6 +173,7 @@
<Compile Include="Notifications\WebSocketNotifier.cs" />
<Compile Include="Persistence\CleanDatabaseScheduledTask.cs" />
<Compile Include="Photos\PhotoAlbumImageProvider.cs" />
+ <Compile Include="Playlists\ManualPlaylistsFolder.cs" />
<Compile Include="Playlists\PlaylistImageProvider.cs" />
<Compile Include="Playlists\PlaylistManager.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs
index f0a9c5ca3..d7897f165 100644
--- a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs
+++ b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs
@@ -8,12 +8,8 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
-using System.Net.Security;
-using System.Net.Sockets;
using System.Reflection;
-using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;
-using Emby.Common.Implementations.Net;
using Emby.Server.Implementations.HttpServer;
using Emby.Server.Implementations.HttpServer.SocketSharp;
using MediaBrowser.Common.Net;
@@ -25,12 +21,12 @@ using MediaBrowser.Model.IO;
using MediaBrowser.Model.Net;
using MediaBrowser.Model.Serialization;
using MediaBrowser.Model.Services;
+using MediaBrowser.Model.System;
using MediaBrowser.Model.Text;
-using ServiceStack.Text.Jsv;
using SocketHttpListener.Net;
using SocketHttpListener.Primitives;
-namespace MediaBrowser.Server.Implementations.HttpServer
+namespace Emby.Server.Implementations.HttpServer
{
public class HttpListenerHost : ServiceStackHost, IHttpServer
{
@@ -46,8 +42,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer
public event EventHandler<WebSocketConnectEventArgs> WebSocketConnected;
public event EventHandler<WebSocketConnectingEventArgs> WebSocketConnecting;
- public string CertificatePath { get; private set; }
-
private readonly IServerConfigurationManager _config;
private readonly INetworkManager _networkManager;
private readonly IMemoryStreamFactory _memoryStreamProvider;
@@ -60,12 +54,16 @@ namespace MediaBrowser.Server.Implementations.HttpServer
private readonly IJsonSerializer _jsonSerializer;
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,
- ILogManager logManager,
+ ILogger logger,
IServerConfigurationManager config,
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[] { })
{
_appHost = applicationHost;
@@ -77,9 +75,13 @@ namespace MediaBrowser.Server.Implementations.HttpServer
_cryptoProvider = cryptoProvider;
_jsonSerializer = jsonSerializer;
_xmlSerializer = xmlSerializer;
+ _environment = environment;
+ _certificate = certificate;
+ _streamFactory = streamFactory;
+ _funcParseFn = funcParseFn;
_config = config;
- _logger = logManager.GetLogger("HttpServer");
+ _logger = logger;
}
public string GlobalResponse { get; set; }
@@ -92,11 +94,10 @@ namespace MediaBrowser.Server.Implementations.HttpServer
{typeof (NotImplementedException), 500},
{typeof (ResourceNotFoundException), 404},
{typeof (FileNotFoundException), 404},
- {typeof (DirectoryNotFoundException), 404},
+ //{typeof (DirectoryNotFoundException), 404},
{typeof (SecurityException), 401},
{typeof (PaymentRequiredException), 402},
{typeof (UnauthorizedAccessException), 500},
- {typeof (ApplicationException), 500},
{typeof (PlatformNotSupportedException), 500},
{typeof (NotSupportedException), 500}
};
@@ -123,16 +124,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer
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>()
{
return _appHost.TryResolve<T>();
@@ -187,34 +178,18 @@ namespace MediaBrowser.Server.Implementations.HttpServer
private IHttpListener GetListener()
{
- var cert = !string.IsNullOrWhiteSpace(CertificatePath) && File.Exists(CertificatePath)
- ? GetCert(CertificatePath) :
- null;
-
- var enableDualMode = Environment.OSVersion.Platform == PlatformID.Win32NT;
+ var enableDualMode = _environment.OperatingSystem == OperatingSystem.Windows;
- return new WebSocketSharpListener(_logger, cert, _memoryStreamProvider, _textEncoding, _networkManager, _socketFactory, _cryptoProvider, new StreamFactory(), enableDualMode, GetRequest);
- }
-
- public ICertificate GetCert(string certificateLocation)
- {
- 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;
- }
+ return new WebSocketSharpListener(_logger,
+ _certificate,
+ _memoryStreamProvider,
+ _textEncoding,
+ _networkManager,
+ _socketFactory,
+ _cryptoProvider,
+ _streamFactory,
+ enableDualMode,
+ GetRequest);
}
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
var newQueryString = MyHttpUtility.ParseQueryString(uri.Query);
- if (newQueryString.Count == 0)
+ var originalCount = newQueryString.Count;
+
+ if (originalCount == 0)
{
return url;
}
@@ -336,8 +313,13 @@ namespace MediaBrowser.Server.Implementations.HttpServer
// this removes the key if exists
newQueryString.Remove(key);
+ if (originalCount == newQueryString.Count)
+ {
+ return url;
+ }
+
// 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
? String.Format("{0}?{1}", pagePathWithoutQueryString, newQueryString)
@@ -578,28 +560,28 @@ namespace MediaBrowser.Server.Implementations.HttpServer
base.Init();
}
- public override Model.Services.RouteAttribute[] GetRouteAttributes(Type requestType)
+ public override RouteAttribute[] GetRouteAttributes(Type requestType)
{
var routes = base.GetRouteAttributes(requestType).ToList();
var clone = routes.ToList();
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,
Priority = route.Priority,
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,
Priority = route.Priority,
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,
Priority = route.Priority,
@@ -622,14 +604,14 @@ namespace MediaBrowser.Server.Implementations.HttpServer
task.Wait();
- var type = task.GetType();
+ var type = task.GetType().GetTypeInfo();
if (!type.IsGenericType)
{
return null;
}
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)
{
@@ -639,9 +621,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
public override Func<string, object> GetParseFn(Type propertyType)
{
- var fn = JsvReader.GetParseFn(propertyType);
-
- return s => fn(s);
+ return _funcParseFn(propertyType);
}
public override void SerializeToJson(object o, Stream stream)
@@ -721,44 +701,10 @@ namespace MediaBrowser.Server.Implementations.HttpServer
GC.SuppressFinalize(this);
}
- public void StartServer(IEnumerable<string> urlPrefixes, string certificatePath)
+ public void StartServer(IEnumerable<string> urlPrefixes)
{
- CertificatePath = certificatePath;
UrlPrefixes = urlPrefixes.ToList();
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; }
- }
} \ No newline at end of file
diff --git a/MediaBrowser.Server.Implementations/Playlists/ManualPlaylistsFolder.cs b/Emby.Server.Implementations/Playlists/ManualPlaylistsFolder.cs
index eff77574d..8e65ccaf7 100644
--- a/MediaBrowser.Server.Implementations/Playlists/ManualPlaylistsFolder.cs
+++ b/Emby.Server.Implementations/Playlists/ManualPlaylistsFolder.cs
@@ -1,16 +1,14 @@
-using MediaBrowser.Common.Configuration;
-using MediaBrowser.Controller.Entities;
-using MediaBrowser.Controller.Playlists;
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.IO;
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.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
{
@@ -39,7 +37,7 @@ namespace MediaBrowser.Server.Implementations.Playlists
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)
diff --git a/Emby.Server.Implementations/ServerManager/ServerManager.cs b/Emby.Server.Implementations/ServerManager/ServerManager.cs
index f660d01ec..f7e4c0ce2 100644
--- a/Emby.Server.Implementations/ServerManager/ServerManager.cs
+++ b/Emby.Server.Implementations/ServerManager/ServerManager.cs
@@ -112,22 +112,22 @@ namespace Emby.Server.Implementations.ServerManager
/// <summary>
/// Starts this instance.
/// </summary>
- public void Start(IEnumerable<string> urlPrefixes, string certificatePath)
+ public void Start(IEnumerable<string> urlPrefixes)
{
- ReloadHttpServer(urlPrefixes, certificatePath);
+ ReloadHttpServer(urlPrefixes);
}
/// <summary>
/// Restarts the Http Server, or starts it if not currently running
/// </summary>
- private void ReloadHttpServer(IEnumerable<string> urlPrefixes, string certificatePath)
+ private void ReloadHttpServer(IEnumerable<string> urlPrefixes)
{
_logger.Info("Loading Http Server");
try
{
HttpServer = _applicationHost.Resolve<IHttpServer>();
- HttpServer.StartServer(urlPrefixes, certificatePath);
+ HttpServer.StartServer(urlPrefixes);
}
catch (Exception ex)
{
diff --git a/MediaBrowser.Controller/Net/IHttpServer.cs b/MediaBrowser.Controller/Net/IHttpServer.cs
index 8c503c199..f319244da 100644
--- a/MediaBrowser.Controller/Net/IHttpServer.cs
+++ b/MediaBrowser.Controller/Net/IHttpServer.cs
@@ -16,18 +16,10 @@ namespace MediaBrowser.Controller.Net
IEnumerable<string> UrlPrefixes { get; }
/// <summary>
- /// Gets the certificate path.
- /// </summary>
- /// <value>The certificate path.</value>
- string CertificatePath { get; }
-
- /// <summary>
/// Starts the specified server name.
/// </summary>
/// <param name="urlPrefixes">The URL prefixes.</param>
- /// <param name="certificatePath">If an https prefix is specified,
- /// the ssl certificate localtion on the file system.</param>
- void StartServer(IEnumerable<string> urlPrefixes, string certificatePath);
+ void StartServer(IEnumerable<string> urlPrefixes);
/// <summary>
/// Stops this instance.
diff --git a/MediaBrowser.Controller/Net/IServerManager.cs b/MediaBrowser.Controller/Net/IServerManager.cs
index 5191a62e3..202df2982 100644
--- a/MediaBrowser.Controller/Net/IServerManager.cs
+++ b/MediaBrowser.Controller/Net/IServerManager.cs
@@ -15,9 +15,7 @@ namespace MediaBrowser.Controller.Net
/// Starts this instance.
/// </summary>
/// <param name="urlPrefixes">The URL prefixes.</param>
- /// <param name="certificatePath">If an https prefix is specified,
- /// the ssl certificate localtion on the file system.</param>
- void Start(IEnumerable<string> urlPrefixes, string certificatePath);
+ void Start(IEnumerable<string> urlPrefixes);
/// <summary>
/// Sends a message to all clients currently connected via a web socket
diff --git a/MediaBrowser.Server.Implementations/Devices/CameraUploadsFolder.cs b/MediaBrowser.Server.Implementations/Devices/CameraUploadsFolder.cs
index 19a0593e3..882701885 100644
--- a/MediaBrowser.Server.Implementations/Devices/CameraUploadsFolder.cs
+++ b/MediaBrowser.Server.Implementations/Devices/CameraUploadsFolder.cs
@@ -10,6 +10,7 @@ using MediaBrowser.Common.IO;
using MediaBrowser.Controller.IO;
using MediaBrowser.Model.IO;
using MediaBrowser.Controller.Providers;
+using MediaBrowser.Model.Serialization;
namespace MediaBrowser.Server.Implementations.Devices
{
diff --git a/MediaBrowser.Server.Implementations/HttpServer/ServerFactory.cs b/MediaBrowser.Server.Implementations/HttpServer/ServerFactory.cs
deleted file mode 100644
index abcf84abd..000000000
--- a/MediaBrowser.Server.Implementations/HttpServer/ServerFactory.cs
+++ /dev/null
@@ -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);
- }
- }
-}
diff --git a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
index 6fb4f9e36..8d5697c49 100644
--- a/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
+++ b/MediaBrowser.Server.Implementations/MediaBrowser.Server.Implementations.csproj
@@ -42,21 +42,10 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<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">
<HintPath>..\packages\ini-parser.2.3.0\lib\net20\INIFileParser.dll</HintPath>
<Private>True</Private>
</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">
<HintPath>..\packages\Microsoft.IO.RecyclableMemoryStream.1.1.0.0\lib\net45\Microsoft.IO.RecyclableMemoryStream.dll</HintPath>
<Private>True</Private>
@@ -65,38 +54,18 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\ThirdParty\emby\Mono.Nat.dll</HintPath>
</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">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\ThirdParty\SharpCompress\SharpCompress.dll</HintPath>
</Reference>
- <Reference Include="SocketHttpListener.Portable">
- <HintPath>..\ThirdParty\emby\SocketHttpListener.Portable.dll</HintPath>
- </Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.Net" />
- <Reference Include="System.Runtime.Serialization" />
- <Reference Include="System.Security" />
<Reference Include="System.Xml" />
- <Reference Include="ServiceStack">
- <HintPath>..\ThirdParty\ServiceStack\ServiceStack.dll</HintPath>
- </Reference>
<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>
<Compile Include="..\SharedVersion.cs">
@@ -105,12 +74,9 @@
<Compile Include="Activity\ActivityRepository.cs" />
<Compile Include="Archiving\ZipClient.cs" />
<Compile Include="Collections\CollectionsDynamicFolder.cs" />
- <Compile Include="Configuration\ServerConfigurationManager.cs" />
<Compile Include="Devices\DeviceRepository.cs" />
<Compile Include="Devices\CameraUploadsFolder.cs" />
<Compile Include="EntryPoints\ExternalPortForwarding.cs" />
- <Compile Include="HttpServer\HttpListenerHost.cs" />
- <Compile Include="HttpServer\ServerFactory.cs" />
<Compile Include="IO\LibraryMonitor.cs" />
<Compile Include="IO\MemoryStreamProvider.cs" />
<Compile Include="LiveTv\TunerHosts\SatIp\ChannelScan.cs" />
@@ -143,10 +109,8 @@
<Compile Include="Persistence\SqliteFileOrganizationRepository.cs" />
<Compile Include="Notifications\SqliteNotificationsRepository.cs" />
<Compile Include="Persistence\TypeMapper.cs" />
- <Compile Include="Playlists\ManualPlaylistsFolder.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Security\AuthenticationRepository.cs" />
- <Compile Include="ServerApplicationPaths.cs" />
<Compile Include="Persistence\SqliteDisplayPreferencesRepository.cs" />
<Compile Include="Persistence\SqliteItemRepository.cs" />
<Compile Include="Persistence\SqliteUserDataRepository.cs" />
@@ -170,10 +134,6 @@
<Project>{7EEEB4BB-F3E8-48FC-B4C5-70F0FFF8329B}</Project>
<Name>MediaBrowser.Model</Name>
</ProjectReference>
- <ProjectReference Include="..\MediaBrowser.Providers\MediaBrowser.Providers.csproj">
- <Project>{442b5058-dcaf-4263-bb6a-f21e31120a1b}</Project>
- <Name>MediaBrowser.Providers</Name>
- </ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
@@ -348,9 +308,7 @@
<None Include="LiveTv\TunerHosts\SatIp\ini\satellite\3594.ini" />
<None Include="packages.config" />
</ItemGroup>
- <ItemGroup>
- <Folder Include="Serialization\" />
- </ItemGroup>
+ <ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- 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.
diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs
index 3577d1883..3dcd83da0 100644
--- a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs
+++ b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs
@@ -18,6 +18,7 @@ using System.Runtime.Serialization;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
+using Emby.Server.Implementations.Playlists;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.IO;
using MediaBrowser.Controller.Channels;
@@ -30,7 +31,6 @@ using MediaBrowser.Model.Extensions;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.LiveTv;
using MediaBrowser.Server.Implementations.Devices;
-using MediaBrowser.Server.Implementations.Playlists;
namespace MediaBrowser.Server.Implementations.Persistence
{
diff --git a/MediaBrowser.Server.Implementations/packages.config b/MediaBrowser.Server.Implementations/packages.config
index 16ac6faf3..c224c3d38 100644
--- a/MediaBrowser.Server.Implementations/packages.config
+++ b/MediaBrowser.Server.Implementations/packages.config
@@ -1,10 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="Emby.XmlTv" version="1.0.0.63" targetFramework="net46" />
<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="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> \ No newline at end of file
diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
index e5a17f8fc..b14378eb8 100644
--- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
+++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
@@ -50,9 +50,7 @@ using MediaBrowser.Providers.Manager;
using MediaBrowser.Providers.Subtitles;
using MediaBrowser.Server.Implementations;
using MediaBrowser.Server.Implementations.Activity;
-using MediaBrowser.Server.Implementations.Configuration;
using MediaBrowser.Server.Implementations.Devices;
-using MediaBrowser.Server.Implementations.HttpServer;
using MediaBrowser.Server.Implementations.IO;
using MediaBrowser.Server.Implementations.Notifications;
using MediaBrowser.Server.Implementations.Persistence;
@@ -72,6 +70,7 @@ using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
using System.Threading;
using System.Threading.Tasks;
using Emby.Common.Implementations;
@@ -133,8 +132,10 @@ using MediaBrowser.Model.Social;
using MediaBrowser.Model.Text;
using MediaBrowser.Model.Xml;
using MediaBrowser.Server.Implementations.Archiving;
+using MediaBrowser.Server.Startup.Common.Configuration;
using OpenSubtitlesHandler;
using ServiceStack;
+using SocketHttpListener.Primitives;
using StringExtensions = MediaBrowser.Controller.Extensions.StringExtensions;
namespace MediaBrowser.Server.Startup.Common
@@ -271,7 +272,7 @@ namespace MediaBrowser.Server.Startup.Common
ILogManager logManager,
StartupOptions options,
IFileSystem fileSystem,
- INativeApp nativeApp,
+ INativeApp nativeApp,
IPowerManagement powerManagement,
string releaseAssetFilename)
: base(applicationPaths, logManager, fileSystem)
@@ -613,7 +614,7 @@ namespace MediaBrowser.Server.Startup.Common
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");
RegisterSingleInstance(HttpServer, false);
progress.Report(10);
@@ -736,6 +737,32 @@ namespace MediaBrowser.Server.Startup.Common
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()
{
var maxConcurrentImageProcesses = Math.Max(Environment.ProcessorCount, 4);
@@ -969,6 +996,7 @@ namespace MediaBrowser.Server.Startup.Common
}
private string CertificatePath { get; set; }
+ private ICertificate Certificate { get; set; }
private IEnumerable<string> GetUrlPrefixes()
{
@@ -998,10 +1026,11 @@ namespace MediaBrowser.Server.Startup.Common
private void StartServer()
{
CertificatePath = GetCertificatePath(true);
+ Certificate = GetCertificate(CertificatePath);
try
{
- ServerManager.Start(GetUrlPrefixes(), CertificatePath);
+ ServerManager.Start(GetUrlPrefixes());
return;
}
catch (Exception ex)
@@ -1018,7 +1047,7 @@ namespace MediaBrowser.Server.Startup.Common
try
{
- ServerManager.Start(GetUrlPrefixes(), CertificatePath);
+ ServerManager.Start(GetUrlPrefixes());
}
catch (Exception ex)
{
@@ -1298,7 +1327,7 @@ namespace MediaBrowser.Server.Startup.Common
public bool SupportsHttps
{
- get { return !string.IsNullOrWhiteSpace(HttpServer.CertificatePath); }
+ get { return Certificate != null; }
}
public async Task<string> GetLocalApiUrl()
diff --git a/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs b/MediaBrowser.Server.Startup.Common/Configuration/ServerConfigurationManager.cs
index 4b6195192..756a8d0bf 100644
--- a/MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs
+++ b/MediaBrowser.Server.Startup.Common/Configuration/ServerConfigurationManager.cs
@@ -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.Events;
-using Emby.Common.Implementations.Configuration;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
@@ -10,16 +13,11 @@ using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Events;
+using MediaBrowser.Model.IO;
using MediaBrowser.Model.Logging;
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>
/// Class ServerConfigurationManager
diff --git a/MediaBrowser.Server.Startup.Common/HttpServerFactory.cs b/MediaBrowser.Server.Startup.Common/HttpServerFactory.cs
new file mode 100644
index 000000000..c0c376996
--- /dev/null
+++ b/MediaBrowser.Server.Startup.Common/HttpServerFactory.cs
@@ -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; }
+ }
+}
diff --git a/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj b/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj
index 7e01fd36d..7ac020cc4 100644
--- a/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj
+++ b/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj
@@ -49,14 +49,22 @@
<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.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+ <Reference Include="ServiceStack, Version=4.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<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 Include="SimpleInjector, Version=3.2.4.0, Culture=neutral, PublicKeyToken=984cb50dea722e99, processorArchitecture=MSIL">
<HintPath>..\packages\SimpleInjector.3.2.4\lib\net45\SimpleInjector.dll</HintPath>
<Private>True</Private>
</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.Configuration" />
<Reference Include="System.Core" />
@@ -73,10 +81,12 @@
<Compile Include="ApplicationHost.cs" />
<Compile Include="ApplicationPathHelper.cs" />
<Compile Include="Browser\BrowserLauncher.cs" />
+ <Compile Include="Configuration\ServerConfigurationManager.cs" />
<Compile Include="EntryPoints\StartupWizard.cs" />
<Compile Include="FFMpeg\FFMpegLoader.cs" />
<Compile Include="FFMpeg\FFMpegInstallInfo.cs" />
<Compile Include="FFMpeg\FFMpegInfo.cs" />
+ <Compile Include="HttpServerFactory.cs" />
<Compile Include="INativeApp.cs" />
<Compile Include="MbLinkShortcutHandler.cs" />
<Compile Include="Migrations\IVersionMigration.cs" />
@@ -103,6 +113,7 @@
<Compile Include="Security\X509Extension.cs" />
<Compile Include="Security\X509Extensions.cs" />
<Compile Include="Security\X520Attributes.cs" />
+ <Compile Include="ServerApplicationPaths.cs" />
<Compile Include="StartupOptions.cs" />
<Compile Include="SystemEvents.cs" />
<Compile Include="TextLocalizer.cs" />
diff --git a/MediaBrowser.Server.Implementations/ServerApplicationPaths.cs b/MediaBrowser.Server.Startup.Common/ServerApplicationPaths.cs
index c8dea9005..11de1c4ab 100644
--- a/MediaBrowser.Server.Implementations/ServerApplicationPaths.cs
+++ b/MediaBrowser.Server.Startup.Common/ServerApplicationPaths.cs
@@ -1,8 +1,8 @@
-using Emby.Common.Implementations;
+using System.IO;
+using Emby.Common.Implementations;
using MediaBrowser.Controller;
-using System.IO;
-namespace MediaBrowser.Server.Implementations
+namespace MediaBrowser.Server.Startup.Common
{
/// <summary>
/// Extends BaseApplicationPaths to add paths that are only applicable on the server
diff --git a/MediaBrowser.Server.Startup.Common/packages.config b/MediaBrowser.Server.Startup.Common/packages.config
index ea3d0e7f8..fa1cc928c 100644
--- a/MediaBrowser.Server.Startup.Common/packages.config
+++ b/MediaBrowser.Server.Startup.Common/packages.config
@@ -3,5 +3,6 @@
<package id="MediaBrowser.Naming" version="1.0.0.59" targetFramework="net46" />
<package id="Mono.Posix" version="4.0.0.0" targetFramework="net45" />
<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" />
</packages> \ No newline at end of file