diff --git a/src/Jackett.Common/Services/Interfaces/IServerService.cs b/src/Jackett.Common/Services/Interfaces/IServerService.cs index 9f28a9e4d..9b8bd529f 100644 --- a/src/Jackett.Common/Services/Interfaces/IServerService.cs +++ b/src/Jackett.Common/Services/Interfaces/IServerService.cs @@ -12,7 +12,9 @@ namespace Jackett.Common.Services.Interfaces void ReserveUrls(bool doInstall = true); Uri ConvertToProxyLink(Uri link, string serverUrl, string indexerId, string action = "dl", string file = "t"); string BasePath(); - string GetServerUrl(HttpRequestMessage Request); - List notices { get; } + string GetServerUrl(object Request); //TODO: Once Mono is removed, change type to HttpRequest + List notices { get; } + string GetBlackholeDirectory(); + string GetApiKey(); } } diff --git a/src/Jackett/Services/ServerService.cs b/src/Jackett/Services/ServerService.cs index 1b362126e..21a14fa05 100644 --- a/src/Jackett/Services/ServerService.cs +++ b/src/Jackett/Services/ServerService.cs @@ -335,30 +335,46 @@ namespace Jackett.Services } } - public string GetServerUrl(HttpRequestMessage Request) + public string GetServerUrl(Object obj) { - var scheme = Request.RequestUri.Scheme; - var port = Request.RequestUri.Port; + string serverUrl = ""; - // Check for protocol headers added by reverse proxys - // X-Forwarded-Proto: A de facto standard for identifying the originating protocol of an HTTP request - var X_Forwarded_Proto = Request.Headers.Where(x => x.Key == "X-Forwarded-Proto").Select(x => x.Value).FirstOrDefault(); - if (X_Forwarded_Proto != null) + if (obj is HttpRequestMessage request) { - scheme = X_Forwarded_Proto.First(); - } - // Front-End-Https: Non-standard header field used by Microsoft applications and load-balancers - else if (Request.Headers.Where(x => x.Key == "Front-End-Https" && x.Value.FirstOrDefault() == "on").Any()) - { - scheme = "https"; + var scheme = request.RequestUri.Scheme; + var port = request.RequestUri.Port; + + // Check for protocol headers added by reverse proxys + // X-Forwarded-Proto: A de facto standard for identifying the originating protocol of an HTTP request + var X_Forwarded_Proto = request.Headers.Where(x => x.Key == "X-Forwarded-Proto").Select(x => x.Value).FirstOrDefault(); + if (X_Forwarded_Proto != null) + { + scheme = X_Forwarded_Proto.First(); + } + // Front-End-Https: Non-standard header field used by Microsoft applications and load-balancers + else if (request.Headers.Where(x => x.Key == "Front-End-Https" && x.Value.FirstOrDefault() == "on").Any()) + { + scheme = "https"; + } + + // default to 443 if the Host header doesn't contain the port (needed for reverse proxy setups) + if (scheme == "https" && !request.RequestUri.Authority.Contains(":")) + port = 443; + + serverUrl = string.Format("{0}://{1}:{2}{3}/", scheme, request.RequestUri.Host, port, BasePath()); } - // default to 443 if the Host header doesn't contain the port (needed for reverse proxy setups) - if (scheme == "https" && !Request.RequestUri.Authority.Contains(":")) - port = 443; - - var serverUrl = string.Format("{0}://{1}:{2}{3}/", scheme, Request.RequestUri.Host, port, BasePath()); return serverUrl; } + + public string GetBlackholeDirectory() + { + return config.BlackholeDir; + } + + public string GetApiKey() + { + return config.APIKey; + } } }