From f02f3222085311b2a2cacab6642ad987a4176e65 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 6 Oct 2014 19:58:46 -0400 Subject: remove mono compiler directives --- .../HttpServer/HttpListenerHost.cs | 13 +++++++++++-- .../HttpServer/NativeWebSocket.cs | 5 ----- .../HttpServer/Security/AuthService.cs | 12 ++++++------ .../HttpServer/ServerFactory.cs | 12 +++++++++--- 4 files changed, 26 insertions(+), 16 deletions(-) (limited to 'MediaBrowser.Server.Implementations/HttpServer') 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; + /// /// Gets the local end points. /// @@ -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 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 /// Name of the server. /// The handler path. /// The default redirectpath. + /// if set to true [supports native web socket]. /// IHttpServer. - 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); } } } -- cgit v1.2.3