aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/HttpServer
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Server.Implementations/HttpServer')
-rw-r--r--MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs13
-rw-r--r--MediaBrowser.Server.Implementations/HttpServer/NativeWebSocket.cs5
-rw-r--r--MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs12
-rw-r--r--MediaBrowser.Server.Implementations/HttpServer/ServerFactory.cs12
4 files changed, 26 insertions, 16 deletions
diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs
index 95877ec0c..98f895616 100644
--- a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs
+++ b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs
@@ -43,6 +43,8 @@ namespace MediaBrowser.Server.Implementations.HttpServer
private readonly ReaderWriterLockSlim _localEndpointLock = new ReaderWriterLockSlim();
+ private readonly bool _supportsNativeWebSocket;
+
/// <summary>
/// Gets the local end points.
/// </summary>
@@ -61,10 +63,17 @@ namespace MediaBrowser.Server.Implementations.HttpServer
}
}
- public HttpListenerHost(IApplicationHost applicationHost, ILogManager logManager, string serviceName, string handlerPath, string defaultRedirectPath, params Assembly[] assembliesWithServices)
+ public HttpListenerHost(IApplicationHost applicationHost,
+ ILogManager logManager,
+ string serviceName,
+ string handlerPath,
+ string defaultRedirectPath,
+ bool supportsNativeWebSocket,
+ params Assembly[] assembliesWithServices)
: base(serviceName, assembliesWithServices)
{
DefaultRedirectPath = defaultRedirectPath;
+ _supportsNativeWebSocket = supportsNativeWebSocket;
HandlerPath = handlerPath;
_logger = logManager.GetLogger("HttpServer");
@@ -195,7 +204,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
{
HostContext.Config.HandlerFactoryPath = ListenerRequest.GetHandlerPathIfAny(UrlPrefixes.First());
- _listener = NativeWebSocket.IsSupported
+ _listener = _supportsNativeWebSocket && NativeWebSocket.IsSupported
? _listener = new HttpListenerServer(_logger, OnRequestReceived)
//? _listener = new WebSocketSharpListener(_logger, OnRequestReceived)
: _listener = new WebSocketSharpListener(_logger, OnRequestReceived);
diff --git a/MediaBrowser.Server.Implementations/HttpServer/NativeWebSocket.cs b/MediaBrowser.Server.Implementations/HttpServer/NativeWebSocket.cs
index c7669fecb..8cc614fe5 100644
--- a/MediaBrowser.Server.Implementations/HttpServer/NativeWebSocket.cs
+++ b/MediaBrowser.Server.Implementations/HttpServer/NativeWebSocket.cs
@@ -219,11 +219,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer
{
get
{
-#if __MonoCS__
- return false;
-#else
-#endif
-
if (!_supportsNativeWebSocket.HasValue)
{
try
diff --git a/MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs b/MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs
index 4b699c018..4d2ee3f39 100644
--- a/MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs
+++ b/MediaBrowser.Server.Implementations/HttpServer/Security/AuthService.cs
@@ -1,4 +1,5 @@
-using MediaBrowser.Controller.Configuration;
+using System.Collections.Generic;
+using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.Session;
@@ -57,15 +58,14 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security
}
private void ValidateUser(IRequest req, bool allowLocal,
- string[] roles)
+ IEnumerable<string> roles)
{
- //This code is executed before the service
+ // This code is executed before the service
var auth = AuthorizationContext.GetAuthorizationInfo(req);
- if (!string.IsNullOrWhiteSpace(auth.Token)
- || _config.Configuration.SecureApps2.Contains(auth.Client ?? string.Empty, StringComparer.OrdinalIgnoreCase))
+ if (!allowLocal || !req.IsLocal)
{
- if (!allowLocal || !req.IsLocal)
+ if (!_config.Configuration.InsecureApps.Contains(auth.Client ?? string.Empty, StringComparer.OrdinalIgnoreCase))
{
SessionManager.ValidateSecurityToken(auth.Token);
}
diff --git a/MediaBrowser.Server.Implementations/HttpServer/ServerFactory.cs b/MediaBrowser.Server.Implementations/HttpServer/ServerFactory.cs
index c403c09b4..b48703a15 100644
--- a/MediaBrowser.Server.Implementations/HttpServer/ServerFactory.cs
+++ b/MediaBrowser.Server.Implementations/HttpServer/ServerFactory.cs
@@ -18,12 +18,18 @@ namespace MediaBrowser.Server.Implementations.HttpServer
/// <param name="serverName">Name of the server.</param>
/// <param name="handlerPath">The handler path.</param>
/// <param name="defaultRedirectpath">The default redirectpath.</param>
+ /// <param name="supportsNativeWebSocket">if set to <c>true</c> [supports native web socket].</param>
/// <returns>IHttpServer.</returns>
- public static IHttpServer CreateServer(IApplicationHost applicationHost, ILogManager logManager, string serverName, string handlerPath, string defaultRedirectpath)
+ public static IHttpServer CreateServer(IApplicationHost applicationHost,
+ ILogManager logManager,
+ string serverName,
+ string handlerPath,
+ string defaultRedirectpath,
+ bool supportsNativeWebSocket)
{
LogManager.LogFactory = new ServerLogFactory(logManager);
-
- return new HttpListenerHost(applicationHost, logManager, serverName, handlerPath, defaultRedirectpath);
+
+ return new HttpListenerHost(applicationHost, logManager, serverName, handlerPath, defaultRedirectpath, supportsNativeWebSocket);
}
}
}