diff --git a/src/CurlSharp/CurlMulti.cs b/src/CurlSharp/CurlMulti.cs index 510b9f9a0..b49a2891d 100644 --- a/src/CurlSharp/CurlMulti.cs +++ b/src/CurlSharp/CurlMulti.cs @@ -295,7 +295,9 @@ namespace CurlSharp _multiInfo = null; throw new NotImplementedException("CurlMulti.InfoRead()"); #endif +#pragma warning disable CS0162 // Unreachable code detected when not compiling with the shim return _multiInfo; +#pragma warning restore CS0162 // Unreachable code detected when not compiling with the shim } } } \ No newline at end of file diff --git a/src/Jackett/CurlHelper.cs b/src/Jackett.Common/CurlHelper.cs similarity index 97% rename from src/Jackett/CurlHelper.cs rename to src/Jackett.Common/CurlHelper.cs index 49e12a695..88986f458 100644 --- a/src/Jackett/CurlHelper.cs +++ b/src/Jackett.Common/CurlHelper.cs @@ -10,6 +10,7 @@ using System.Net.Http.Headers; using Jackett.Utils; using System.Net; using System.Threading; +using Jacket.Common; namespace Jackett { @@ -138,7 +139,7 @@ namespace Jackett } } - if (Startup.DoSSLFix == true) + if (JackettStartup.DoSSLFix == true) { // http://stackoverflow.com/questions/31107851/how-to-fix-curl-35-cannot-communicate-securely-with-peer-no-common-encryptio // https://git.fedorahosted.org/cgit/mod_nss.git/plain/docs/mod_nss.html @@ -147,16 +148,16 @@ namespace Jackett easy.ForbidReuse = true; } - if (Startup.IgnoreSslErrors == true) + if (JackettStartup.IgnoreSslErrors == true) { easy.SetOpt(CurlOption.SslVerifyhost, false); easy.SetOpt(CurlOption.SslVerifyPeer, false); } - if (Engine.Server.Config.Proxy != null) + if (JackettStartup.ProxyConnection != null) { easy.SetOpt(CurlOption.HttpProxyTunnel, 1); - easy.SetOpt(CurlOption.Proxy, Engine.Server.Config.Proxy); + easy.SetOpt(CurlOption.Proxy, JackettStartup.ProxyConnection); } easy.Perform(); @@ -173,7 +174,7 @@ namespace Jackett var headerBytes = Combine(headerBuffers.ToArray()); var headerString = Encoding.UTF8.GetString(headerBytes); - if (Startup.ProxyConnection != null) + if (JackettStartup.ProxyConnection != null) { var firstcrlf = headerString.IndexOf("\r\n\r\n"); var secondcrlf = headerString.IndexOf("\r\n\r\n", firstcrlf + 1); diff --git a/src/Jackett/CurlSharp.dll.config b/src/Jackett.Common/CurlSharp.dll.config similarity index 100% rename from src/Jackett/CurlSharp.dll.config rename to src/Jackett.Common/CurlSharp.dll.config diff --git a/src/Jackett/ExceptionWithConfigData.cs b/src/Jackett.Common/ExceptionWithConfigData.cs similarity index 100% rename from src/Jackett/ExceptionWithConfigData.cs rename to src/Jackett.Common/ExceptionWithConfigData.cs diff --git a/src/Jackett.Common/Helpers/WebUtilityHelpers.cs b/src/Jackett.Common/Helpers/WebUtilityHelpers.cs new file mode 100644 index 000000000..8167a2d59 --- /dev/null +++ b/src/Jackett.Common/Helpers/WebUtilityHelpers.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Net; +using System.Text; + +namespace Jacket.Common.Helpers +{ + public static class WebUtilityHelpers + { + public static string UrlEncode(string searchString, Encoding encoding) + { + if (string.IsNullOrEmpty(searchString)) + { + return string.Empty; + } + + byte[] bytes = encoding.GetBytes(searchString); + return encoding.GetString(WebUtility.UrlEncodeToBytes(bytes, 0, bytes.Length)); + } + + public static string UrlDecode(string searchString, Encoding encoding) + { + if (string.IsNullOrEmpty(searchString)) + { + return string.Empty; + } + + var inputBytes = encoding.GetBytes(searchString); + return encoding.GetString(WebUtility.UrlDecodeToBytes(inputBytes, 0, inputBytes.Length)); + } + } +} diff --git a/src/Jackett/IndexerException.cs b/src/Jackett.Common/IndexerException.cs similarity index 94% rename from src/Jackett/IndexerException.cs rename to src/Jackett.Common/IndexerException.cs index fae662010..429a0c786 100644 --- a/src/Jackett/IndexerException.cs +++ b/src/Jackett.Common/IndexerException.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace Jackett { - class IndexerException : Exception + public class IndexerException : Exception { public IIndexer Indexer { get; protected set; } diff --git a/src/Jackett/Indexers/7tor.cs b/src/Jackett.Common/Indexers/7tor.cs similarity index 99% rename from src/Jackett/Indexers/7tor.cs rename to src/Jackett.Common/Indexers/7tor.cs index 9d2795f8e..dc2266844 100644 --- a/src/Jackett/Indexers/7tor.cs +++ b/src/Jackett.Common/Indexers/7tor.cs @@ -25,7 +25,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public SevenTor(IIndexerConfigurationService configService, IWebClient wc, Logger l, IProtectionService ps) + public SevenTor(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps) : base(name: "7tor", description: "7Tor is a RUSSIAN Semi-Private site for MOVIES / TV / GENERAL", link: "https://7tor.org/", diff --git a/src/Jackett/Indexers/Abnormal.cs b/src/Jackett.Common/Indexers/Abnormal.cs similarity index 99% rename from src/Jackett/Indexers/Abnormal.cs rename to src/Jackett.Common/Indexers/Abnormal.cs index e0aee3a8c..6c5a0ffff 100644 --- a/src/Jackett/Indexers/Abnormal.cs +++ b/src/Jackett.Common/Indexers/Abnormal.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Collections.Specialized; using System.IO; using System.Linq; +using System.Net; using System.Reflection; using System.Text; using System.Text.RegularExpressions; @@ -44,7 +45,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public Abnormal(IIndexerConfigurationService configService, IWebClient w, Logger l, IProtectionService ps) + public Abnormal(IIndexerConfigurationService configService, Utils.Clients.WebClient w, Logger l, IProtectionService ps) : base( name: "Abnormal", description: "General French Private Tracker", @@ -411,12 +412,12 @@ namespace Jackett.Indexers if (categoriesList.Last() == category) { // Adding previous categories to URL with latest category - parameters.Add(Uri.EscapeDataString("cat[]"), HttpUtility.UrlEncode(category) + categories); + parameters.Add(Uri.EscapeDataString("cat[]"), WebUtility.UrlEncode(category) + categories); } else { // Build categories parameter - categories += "&" + Uri.EscapeDataString("cat[]") + "=" + HttpUtility.UrlEncode(category); + categories += "&" + Uri.EscapeDataString("cat[]") + "=" + WebUtility.UrlEncode(category); } } @@ -424,11 +425,11 @@ namespace Jackett.Indexers if (!string.IsNullOrWhiteSpace(term)) { // Add search term - parameters.Add("search", HttpUtility.UrlEncode(term)); + parameters.Add("search", WebUtility.UrlEncode(term)); } else { - parameters.Add("search", HttpUtility.UrlEncode("%")); + parameters.Add("search", WebUtility.UrlEncode("%")); // Showing all torrents (just for output function) term = "all"; } @@ -733,7 +734,7 @@ namespace Jackett.Indexers goto case "debug"; case "debug": // Only if Debug Level Enabled on Jackett - if (Engine.Logger.IsDebugEnabled) + if (logger.IsDebugEnabled) { logger.Debug(message); } diff --git a/src/Jackett/Indexers/Abstract/AvistazTracker.cs b/src/Jackett.Common/Indexers/Abstract/AvistazTracker.cs similarity index 96% rename from src/Jackett/Indexers/Abstract/AvistazTracker.cs rename to src/Jackett.Common/Indexers/Abstract/AvistazTracker.cs index 7d4777e7f..31dc6811f 100644 --- a/src/Jackett/Indexers/Abstract/AvistazTracker.cs +++ b/src/Jackett.Common/Indexers/Abstract/AvistazTracker.cs @@ -13,6 +13,7 @@ using Jackett.Utils.Clients; using System.Text.RegularExpressions; using Jackett.Models.IndexerConfig; using Jackett.Services.Interfaces; +using System.Net; namespace Jackett.Indexers { @@ -27,7 +28,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public AvistazTracker(IIndexerConfigurationService configService, IWebClient webClient, Logger logger, IProtectionService protectionService, string name, string desc, string link) + public AvistazTracker(IIndexerConfigurationService configService, Utils.Clients.WebClient webClient, Logger logger, IProtectionService protectionService, string name, string desc, string link) : base(name: name, description: desc, link: link, @@ -38,7 +39,7 @@ namespace Jackett.Indexers p: protectionService, configData: new ConfigurationDataBasicLogin()) { - Encoding = Encoding.GetEncoding("UTF-8"); + Encoding = Encoding.UTF8; Language = "en-us"; AddCategoryMapping(1, TorznabCatType.Movies); @@ -85,7 +86,7 @@ namespace Jackett.Indexers } - var episodeSearchUrl = string.Format(SearchUrl, category, HttpUtility.UrlEncode(query.GetQueryString())); + var episodeSearchUrl = string.Format(SearchUrl, category, WebUtility.UrlEncode(query.GetQueryString())); var response = await RequestStringWithCookiesAndRetry(episodeSearchUrl); if (response.IsRedirect) diff --git a/src/Jackett/Indexers/Abstract/CouchPotatoTracker.cs b/src/Jackett.Common/Indexers/Abstract/CouchPotatoTracker.cs similarity index 96% rename from src/Jackett/Indexers/Abstract/CouchPotatoTracker.cs rename to src/Jackett.Common/Indexers/Abstract/CouchPotatoTracker.cs index 2a211f129..ec36c60a3 100644 --- a/src/Jackett/Indexers/Abstract/CouchPotatoTracker.cs +++ b/src/Jackett.Common/Indexers/Abstract/CouchPotatoTracker.cs @@ -24,7 +24,7 @@ namespace Jackett.Indexers.Abstract set { base.configData = value; } } - public CouchPotatoTracker(IIndexerConfigurationService configService, IWebClient client, Logger logger, IProtectionService p, ConfigurationDataUserPasskey configData, string name, string description, string link, string endpoint) + public CouchPotatoTracker(IIndexerConfigurationService configService, WebClient client, Logger logger, IProtectionService p, ConfigurationDataUserPasskey configData, string name, string description, string link, string endpoint) : base(name: name, description: description, link: link, diff --git a/src/Jackett/Indexers/Abstract/GazelleTracker.cs b/src/Jackett.Common/Indexers/Abstract/GazelleTracker.cs similarity index 95% rename from src/Jackett/Indexers/Abstract/GazelleTracker.cs rename to src/Jackett.Common/Indexers/Abstract/GazelleTracker.cs index 4eb05141f..684c4b851 100644 --- a/src/Jackett/Indexers/Abstract/GazelleTracker.cs +++ b/src/Jackett.Common/Indexers/Abstract/GazelleTracker.cs @@ -14,6 +14,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Web; +using System.Net; namespace Jackett.Indexers.Abstract { @@ -30,7 +31,7 @@ namespace Jackett.Indexers.Abstract set { base.configData = value; } } - public GazelleTracker(IIndexerConfigurationService configService, IWebClient webClient, Logger logger, IProtectionService protectionService, string name, string desc, string link) + public GazelleTracker(IIndexerConfigurationService configService, Utils.Clients.WebClient webClient, Logger logger, IProtectionService protectionService, string name, string desc, string link) : base(name: name, description: desc, link: link, @@ -41,7 +42,7 @@ namespace Jackett.Indexers.Abstract p: protectionService, configData: new ConfigurationDataBasicLogin()) { - Encoding = Encoding.GetEncoding("UTF-8"); + Encoding = Encoding.UTF8; } public override async Task ApplyConfiguration(JToken configJson) @@ -120,8 +121,8 @@ namespace Jackett.Indexers.Abstract foreach (JObject r in json["response"]["results"]) { var groupTime = DateTimeUtil.UnixTimestampToDateTime(long.Parse((string)r["groupTime"])); - var groupName = HttpUtility.HtmlDecode((string)r["groupName"]); - var artist = HttpUtility.HtmlDecode((string)r["artist"]); + var groupName = WebUtility.HtmlDecode((string)r["groupName"]); + var artist = WebUtility.HtmlDecode((string)r["artist"]); var cover = (string)r["cover"]; var tags = r["tags"].ToList(); var groupYear = (string)r["groupYear"]; @@ -192,7 +193,7 @@ namespace Jackett.Indexers.Abstract var format = (string)torrent["format"]; if (!string.IsNullOrEmpty(format)) - flags.Add(HttpUtility.HtmlDecode(format)); + flags.Add(WebUtility.HtmlDecode(format)); var encoding = (string)torrent["encoding"]; if (!string.IsNullOrEmpty(encoding)) @@ -214,7 +215,7 @@ namespace Jackett.Indexers.Abstract if (torrent["remastered"] != null && (bool)torrent["remastered"]) { var remasterYear = (string)torrent["remasterYear"]; - var remasterTitle = HttpUtility.HtmlDecode((string)torrent["remasterTitle"]); + var remasterTitle = WebUtility.HtmlDecode((string)torrent["remasterTitle"]); flags.Add(remasterYear + (!string.IsNullOrEmpty(remasterTitle) ? " " + remasterTitle : "")); } diff --git a/src/Jackett/Indexers/AlphaRatio.cs b/src/Jackett.Common/Indexers/AlphaRatio.cs similarity index 96% rename from src/Jackett/Indexers/AlphaRatio.cs rename to src/Jackett.Common/Indexers/AlphaRatio.cs index 1cb928dba..618aea7a4 100644 --- a/src/Jackett/Indexers/AlphaRatio.cs +++ b/src/Jackett.Common/Indexers/AlphaRatio.cs @@ -8,7 +8,7 @@ namespace Jackett.Indexers { public class AlphaRatio : GazelleTracker { - public AlphaRatio(IIndexerConfigurationService configService, IWebClient webClient, Logger logger, IProtectionService protectionService) + public AlphaRatio(IIndexerConfigurationService configService, WebClient webClient, Logger logger, IProtectionService protectionService) : base(name: "AlphaRatio", desc: "AlphaRatio (AR) is a Private Torrent Tracker for 0DAY / GENERAL", link: "https://alpharatio.cc/", diff --git a/src/Jackett/Indexers/Andraste.cs b/src/Jackett.Common/Indexers/Andraste.cs similarity index 99% rename from src/Jackett/Indexers/Andraste.cs rename to src/Jackett.Common/Indexers/Andraste.cs index 2ba71e83f..a2c9c326c 100644 --- a/src/Jackett/Indexers/Andraste.cs +++ b/src/Jackett.Common/Indexers/Andraste.cs @@ -27,7 +27,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public Andraste(IIndexerConfigurationService configService, IWebClient wc, Logger l, IProtectionService ps) + public Andraste(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps) : base(name: "Andraste", description: "A German general tracker.", link: "https://andraste.io/", diff --git a/src/Jackett/Indexers/AnimeBytes.cs b/src/Jackett.Common/Indexers/AnimeBytes.cs similarity index 99% rename from src/Jackett/Indexers/AnimeBytes.cs rename to src/Jackett.Common/Indexers/AnimeBytes.cs index 44098f2d7..8c4dd18df 100644 --- a/src/Jackett/Indexers/AnimeBytes.cs +++ b/src/Jackett.Common/Indexers/AnimeBytes.cs @@ -39,7 +39,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public AnimeBytes(IIndexerConfigurationService configService, IWebClient client, Logger l, IProtectionService ps) + public AnimeBytes(IIndexerConfigurationService configService, Utils.Clients.WebClient client, Logger l, IProtectionService ps) : base(name: "AnimeBytes", link: "https://animebytes.tv/", description: "Powered by Tentacles", @@ -58,7 +58,7 @@ namespace Jackett.Indexers p: ps, configData: new ConfigurationDataAnimeBytes()) { - Encoding = Encoding.GetEncoding("UTF-8"); + Encoding = Encoding.UTF8; Language = "en-us"; Type = "private"; @@ -165,7 +165,7 @@ namespace Jackett.Indexers private async Task> GetResults(TorznabQuery query, SearchType searchType, string searchTerm) { - var cleanSearchTerm = HttpUtility.UrlEncode(searchTerm); + var cleanSearchTerm = WebUtility.UrlEncode(searchTerm); // The result list var releases = new List(); diff --git a/src/Jackett/Indexers/AnimeTorrents.cs b/src/Jackett.Common/Indexers/AnimeTorrents.cs similarity index 98% rename from src/Jackett/Indexers/AnimeTorrents.cs rename to src/Jackett.Common/Indexers/AnimeTorrents.cs index b40c082cb..8047382b9 100644 --- a/src/Jackett/Indexers/AnimeTorrents.cs +++ b/src/Jackett.Common/Indexers/AnimeTorrents.cs @@ -28,7 +28,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public AnimeTorrents(IIndexerConfigurationService configService, IWebClient c, Logger l, IProtectionService ps) + public AnimeTorrents(IIndexerConfigurationService configService, WebClient c, Logger l, IProtectionService ps) : base(name: "AnimeTorrents", description: "Definitive source for anime and manga", link: "https://animetorrents.me/", @@ -39,7 +39,7 @@ namespace Jackett.Indexers p: ps, configData: new ConfigurationDataBasicLogin()) { - Encoding = Encoding.GetEncoding("UTF-8"); + Encoding = Encoding.UTF8; Language = "en-us"; Type = "private"; diff --git a/src/Jackett/Indexers/Avistaz.cs b/src/Jackett.Common/Indexers/Avistaz.cs similarity index 88% rename from src/Jackett/Indexers/Avistaz.cs rename to src/Jackett.Common/Indexers/Avistaz.cs index 80106da3d..c87c078ba 100644 --- a/src/Jackett/Indexers/Avistaz.cs +++ b/src/Jackett.Common/Indexers/Avistaz.cs @@ -6,7 +6,7 @@ namespace Jackett.Indexers { public class Avistaz : AvistazTracker { - public Avistaz(IIndexerConfigurationService configService, IWebClient webClient, Logger logger, IProtectionService protectionService) + public Avistaz(IIndexerConfigurationService configService, WebClient webClient, Logger logger, IProtectionService protectionService) : base(name: "Avistaz", desc: "Aka AsiaTorrents", link: "https://avistaz.to/", diff --git a/src/Jackett/Indexers/BB.cs b/src/Jackett.Common/Indexers/BB.cs similarity index 98% rename from src/Jackett/Indexers/BB.cs rename to src/Jackett.Common/Indexers/BB.cs index 49007bf9f..7de771d56 100644 --- a/src/Jackett/Indexers/BB.cs +++ b/src/Jackett.Common/Indexers/BB.cs @@ -31,7 +31,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public BB(IIndexerConfigurationService configService, IWebClient w, Logger l, IProtectionService ps) + public BB(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps) : base(name: "bB", description: "BaconBits (bB) is a Private Torrent Tracker for 0DAY / GENERAL", link: StringUtil.FromBase64("aHR0cHM6Ly9iYWNvbmJpdHMub3JnLw=="), @@ -42,7 +42,7 @@ namespace Jackett.Indexers p: ps, configData: new ConfigurationDataBasicLogin()) { - Encoding = Encoding.GetEncoding("UTF-8"); + Encoding = Encoding.UTF8; Language = "en-us"; Type = "private"; diff --git a/src/Jackett/Indexers/BJShare.cs b/src/Jackett.Common/Indexers/BJShare.cs similarity index 99% rename from src/Jackett/Indexers/BJShare.cs rename to src/Jackett.Common/Indexers/BJShare.cs index 6b042dc81..68d072799 100644 --- a/src/Jackett/Indexers/BJShare.cs +++ b/src/Jackett.Common/Indexers/BJShare.cs @@ -29,7 +29,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public BJShare(IIndexerConfigurationService configService, IWebClient wc, Logger l, IProtectionService ps) + public BJShare(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps) : base(name: "BJ-Share", description: "A brazilian tracker.", link: "https://bj-share.me/", @@ -40,7 +40,7 @@ namespace Jackett.Indexers p: ps, configData: new ConfigurationDataBasicLoginWithRSSAndDisplay()) { - Encoding = Encoding.GetEncoding("UTF-8"); +Encoding = Encoding.UTF8; Language = "pt-br"; Type = "private"; diff --git a/src/Jackett/Indexers/BakaBT.cs b/src/Jackett.Common/Indexers/BakaBT.cs similarity index 97% rename from src/Jackett/Indexers/BakaBT.cs rename to src/Jackett.Common/Indexers/BakaBT.cs index 2a546c2a1..2b028b419 100644 --- a/src/Jackett/Indexers/BakaBT.cs +++ b/src/Jackett.Common/Indexers/BakaBT.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Globalization; +using System.Net; using System.Text; using System.Threading.Tasks; using System.Web; @@ -26,7 +27,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public BakaBT(IIndexerConfigurationService configService, IWebClient wc, Logger l, IProtectionService ps) + public BakaBT(IIndexerConfigurationService configService, Utils.Clients.WebClient wc, Logger l, IProtectionService ps) : base(name: "BakaBT", description: "Anime Comunity", link: "https://bakabt.me/", @@ -83,7 +84,7 @@ namespace Jackett.Indexers var releases = new List(); var searchString = query.SanitizedSearchTerm; - var episodeSearchUrl = SearchUrl + HttpUtility.UrlEncode(searchString); + var episodeSearchUrl = SearchUrl + WebUtility.UrlEncode(searchString); var response = await RequestStringWithCookiesAndRetry(episodeSearchUrl); try diff --git a/src/Jackett/Indexers/BaseIndexer.cs b/src/Jackett.Common/Indexers/BaseIndexer.cs similarity index 98% rename from src/Jackett/Indexers/BaseIndexer.cs rename to src/Jackett.Common/Indexers/BaseIndexer.cs index 0df50cf2c..d096f6530 100644 --- a/src/Jackett/Indexers/BaseIndexer.cs +++ b/src/Jackett.Common/Indexers/BaseIndexer.cs @@ -260,7 +260,7 @@ namespace Jackett.Indexers public abstract class BaseWebIndexer : BaseIndexer, IWebIndexer { - protected BaseWebIndexer(string name, string link, string description, IIndexerConfigurationService configService, IWebClient client, Logger logger, ConfigurationData configData, IProtectionService p, TorznabCapabilities caps = null, string downloadBase = null) + protected BaseWebIndexer(string name, string link, string description, IIndexerConfigurationService configService, WebClient client, Logger logger, ConfigurationData configData, IProtectionService p, TorznabCapabilities caps = null, string downloadBase = null) : base(name, link, description, configService, logger, configData, p) { this.webclient = client; @@ -272,7 +272,7 @@ namespace Jackett.Indexers } // minimal constructor used by e.g. cardigann generic indexer - protected BaseWebIndexer(IIndexerConfigurationService configService, IWebClient client, Logger logger, IProtectionService p) + protected BaseWebIndexer(IIndexerConfigurationService configService, WebClient client, Logger logger, IProtectionService p) : base("", "/", "", configService, logger, null, p) { this.webclient = client; @@ -739,13 +739,13 @@ namespace Jackett.Indexers public Encoding Encoding { get; protected set; } private List categoryMapping = new List(); - protected IWebClient webclient; + protected WebClient webclient; protected readonly string downloadUrlBase = ""; } public abstract class BaseCachingWebIndexer : BaseWebIndexer { - protected BaseCachingWebIndexer(string name, string link, string description, IIndexerConfigurationService configService, IWebClient client, Logger logger, ConfigurationData configData, IProtectionService p, TorznabCapabilities caps = null, string downloadBase = null) + protected BaseCachingWebIndexer(string name, string link, string description, IIndexerConfigurationService configService, WebClient client, Logger logger, ConfigurationData configData, IProtectionService p, TorznabCapabilities caps = null, string downloadBase = null) : base(name, link, description, configService, client, logger, configData, p, caps, downloadBase) { } diff --git a/src/Jackett/Indexers/BeyondHD.cs b/src/Jackett.Common/Indexers/BeyondHD.cs similarity index 98% rename from src/Jackett/Indexers/BeyondHD.cs rename to src/Jackett.Common/Indexers/BeyondHD.cs index d2a2cd856..af201ae5f 100644 --- a/src/Jackett/Indexers/BeyondHD.cs +++ b/src/Jackett.Common/Indexers/BeyondHD.cs @@ -26,7 +26,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public BeyondHD(IIndexerConfigurationService configService, IWebClient w, Logger l, IProtectionService ps) + public BeyondHD(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps) : base(name: "BeyondHD", description: "Without BeyondHD, your HDTV is just a TV", link: "https://beyond-hd.me/", @@ -37,7 +37,7 @@ namespace Jackett.Indexers p: ps, configData: new ConfigurationDataLoginLink()) { - Encoding = Encoding.GetEncoding("UTF-8"); + Encoding = Encoding.UTF8; Language = "en-us"; Type = "private"; diff --git a/src/Jackett/Indexers/BitCityReloaded.cs b/src/Jackett.Common/Indexers/BitCityReloaded.cs similarity index 99% rename from src/Jackett/Indexers/BitCityReloaded.cs rename to src/Jackett.Common/Indexers/BitCityReloaded.cs index 63145bee3..84d38cfa9 100644 --- a/src/Jackett/Indexers/BitCityReloaded.cs +++ b/src/Jackett.Common/Indexers/BitCityReloaded.cs @@ -27,7 +27,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public BitCityReloaded(IIndexerConfigurationService configService, IWebClient wc, Logger l, IProtectionService ps) + public BitCityReloaded(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps) : base(name: "Bit-City Reloaded", description: "A German general tracker.", link: "https://bc-reloaded.net/", diff --git a/src/Jackett/Indexers/BitHdtv.cs b/src/Jackett.Common/Indexers/BitHdtv.cs similarity index 99% rename from src/Jackett/Indexers/BitHdtv.cs rename to src/Jackett.Common/Indexers/BitHdtv.cs index bb6c72966..431f4ab23 100644 --- a/src/Jackett/Indexers/BitHdtv.cs +++ b/src/Jackett.Common/Indexers/BitHdtv.cs @@ -29,7 +29,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public BitHdtv(IIndexerConfigurationService configService, IWebClient w, Logger l, IProtectionService ps) + public BitHdtv(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps) : base(name: "BIT-HDTV", description: "Home of high definition invites", link: "https://www.bit-hdtv.com/", diff --git a/src/Jackett/Indexers/BitMeTV.cs b/src/Jackett.Common/Indexers/BitMeTV.cs similarity index 97% rename from src/Jackett/Indexers/BitMeTV.cs rename to src/Jackett.Common/Indexers/BitMeTV.cs index 8512bd105..e20a5ca8d 100644 --- a/src/Jackett/Indexers/BitMeTV.cs +++ b/src/Jackett.Common/Indexers/BitMeTV.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; +using System.Net; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; @@ -32,7 +33,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public BitMeTV(IIndexerConfigurationService configService, IWebClient c, Logger l, IProtectionService ps) + public BitMeTV(IIndexerConfigurationService configService, Utils.Clients.WebClient c, Logger l, IProtectionService ps) : base(name: "BitMeTV", description: "TV Episode specialty tracker", link: "http://www.bitmetv.org/", @@ -89,7 +90,7 @@ namespace Jackett.Indexers protected override async Task> PerformQuery(TorznabQuery query) { var releases = new List(); - var episodeSearchUrl = string.Format("{0}?search={1}&cat=0&incldead=1", SearchUrl, HttpUtility.UrlEncode(query.GetQueryString())); + var episodeSearchUrl = string.Format("{0}?search={1}&cat=0&incldead=1", SearchUrl, WebUtility.UrlEncode(query.GetQueryString())); var results = await RequestStringWithCookiesAndRetry(episodeSearchUrl); try { diff --git a/src/Jackett/Indexers/BitSoup.cs b/src/Jackett.Common/Indexers/BitSoup.cs similarity index 99% rename from src/Jackett/Indexers/BitSoup.cs rename to src/Jackett.Common/Indexers/BitSoup.cs index 0400d9e20..bedec85c6 100644 --- a/src/Jackett/Indexers/BitSoup.cs +++ b/src/Jackett.Common/Indexers/BitSoup.cs @@ -29,7 +29,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public BitSoup(IIndexerConfigurationService configService, IWebClient wc, Logger l, IProtectionService ps) + public BitSoup(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps) : base(name: "BitSoup", description: "SoupieBits", link: "https://www.bitsoup.me/", diff --git a/src/Jackett/Indexers/BroadcastTheNet.cs b/src/Jackett.Common/Indexers/BroadcastTheNet.cs similarity index 99% rename from src/Jackett/Indexers/BroadcastTheNet.cs rename to src/Jackett.Common/Indexers/BroadcastTheNet.cs index 98b6c73be..199c0e85e 100644 --- a/src/Jackett/Indexers/BroadcastTheNet.cs +++ b/src/Jackett.Common/Indexers/BroadcastTheNet.cs @@ -25,7 +25,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public BroadcastTheNet(IIndexerConfigurationService configService, IWebClient wc, Logger l, IProtectionService ps) + public BroadcastTheNet(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps) : base(name: "BroadcastTheNet", description: "Broadcasthe.net (BTN) is an invite-only torrent tracker focused on TV shows", link: "https://broadcasthe.net/", diff --git a/src/Jackett/Indexers/BrokenStones.cs b/src/Jackett.Common/Indexers/BrokenStones.cs similarity index 94% rename from src/Jackett/Indexers/BrokenStones.cs rename to src/Jackett.Common/Indexers/BrokenStones.cs index 1dc07b80e..8b8cab9f4 100644 --- a/src/Jackett/Indexers/BrokenStones.cs +++ b/src/Jackett.Common/Indexers/BrokenStones.cs @@ -8,7 +8,7 @@ namespace Jackett.Indexers { public class BrokenStones : GazelleTracker { - public BrokenStones(IIndexerConfigurationService configService, IWebClient webClient, Logger logger, IProtectionService protectionService) + public BrokenStones(IIndexerConfigurationService configService, WebClient webClient, Logger logger, IProtectionService protectionService) : base(name: "BrokenStones", desc: "Broken Stones is a Private site for MacOS and iOS APPS / GAMES", link: "https://brokenstones.club/", diff --git a/src/Jackett/Indexers/CardigannIndexer.cs b/src/Jackett.Common/Indexers/CardigannIndexer.cs similarity index 99% rename from src/Jackett/Indexers/CardigannIndexer.cs rename to src/Jackett.Common/Indexers/CardigannIndexer.cs index 52a1344b7..cf013b5b5 100644 --- a/src/Jackett/Indexers/CardigannIndexer.cs +++ b/src/Jackett.Common/Indexers/CardigannIndexer.cs @@ -17,6 +17,9 @@ using System.Web; using AngleSharp.Dom; using AngleSharp.Dom.Html; using System.Linq; +using System.Net; +using Microsoft.AspNetCore.WebUtilities; +using Jacket.Common.Helpers; namespace Jackett.Indexers { @@ -36,7 +39,7 @@ namespace Jackett.Indexers protected readonly string[] OptionalFileds = new string[] { "imdb", "rageid", "tvdbid", "banner" }; - public CardigannIndexer(IIndexerConfigurationService configService, IWebClient wc, Logger l, IProtectionService ps, IndexerDefinition Definition) + public CardigannIndexer(IIndexerConfigurationService configService, Utils.Clients.WebClient wc, Logger l, IProtectionService ps, IndexerDefinition Definition) : base(configService: configService, client: wc, logger: l, @@ -827,10 +830,10 @@ namespace Jackett.Indexers Data = Data.ToUpper(); break; case "urldecode": - Data = HttpUtility.UrlDecode(Data, Encoding); + Data = WebUtilityHelpers.UrlDecode(Data, Encoding); break; case "urlencode": - Data = HttpUtility.UrlEncode(Data, Encoding); + Data = WebUtilityHelpers.UrlEncode(Data, Encoding); break; case "timeago": case "reltime": @@ -1036,7 +1039,7 @@ namespace Jackett.Indexers // build search URL // HttpUtility.UrlPathEncode seems to only encode spaces, we use UrlEncode and replace + with %20 as a workaround - var searchUrl = resolvePath(applyGoTemplateText(SearchPath.Path, variables, HttpUtility.UrlEncode).Replace("+", "%20")).AbsoluteUri; + var searchUrl = resolvePath(applyGoTemplateText(SearchPath.Path, variables, WebUtility.UrlEncode).Replace("+", "%20")).AbsoluteUri; var queryCollection = new List>(); RequestType method = RequestType.GET; @@ -1058,7 +1061,7 @@ namespace Jackett.Indexers { if (Input.Key == "$raw") { - var rawStr = applyGoTemplateText(Input.Value, variables, HttpUtility.UrlEncode); + var rawStr = applyGoTemplateText(Input.Value, variables, WebUtility.UrlEncode); foreach (string part in rawStr.Split('&')) { var parts = part.Split(new char[] { '=' }, 2); @@ -1467,10 +1470,11 @@ namespace Jackett.Indexers variables[prefix + ".Port"] = uri.Port.ToString(); variables[prefix + ".PathAndQuery"] = uri.PathAndQuery; variables[prefix + ".Query"] = uri.Query; - var queryString = HttpUtility.ParseQueryString(uri.Query); + var queryString = QueryHelpers.ParseQuery(uri.Query); foreach (string key in queryString.Keys) { - variables[prefix + ".Query." + key] = queryString.Get(key); + //If we have supplied the same query string multiple time, just take the first. + variables[prefix + ".Query." + key] = queryString[key].First(); } return variables; } diff --git a/src/Jackett/Indexers/CinemaZ.cs b/src/Jackett.Common/Indexers/CinemaZ.cs similarity index 88% rename from src/Jackett/Indexers/CinemaZ.cs rename to src/Jackett.Common/Indexers/CinemaZ.cs index 7989d0069..0053a2926 100644 --- a/src/Jackett/Indexers/CinemaZ.cs +++ b/src/Jackett.Common/Indexers/CinemaZ.cs @@ -6,7 +6,7 @@ namespace Jackett.Indexers { public class CinemaZ : AvistazTracker { - public CinemaZ(IIndexerConfigurationService configService, IWebClient webClient, Logger logger, IProtectionService protectionService) + public CinemaZ(IIndexerConfigurationService configService, WebClient webClient, Logger logger, IProtectionService protectionService) : base(name: "CinemaZ", desc: "Part of the Avistaz network.", link: "https://cinemaz.to/", diff --git a/src/Jackett/Indexers/DanishBits.cs b/src/Jackett.Common/Indexers/DanishBits.cs similarity index 95% rename from src/Jackett/Indexers/DanishBits.cs rename to src/Jackett.Common/Indexers/DanishBits.cs index ccea129d3..be9d671ab 100644 --- a/src/Jackett/Indexers/DanishBits.cs +++ b/src/Jackett.Common/Indexers/DanishBits.cs @@ -19,7 +19,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public DanishBits(IIndexerConfigurationService configService, IWebClient c, Logger l, IProtectionService ps) + public DanishBits(IIndexerConfigurationService configService, WebClient c, Logger l, IProtectionService ps) : base(name: "DanishBits", description: "A danish closed torrent tracker", link: "https://danishbits.org/", @@ -31,7 +31,7 @@ namespace Jackett.Indexers configData: new ConfigurationDataUserPasskey("Note about Passkey: This is not your login Password. Find the Passkey by logging into DanishBits with your Browser, and under your account page you'll see your passkey under the 'Personal' section on the left side.") ) { - Encoding = Encoding.GetEncoding("UTF-8"); + Encoding = Encoding.UTF8; Language = "da-dk"; Type = "private"; diff --git a/src/Jackett/Indexers/Demonoid.cs b/src/Jackett.Common/Indexers/Demonoid.cs similarity index 97% rename from src/Jackett/Indexers/Demonoid.cs rename to src/Jackett.Common/Indexers/Demonoid.cs index 0f5ff5bd0..2e75a0c84 100644 --- a/src/Jackett/Indexers/Demonoid.cs +++ b/src/Jackett.Common/Indexers/Demonoid.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; +using System.Net; using System.Text; using System.Threading.Tasks; using System.Web; @@ -11,6 +12,7 @@ using Jackett.Models.IndexerConfig; using Jackett.Services.Interfaces; using Jackett.Utils; using Jackett.Utils.Clients; +using Microsoft.AspNetCore.WebUtilities; using Newtonsoft.Json.Linq; using NLog; @@ -27,7 +29,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public Demonoid(IIndexerConfigurationService configService, IWebClient wc, Logger l, IProtectionService ps) + public Demonoid(IIndexerConfigurationService configService, Utils.Clients.WebClient wc, Logger l, IProtectionService ps) : base(name: "Demonoid", description: "Demonoid is a Private torrent tracker for 0DAY / TV / MOVIES / GENERAL", link: "https://www.demonoid.pw/", @@ -38,7 +40,7 @@ namespace Jackett.Indexers p: ps, configData: new ConfigurationDataRecaptchaLogin()) { - Encoding = Encoding.GetEncoding("UTF-8"); + Encoding = Encoding.UTF8; Language = "en-us"; Type = "private"; @@ -132,7 +134,7 @@ namespace Jackett.Indexers var releases = new List(); var trackerCats = MapTorznabCapsToTrackers(query); var cat = (trackerCats.Count == 1 ? trackerCats.ElementAt(0) : "0"); - var episodeSearchUrl = string.Format(SearchUrl, cat, HttpUtility.UrlEncode(query.GetQueryString())); + var episodeSearchUrl = string.Format(SearchUrl, cat, WebUtility.UrlEncode(query.GetQueryString())); var results = await RequestStringWithCookiesAndRetry(episodeSearchUrl); if (results.Content.Contains("No torrents found")) @@ -177,7 +179,7 @@ namespace Jackett.Indexers release.PublishDate = lastDateTime; var catUrl = rowA.ChildElements.ElementAt(0).FirstElementChild.GetAttribute("href"); - var catId = HttpUtility.ParseQueryString(catUrl).Get("category"); + var catId = QueryHelpers.ParseQuery(catUrl)["category"].First(); release.Category = MapTrackerCatToNewznab(catId); var qLink = rowA.ChildElements.ElementAt(1).FirstElementChild.Cq(); diff --git a/src/Jackett/Indexers/DigitalHive.cs b/src/Jackett.Common/Indexers/DigitalHive.cs similarity index 99% rename from src/Jackett/Indexers/DigitalHive.cs rename to src/Jackett.Common/Indexers/DigitalHive.cs index 85ea4b31d..96e26d2dc 100644 --- a/src/Jackett/Indexers/DigitalHive.cs +++ b/src/Jackett.Common/Indexers/DigitalHive.cs @@ -27,7 +27,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public DigitalHive(IIndexerConfigurationService configService, IWebClient w, Logger l, IProtectionService ps) + public DigitalHive(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps) : base(name: "DigitalHive", description: "DigitalHive is one of the oldest general trackers", link: "https://www.digitalhive.org/", diff --git a/src/Jackett/Indexers/EliteTracker.cs b/src/Jackett.Common/Indexers/EliteTracker.cs similarity index 98% rename from src/Jackett/Indexers/EliteTracker.cs rename to src/Jackett.Common/Indexers/EliteTracker.cs index e9ddb401b..b6cba8209 100644 --- a/src/Jackett/Indexers/EliteTracker.cs +++ b/src/Jackett.Common/Indexers/EliteTracker.cs @@ -29,7 +29,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public EliteTracker(IIndexerConfigurationService configService, IWebClient webClient, Logger logger, IProtectionService protectionService) + public EliteTracker(IIndexerConfigurationService configService, WebClient webClient, Logger logger, IProtectionService protectionService) : base(name: "Elite-Tracker", description: "French Torrent Tracker", link: "https://elite-tracker.net/", @@ -40,7 +40,7 @@ namespace Jackett.Indexers configData: new ConfigurationDataBasicLogin() ) { - Encoding = Encoding.GetEncoding("UTF-8"); +Encoding = Encoding.UTF8; Language = "fr-fr"; Type = "private"; diff --git a/src/Jackett/Indexers/Feeds/AnimeTosho.cs b/src/Jackett.Common/Indexers/Feeds/AnimeTosho.cs similarity index 96% rename from src/Jackett/Indexers/Feeds/AnimeTosho.cs rename to src/Jackett.Common/Indexers/Feeds/AnimeTosho.cs index 868aa0885..5a1169ffa 100644 --- a/src/Jackett/Indexers/Feeds/AnimeTosho.cs +++ b/src/Jackett.Common/Indexers/Feeds/AnimeTosho.cs @@ -13,7 +13,7 @@ namespace Jackett.Indexers.Newznab { public class AnimeTosho : BaseNewznabIndexer { - public AnimeTosho(IIndexerConfigurationService configService, IWebClient client, Logger logger, IProtectionService p) + public AnimeTosho(IIndexerConfigurationService configService, WebClient client, Logger logger, IProtectionService p) : base( "Anime Tosho", "https://animetosho.org/", diff --git a/src/Jackett/Indexers/Feeds/BaseFeedIndexer.cs b/src/Jackett.Common/Indexers/Feeds/BaseFeedIndexer.cs similarity index 83% rename from src/Jackett/Indexers/Feeds/BaseFeedIndexer.cs rename to src/Jackett.Common/Indexers/Feeds/BaseFeedIndexer.cs index eed4eb937..137f34f3d 100644 --- a/src/Jackett/Indexers/Feeds/BaseFeedIndexer.cs +++ b/src/Jackett.Common/Indexers/Feeds/BaseFeedIndexer.cs @@ -15,7 +15,7 @@ namespace Jackett.Indexers { protected abstract Uri FeedUri { get; } - protected BaseFeedIndexer(string name, string link, string description, IIndexerConfigurationService configService, IWebClient client, Logger logger, ConfigurationData configData, IProtectionService p, TorznabCapabilities caps = null, string downloadBase = null) : base(name, link, description, configService, client, logger, configData, p, caps, downloadBase) + protected BaseFeedIndexer(string name, string link, string description, IIndexerConfigurationService configService, WebClient client, Logger logger, ConfigurationData configData, IProtectionService p, TorznabCapabilities caps = null, string downloadBase = null) : base(name, link, description, configService, client, logger, configData, p, caps, downloadBase) { } diff --git a/src/Jackett/Indexers/Feeds/BaseNewznabIndexer.cs b/src/Jackett.Common/Indexers/Feeds/BaseNewznabIndexer.cs similarity index 88% rename from src/Jackett/Indexers/Feeds/BaseNewznabIndexer.cs rename to src/Jackett.Common/Indexers/Feeds/BaseNewznabIndexer.cs index 0b0e89571..11da47330 100644 --- a/src/Jackett/Indexers/Feeds/BaseNewznabIndexer.cs +++ b/src/Jackett.Common/Indexers/Feeds/BaseNewznabIndexer.cs @@ -13,7 +13,7 @@ namespace Jackett.Indexers { public abstract class BaseNewznabIndexer : BaseFeedIndexer { - protected BaseNewznabIndexer(string name, string link, string description, IIndexerConfigurationService configService, IWebClient client, Logger logger, ConfigurationData configData, IProtectionService p, TorznabCapabilities caps = null, string downloadBase = null) : base(name, link, description, configService, client, logger, configData, p, caps, downloadBase) + protected BaseNewznabIndexer(string name, string link, string description, IIndexerConfigurationService configService, WebClient client, Logger logger, ConfigurationData configData, IProtectionService p, TorznabCapabilities caps = null, string downloadBase = null) : base(name, link, description, configService, client, logger, configData, p, caps, downloadBase) { } diff --git a/src/Jackett/Indexers/FileList.cs b/src/Jackett.Common/Indexers/FileList.cs similarity index 98% rename from src/Jackett/Indexers/FileList.cs rename to src/Jackett.Common/Indexers/FileList.cs index 68464da3f..4dc0a9810 100644 --- a/src/Jackett/Indexers/FileList.cs +++ b/src/Jackett.Common/Indexers/FileList.cs @@ -28,7 +28,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public FileList(IIndexerConfigurationService configService, IWebClient wc, Logger l, IProtectionService ps) + public FileList(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps) : base(name: "FileList", description: "The best Romanian site.", link: "http://filelist.ro/", @@ -39,7 +39,7 @@ namespace Jackett.Indexers p: ps, configData: new ConfigurationDataFileList()) { - Encoding = Encoding.GetEncoding("UTF-8"); + Encoding = Encoding.UTF8; Language = "ro-ro"; Type = "private"; diff --git a/src/Jackett/Indexers/FunFile.cs b/src/Jackett.Common/Indexers/FunFile.cs similarity index 99% rename from src/Jackett/Indexers/FunFile.cs rename to src/Jackett.Common/Indexers/FunFile.cs index 8db6d84a3..22a042796 100644 --- a/src/Jackett/Indexers/FunFile.cs +++ b/src/Jackett.Common/Indexers/FunFile.cs @@ -25,7 +25,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public FunFile(IIndexerConfigurationService configService, IWebClient w, Logger l, IProtectionService ps) + public FunFile(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps) : base(name: "FunFile", description: "A general tracker", link: "https://www.funfile.org/", diff --git a/src/Jackett/Indexers/Fuzer.cs b/src/Jackett.Common/Indexers/Fuzer.cs similarity index 97% rename from src/Jackett/Indexers/Fuzer.cs rename to src/Jackett.Common/Indexers/Fuzer.cs index 9067d9675..64eb78948 100644 --- a/src/Jackett/Indexers/Fuzer.cs +++ b/src/Jackett.Common/Indexers/Fuzer.cs @@ -3,11 +3,13 @@ using System.Collections.Generic; using System.Collections.Specialized; using System.Globalization; using System.Linq; +using System.Net; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Web; using CsQuery; +using Jacket.Common.Helpers; using Jackett.Models; using Jackett.Models.IndexerConfig; using Jackett.Services.Interfaces; @@ -30,7 +32,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public Fuzer(IIndexerConfigurationService configService, IWebClient w, Logger l, IProtectionService ps) + public Fuzer(IIndexerConfigurationService configService, Utils.Clients.WebClient w, Logger l, IProtectionService ps) : base(name: "Fuzer", description: "Fuzer is a private torrent website with israeli torrents.", link: "https://fuzer.me/", @@ -40,7 +42,7 @@ namespace Jackett.Indexers p: ps, configData: new ConfigurationDataBasicLogin()) { - Encoding = Encoding.GetEncoding("Windows-1255"); + Encoding = Encoding.GetEncoding("windows-1255"); Language = "he-il"; Type = "private"; TorznabCaps.Categories.Clear(); @@ -161,7 +163,7 @@ namespace Jackett.Indexers searchUrl += "?"; if (!string.IsNullOrWhiteSpace(searchString)) { - var strEncoded = HttpUtility.UrlEncode(searchString, Encoding.GetEncoding("Windows-1255")); + var strEncoded = WebUtilityHelpers.UrlEncode(searchString, Encoding); searchUrl += "&query=" + strEncoded + "&matchquery=any"; } diff --git a/src/Jackett/Indexers/GFTracker.cs b/src/Jackett.Common/Indexers/GFTracker.cs similarity index 99% rename from src/Jackett/Indexers/GFTracker.cs rename to src/Jackett.Common/Indexers/GFTracker.cs index 0ea023916..23f745f4a 100644 --- a/src/Jackett/Indexers/GFTracker.cs +++ b/src/Jackett.Common/Indexers/GFTracker.cs @@ -31,7 +31,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public GFTracker(IIndexerConfigurationService configService, IWebClient w, Logger l, IProtectionService ps) + public GFTracker(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps) : base(name: "GFTracker", description: "Home of user happiness", link: "https://www.thegft.org/", diff --git a/src/Jackett/Indexers/GhostCity.cs b/src/Jackett.Common/Indexers/GhostCity.cs similarity index 98% rename from src/Jackett/Indexers/GhostCity.cs rename to src/Jackett.Common/Indexers/GhostCity.cs index a8336bd65..f0d317811 100644 --- a/src/Jackett/Indexers/GhostCity.cs +++ b/src/Jackett.Common/Indexers/GhostCity.cs @@ -27,7 +27,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public GhostCity(IIndexerConfigurationService configService, IWebClient wc, Logger l, IProtectionService ps) + public GhostCity(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps) : base(name: "Ghost City", description: "A German general tracker", link: "http://ghostcity.dyndns.info/", @@ -38,7 +38,7 @@ namespace Jackett.Indexers p: ps, configData: new ConfigurationDataBasicLoginWithRSSAndDisplay()) { - Encoding = Encoding.GetEncoding("UTF-8"); + Encoding = Encoding.UTF8; Language = "de-de"; Type = "private"; diff --git a/src/Jackett/Indexers/GimmePeers.cs b/src/Jackett.Common/Indexers/GimmePeers.cs similarity index 99% rename from src/Jackett/Indexers/GimmePeers.cs rename to src/Jackett.Common/Indexers/GimmePeers.cs index b0a38f2c6..a2b88a05e 100644 --- a/src/Jackett/Indexers/GimmePeers.cs +++ b/src/Jackett.Common/Indexers/GimmePeers.cs @@ -28,7 +28,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public GimmePeers(IIndexerConfigurationService configService, IWebClient wc, Logger l, IProtectionService ps) + public GimmePeers(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps) : base(name: "GimmePeers", description: "Formerly ILT", link: "https://www.gimmepeers.com/", diff --git a/src/Jackett/Indexers/HD4Free.cs b/src/Jackett.Common/Indexers/HD4Free.cs similarity index 99% rename from src/Jackett/Indexers/HD4Free.cs rename to src/Jackett.Common/Indexers/HD4Free.cs index b6f7b07ca..fc4f7f342 100644 --- a/src/Jackett/Indexers/HD4Free.cs +++ b/src/Jackett.Common/Indexers/HD4Free.cs @@ -27,7 +27,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public HD4Free(IIndexerConfigurationService configService, IWebClient w, Logger l, IProtectionService ps) + public HD4Free(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps) : base(name: "HD4Free", description: "A HD trackers", link: "https://hd4free.xyz/", @@ -38,7 +38,7 @@ namespace Jackett.Indexers p: ps, configData: new ConfigurationDataRecaptchaLogin()) { - Encoding = Encoding.GetEncoding("UTF-8"); + Encoding = Encoding.UTF8; Language = "en-us"; Type = "private"; diff --git a/src/Jackett/Indexers/HDForever.cs b/src/Jackett.Common/Indexers/HDForever.cs similarity index 90% rename from src/Jackett/Indexers/HDForever.cs rename to src/Jackett.Common/Indexers/HDForever.cs index d80406b41..f56810594 100644 --- a/src/Jackett/Indexers/HDForever.cs +++ b/src/Jackett.Common/Indexers/HDForever.cs @@ -8,7 +8,7 @@ namespace Jackett.Indexers { public class HDForever : GazelleTracker { - public HDForever(IIndexerConfigurationService configService, IWebClient webClient, Logger logger, IProtectionService protectionService) + public HDForever(IIndexerConfigurationService configService, WebClient webClient, Logger logger, IProtectionService protectionService) : base(name: "HD-Forever", desc: "HD-Forever (HD-F) is a FRENCH Private Torrent Tracker for HD MOVIES", link: "https://hdf.world/", diff --git a/src/Jackett/Indexers/HDOnly.cs b/src/Jackett.Common/Indexers/HDOnly.cs similarity index 97% rename from src/Jackett/Indexers/HDOnly.cs rename to src/Jackett.Common/Indexers/HDOnly.cs index 22491aaf6..b8a7bb563 100644 --- a/src/Jackett/Indexers/HDOnly.cs +++ b/src/Jackett.Common/Indexers/HDOnly.cs @@ -10,7 +10,7 @@ namespace Jackett.Indexers { public class HDOnly : GazelleTracker { - public HDOnly(IIndexerConfigurationService configService, IWebClient webClient, Logger logger, IProtectionService protectionService) + public HDOnly(IIndexerConfigurationService configService, WebClient webClient, Logger logger, IProtectionService protectionService) : base(name: "HD-Only", desc: "HD-Only (HD-O) is a FRENCH Private Torrent Tracker for HD MOVIES / TV", link: "https://hd-only.org/", diff --git a/src/Jackett/Indexers/HDSpace.cs b/src/Jackett.Common/Indexers/HDSpace.cs similarity index 98% rename from src/Jackett/Indexers/HDSpace.cs rename to src/Jackett.Common/Indexers/HDSpace.cs index e1e50d103..351449ffd 100644 --- a/src/Jackett/Indexers/HDSpace.cs +++ b/src/Jackett.Common/Indexers/HDSpace.cs @@ -28,7 +28,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public HDSpace(IIndexerConfigurationService configService, IWebClient wc, Logger l, IProtectionService ps) + public HDSpace(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps) : base(name: "HD-Space", description: "Sharing The Universe", link: "https://hd-space.org/", @@ -39,7 +39,7 @@ namespace Jackett.Indexers p: ps, configData: new ConfigurationDataBasicLogin()) { - Encoding = Encoding.GetEncoding("UTF-8"); + Encoding = Encoding.UTF8; Language = "en-us"; Type = "private"; diff --git a/src/Jackett/Indexers/HDTorrents.cs b/src/Jackett.Common/Indexers/HDTorrents.cs similarity index 98% rename from src/Jackett/Indexers/HDTorrents.cs rename to src/Jackett.Common/Indexers/HDTorrents.cs index abcaaa397..c7ef65434 100644 --- a/src/Jackett/Indexers/HDTorrents.cs +++ b/src/Jackett.Common/Indexers/HDTorrents.cs @@ -28,7 +28,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public HDTorrents(IIndexerConfigurationService configService, IWebClient w, Logger l, IProtectionService ps) + public HDTorrents(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps) : base(name: "HD-Torrents", description: "HD-Torrents is a private torrent website with HD torrents and strict rules on their content.", link: "https://hdts.ru/",// Of the accessible domains the .ru seems the most reliable. https://hdts.ru | https://hd-torrents.org | https://hd-torrents.net | https://hd-torrents.me @@ -38,7 +38,7 @@ namespace Jackett.Indexers p: ps, configData: new ConfigurationDataBasicLogin()) { - Encoding = Encoding.GetEncoding("UTF-8"); + Encoding = Encoding.UTF8; Language = "en-us"; Type = "private"; diff --git a/src/Jackett/Indexers/Hardbay.cs b/src/Jackett.Common/Indexers/Hardbay.cs similarity index 98% rename from src/Jackett/Indexers/Hardbay.cs rename to src/Jackett.Common/Indexers/Hardbay.cs index ad7653c01..c31c91265 100644 --- a/src/Jackett/Indexers/Hardbay.cs +++ b/src/Jackett.Common/Indexers/Hardbay.cs @@ -26,7 +26,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public Hardbay(IIndexerConfigurationService configService, IWebClient w, Logger l, IProtectionService ps) + public Hardbay(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps) : base(name: "Hardbay", description: "Hardbay is a Private Torrent Tracker for HARDSTYLE / HARDCORE ELECTRONIC MUSIC", link: "https://hardbay.club/", @@ -37,7 +37,7 @@ namespace Jackett.Indexers p: ps, configData: new ConfigurationDataBasicLogin()) { - Encoding = Encoding.GetEncoding("UTF-8"); + Encoding = Encoding.UTF8; Language = "en-us"; Type = "private"; diff --git a/src/Jackett/Indexers/Hebits.cs b/src/Jackett.Common/Indexers/Hebits.cs similarity index 96% rename from src/Jackett/Indexers/Hebits.cs rename to src/Jackett.Common/Indexers/Hebits.cs index 882db775d..1066947ee 100644 --- a/src/Jackett/Indexers/Hebits.cs +++ b/src/Jackett.Common/Indexers/Hebits.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Globalization; +using System.Net; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; @@ -28,7 +29,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public Hebits(IIndexerConfigurationService configService, IWebClient wc, Logger l, IProtectionService ps) + public Hebits(IIndexerConfigurationService configService, Utils.Clients.WebClient wc, Logger l, IProtectionService ps) : base(name: "Hebits", description: "The Israeli Tracker", link: "https://hebits.net/", @@ -85,9 +86,9 @@ namespace Jackett.Indexers if (!string.IsNullOrWhiteSpace(searchString)) { - searchUrl += "&search=" + HttpUtility.UrlEncode(searchString); + searchUrl += "&search=" + WebUtility.UrlEncode(searchString); } - string.Format(SearchUrl, HttpUtility.UrlEncode(searchString)); + string.Format(SearchUrl, WebUtility.UrlEncode(searchString)); var cats = MapTorznabCapsToTrackers(query); if (cats.Count > 0) diff --git a/src/Jackett/Indexers/Hounddawgs.cs b/src/Jackett.Common/Indexers/Hounddawgs.cs similarity index 99% rename from src/Jackett/Indexers/Hounddawgs.cs rename to src/Jackett.Common/Indexers/Hounddawgs.cs index ca8aa8f1b..86e3a472a 100644 --- a/src/Jackett/Indexers/Hounddawgs.cs +++ b/src/Jackett.Common/Indexers/Hounddawgs.cs @@ -28,7 +28,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public Hounddawgs(IIndexerConfigurationService configService, IWebClient c, Logger l, IProtectionService ps) + public Hounddawgs(IIndexerConfigurationService configService, WebClient c, Logger l, IProtectionService ps) : base(name: "Hounddawgs", description: "A danish closed torrent tracker", link: "https://hounddawgs.org/", @@ -39,7 +39,7 @@ namespace Jackett.Indexers p: ps, configData: new NxtGnConfigurationData()) { - Encoding = Encoding.GetEncoding("UTF-8"); + Encoding = Encoding.UTF8; Language = "da-dk"; Type = "private"; diff --git a/src/Jackett/Indexers/HouseOfTorrents.cs b/src/Jackett.Common/Indexers/HouseOfTorrents.cs similarity index 99% rename from src/Jackett/Indexers/HouseOfTorrents.cs rename to src/Jackett.Common/Indexers/HouseOfTorrents.cs index e782dd784..6618c5f34 100644 --- a/src/Jackett/Indexers/HouseOfTorrents.cs +++ b/src/Jackett.Common/Indexers/HouseOfTorrents.cs @@ -29,7 +29,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public HouseOfTorrents(IIndexerConfigurationService configService, IWebClient w, Logger l, IProtectionService ps) + public HouseOfTorrents(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps) : base(name: "House-of-Torrents", description: "A general tracker", link: "https://houseoftorrents.club/", @@ -40,7 +40,7 @@ namespace Jackett.Indexers p: ps, configData: new ConfigurationDataBasicLoginWithRSSAndDisplay()) { - Encoding = Encoding.GetEncoding("UTF-8"); + Encoding = Encoding.UTF8; Language = "en-us"; Type = "private"; diff --git a/src/Jackett/Indexers/IIndexer.cs b/src/Jackett.Common/Indexers/IIndexer.cs similarity index 100% rename from src/Jackett/Indexers/IIndexer.cs rename to src/Jackett.Common/Indexers/IIndexer.cs diff --git a/src/Jackett/Indexers/IPTorrents.cs b/src/Jackett.Common/Indexers/IPTorrents.cs similarity index 98% rename from src/Jackett/Indexers/IPTorrents.cs rename to src/Jackett.Common/Indexers/IPTorrents.cs index 22b09e899..e84f7f8ce 100644 --- a/src/Jackett/Indexers/IPTorrents.cs +++ b/src/Jackett.Common/Indexers/IPTorrents.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; +using System.Net; using System.Text; using System.Threading.Tasks; using System.Web; @@ -42,7 +43,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public IPTorrents(IIndexerConfigurationService configService, IWebClient wc, Logger l, IProtectionService ps) + public IPTorrents(IIndexerConfigurationService configService, Utils.Clients.WebClient wc, Logger l, IProtectionService ps) : base(name: "IPTorrents", description: "Always a step ahead.", link: "https://iptorrents.com/", @@ -53,7 +54,7 @@ namespace Jackett.Indexers p: ps, configData: new ConfigurationDataRecaptchaLogin()) { - Encoding = Encoding.GetEncoding("UTF-8"); + Encoding = Encoding.UTF8; Language = "en-us"; Type = "private"; @@ -267,7 +268,7 @@ namespace Jackett.Indexers release.PublishDate = DateTimeUtil.FromTimeAgo(dateString); var qLink = row.ChildElements.ElementAt(3).Cq().Children("a"); - release.Link = new Uri(SiteLink + HttpUtility.UrlEncode(qLink.Attr("href").TrimStart('/'))); + release.Link = new Uri(SiteLink + WebUtility.UrlEncode(qLink.Attr("href").TrimStart('/'))); var sizeStr = row.ChildElements.ElementAt(5).Cq().Text(); release.Size = ReleaseInfo.GetBytes(sizeStr); diff --git a/src/Jackett/Indexers/ImmortalSeed.cs b/src/Jackett.Common/Indexers/ImmortalSeed.cs similarity index 96% rename from src/Jackett/Indexers/ImmortalSeed.cs rename to src/Jackett.Common/Indexers/ImmortalSeed.cs index 3db685854..697f5e289 100644 --- a/src/Jackett/Indexers/ImmortalSeed.cs +++ b/src/Jackett.Common/Indexers/ImmortalSeed.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; +using System.Net; using System.Text; using System.Threading.Tasks; using System.Web; @@ -28,7 +29,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public ImmortalSeed(IIndexerConfigurationService configService, IWebClient wc, Logger l, IProtectionService ps) + public ImmortalSeed(IIndexerConfigurationService configService, Utils.Clients.WebClient wc, Logger l, IProtectionService ps) : base(name: "ImmortalSeed", description: "ImmortalSeed (iS) is a Private Torrent Tracker for MOVIES / TV / GENERAL", link: "http://immortalseed.me/", @@ -39,7 +40,7 @@ namespace Jackett.Indexers p: ps, configData: new ConfigurationDataBasicLogin()) { - Encoding = Encoding.GetEncoding("UTF-8"); + Encoding = Encoding.UTF8; Language = "en-us"; Type = "private"; @@ -96,7 +97,7 @@ namespace Jackett.Indexers if (!string.IsNullOrWhiteSpace(query.GetQueryString())) { - searchUrl += string.Format(QueryString, HttpUtility.UrlEncode(query.GetQueryString())); + searchUrl += string.Format(QueryString, WebUtility.UrlEncode(query.GetQueryString())); } var results = await RequestStringWithCookiesAndRetry(searchUrl); diff --git a/src/Jackett/Indexers/LostFilm.cs b/src/Jackett.Common/Indexers/LostFilm.cs similarity index 99% rename from src/Jackett/Indexers/LostFilm.cs rename to src/Jackett.Common/Indexers/LostFilm.cs index 96849ca4b..121321e0e 100644 --- a/src/Jackett/Indexers/LostFilm.cs +++ b/src/Jackett.Common/Indexers/LostFilm.cs @@ -83,7 +83,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public LostFilm(IIndexerConfigurationService configService, IWebClient wc, Logger l, IProtectionService ps) + public LostFilm(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps) : base(name: "LostFilm.tv", description: "Unique portal about foreign series", link: "https://www.lostfilm.tv/", diff --git a/src/Jackett/Indexers/Meta/BaseMetaIndexer.cs b/src/Jackett.Common/Indexers/Meta/BaseMetaIndexer.cs similarity index 97% rename from src/Jackett/Indexers/Meta/BaseMetaIndexer.cs rename to src/Jackett.Common/Indexers/Meta/BaseMetaIndexer.cs index d370cee8a..a8fbabf45 100644 --- a/src/Jackett/Indexers/Meta/BaseMetaIndexer.cs +++ b/src/Jackett.Common/Indexers/Meta/BaseMetaIndexer.cs @@ -14,7 +14,7 @@ namespace Jackett.Indexers.Meta { public abstract class BaseMetaIndexer : BaseWebIndexer { - protected BaseMetaIndexer(string name, string description, IFallbackStrategyProvider fallbackStrategyProvider, IResultFilterProvider resultFilterProvider, IIndexerConfigurationService configService, IWebClient webClient, Logger logger, ConfigurationData configData, IProtectionService p, Func filter) + protected BaseMetaIndexer(string name, string description, IFallbackStrategyProvider fallbackStrategyProvider, IResultFilterProvider resultFilterProvider, IIndexerConfigurationService configService, WebClient webClient, Logger logger, ConfigurationData configData, IProtectionService p, Func filter) : base(name, "http://127.0.0.1/", description, configService, webClient, logger, configData, p, null, null) { filterFunc = filter; diff --git a/src/Jackett/Indexers/Meta/Fallbacks.cs b/src/Jackett.Common/Indexers/Meta/Fallbacks.cs similarity index 100% rename from src/Jackett/Indexers/Meta/Fallbacks.cs rename to src/Jackett.Common/Indexers/Meta/Fallbacks.cs diff --git a/src/Jackett/Indexers/Meta/MetaIndexers.cs b/src/Jackett.Common/Indexers/Meta/MetaIndexers.cs similarity index 88% rename from src/Jackett/Indexers/Meta/MetaIndexers.cs rename to src/Jackett.Common/Indexers/Meta/MetaIndexers.cs index 4e3aaf88c..b9d5d632a 100644 --- a/src/Jackett/Indexers/Meta/MetaIndexers.cs +++ b/src/Jackett.Common/Indexers/Meta/MetaIndexers.cs @@ -12,7 +12,7 @@ using Jackett.Models.IndexerConfig; namespace Jackett.Indexers.Meta { - class AggregateIndexer : BaseMetaIndexer + public class AggregateIndexer : BaseMetaIndexer { public override string ID { @@ -21,7 +21,7 @@ namespace Jackett.Indexers.Meta return "all"; } } - public AggregateIndexer(IFallbackStrategyProvider fallbackStrategyProvider, IResultFilterProvider resultFilterProvider, IIndexerConfigurationService configService, IWebClient wc, Logger l, IProtectionService ps) + public AggregateIndexer(IFallbackStrategyProvider fallbackStrategyProvider, IResultFilterProvider resultFilterProvider, IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps) : base("AggregateSearch", "This feed includes all configured trackers", fallbackStrategyProvider, resultFilterProvider, configService, wc, l, new ConfigurationData(), ps, x => true) { } diff --git a/src/Jackett/Indexers/Meta/ResultFilters.cs b/src/Jackett.Common/Indexers/Meta/ResultFilters.cs similarity index 100% rename from src/Jackett/Indexers/Meta/ResultFilters.cs rename to src/Jackett.Common/Indexers/Meta/ResultFilters.cs diff --git a/src/Jackett/Indexers/MoreThanTV.cs b/src/Jackett.Common/Indexers/MoreThanTV.cs similarity index 97% rename from src/Jackett/Indexers/MoreThanTV.cs rename to src/Jackett.Common/Indexers/MoreThanTV.cs index ccea10edb..1538a7879 100644 --- a/src/Jackett/Indexers/MoreThanTV.cs +++ b/src/Jackett.Common/Indexers/MoreThanTV.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; +using System.Net; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; @@ -28,7 +29,7 @@ namespace Jackett.Indexers private ConfigurationDataBasicLogin ConfigData => (ConfigurationDataBasicLogin)configData; - public MoreThanTV(IIndexerConfigurationService configService, IWebClient c, Logger l, IProtectionService ps) + public MoreThanTV(IIndexerConfigurationService configService, Utils.Clients.WebClient c, Logger l, IProtectionService ps) : base(name: "MoreThanTV", description: "ROMANIAN Private Torrent Tracker for TV / MOVIES, and the internal tracker for the release group DRACULA.", link: "https://www.morethan.tv/", @@ -40,7 +41,7 @@ namespace Jackett.Indexers p: ps, configData: new ConfigurationDataBasicLogin()) { - Encoding = Encoding.GetEncoding("UTF-8"); + Encoding = Encoding.UTF8; Language = "en-us"; Type = "private"; } @@ -101,7 +102,7 @@ namespace Jackett.Indexers if (Array.IndexOf(categories, TorznabCatType.TV.ID) > -1) extra += "&filter_cat%5B2%5D=1"; - return SiteLink + $"torrents.php?searchstr={HttpUtility.UrlEncode(searchQuery)}&tags_type=1&order_by=time&order_way=desc&group_results=1{extra}&action=basic&searchsubmit=1"; + return SiteLink + $"torrents.php?searchstr={WebUtility.UrlEncode(searchQuery)}&tags_type=1&order_by=time&order_way=desc&group_results=1{extra}&action=basic&searchsubmit=1"; } private async Task GetReleases(ICollection releases, TorznabQuery query, string searchQuery) diff --git a/src/Jackett/Indexers/MyAnonamouse.cs b/src/Jackett.Common/Indexers/MyAnonamouse.cs similarity index 99% rename from src/Jackett/Indexers/MyAnonamouse.cs rename to src/Jackett.Common/Indexers/MyAnonamouse.cs index 752162438..6fad57cee 100644 --- a/src/Jackett/Indexers/MyAnonamouse.cs +++ b/src/Jackett.Common/Indexers/MyAnonamouse.cs @@ -26,7 +26,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public Myanonamouse(IIndexerConfigurationService configService, IWebClient c, Logger l, IProtectionService ps) + public Myanonamouse(IIndexerConfigurationService configService, WebClient c, Logger l, IProtectionService ps) : base(name: "MyAnonamouse", description: "Friendliness, Warmth and Sharing", link: "https://www.myanonamouse.net/", @@ -42,7 +42,7 @@ namespace Jackett.Indexers p: ps, configData: new ConfigurationDataBasicLogin()) { - Encoding = Encoding.GetEncoding("UTF-8"); + Encoding = Encoding.UTF8; Language = "en-us"; Type = "private"; diff --git a/src/Jackett/Indexers/NCore.cs b/src/Jackett.Common/Indexers/NCore.cs similarity index 99% rename from src/Jackett/Indexers/NCore.cs rename to src/Jackett.Common/Indexers/NCore.cs index ade1771e0..b1936f16c 100644 --- a/src/Jackett/Indexers/NCore.cs +++ b/src/Jackett.Common/Indexers/NCore.cs @@ -28,7 +28,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public NCore(IIndexerConfigurationService configService, IWebClient wc, Logger l, IProtectionService ps) + public NCore(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps) : base(name: "nCore", description: "A Hungarian private torrent site.", link: "https://ncore.cc/", diff --git a/src/Jackett/Indexers/NewRealWorld.cs b/src/Jackett.Common/Indexers/NewRealWorld.cs similarity index 99% rename from src/Jackett/Indexers/NewRealWorld.cs rename to src/Jackett.Common/Indexers/NewRealWorld.cs index b5d616af0..57bcaa76d 100644 --- a/src/Jackett/Indexers/NewRealWorld.cs +++ b/src/Jackett.Common/Indexers/NewRealWorld.cs @@ -26,7 +26,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public NewRealWorld(IIndexerConfigurationService configService, IWebClient wc, Logger l, IProtectionService ps) + public NewRealWorld(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps) : base(name: "New Real World", description: "A German general tracker.", link: "https://nrw-tracker.eu/", diff --git a/src/Jackett/Indexers/Norbits.cs b/src/Jackett.Common/Indexers/Norbits.cs similarity index 98% rename from src/Jackett/Indexers/Norbits.cs rename to src/Jackett.Common/Indexers/Norbits.cs index cff5727df..6ab045cc4 100644 --- a/src/Jackett/Indexers/Norbits.cs +++ b/src/Jackett.Common/Indexers/Norbits.cs @@ -4,11 +4,13 @@ using System.Collections.Specialized; using System.Globalization; using System.IO; using System.Linq; +using System.Net; using System.Reflection; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using CsQuery; +using Jacket.Common.Helpers; using Jackett.Models; using Jackett.Models.IndexerConfig.Bespoke; using Jackett.Services.Interfaces; @@ -40,7 +42,7 @@ namespace Jackett.Indexers private CQ _fDom; private ConfigurationDataNorbits ConfigData => (ConfigurationDataNorbits)configData; - public Norbits(IIndexerConfigurationService configService, IWebClient w, Logger l, IProtectionService ps) + public Norbits(IIndexerConfigurationService configService, Utils.Clients.WebClient w, Logger l, IProtectionService ps) : base( name: "Norbits", description: "Norbits is a Norwegian Private site for MOVIES / TV / GENERAL", @@ -123,7 +125,7 @@ namespace Jackett.Indexers private async Task DoLogin() { // Build WebRequest for index - var myIndexRequest = new WebRequest() + var myIndexRequest = new Utils.Clients.WebRequest() { Type = RequestType.GET, Url = SiteLink, @@ -142,7 +144,7 @@ namespace Jackett.Indexers }; // Build WebRequest for login - var myRequestLogin = new WebRequest() + var myRequestLogin = new Utils.Clients.WebRequest() { Type = RequestType.GET, Url = LoginUrl, @@ -158,7 +160,7 @@ namespace Jackett.Indexers await webclient.GetString(myRequestLogin); // Build WebRequest for submitting authentification - var request = new WebRequest() + var request = new Utils.Clients.WebRequest() { PostData = pairs, Referer = LoginUrl, @@ -458,7 +460,7 @@ namespace Jackett.Indexers } else if (!string.IsNullOrWhiteSpace(term)) { - searchterm = "search=" + System.Web.HttpUtility.UrlEncode(term, Encoding.GetEncoding(28591)); + searchterm = "search=" + WebUtilityHelpers.UrlEncode(term, Encoding.GetEncoding(28591)); } else { @@ -696,7 +698,7 @@ namespace Jackett.Indexers goto case "debug"; case "debug": // Only if Debug Level Enabled on Jackett - if (Engine.Logger.IsDebugEnabled) + if (logger.IsDebugEnabled) { logger.Debug(message); } diff --git a/src/Jackett/Indexers/PassThePopcorn.cs b/src/Jackett.Common/Indexers/PassThePopcorn.cs similarity index 95% rename from src/Jackett/Indexers/PassThePopcorn.cs rename to src/Jackett.Common/Indexers/PassThePopcorn.cs index 4ed17fe39..9a0a33b66 100644 --- a/src/Jackett/Indexers/PassThePopcorn.cs +++ b/src/Jackett.Common/Indexers/PassThePopcorn.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; +using System.Net; using System.Text; using System.Threading.Tasks; using System.Web; @@ -28,7 +29,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public PassThePopcorn(IIndexerConfigurationService configService, IWebClient c, Logger l, IProtectionService ps) + public PassThePopcorn(IIndexerConfigurationService configService, Utils.Clients.WebClient c, Logger l, IProtectionService ps) : base(name: "PassThePopcorn", description: "PassThePopcorn is a Private site for MOVIES / TV", link: "https://passthepopcorn.me/", @@ -105,11 +106,11 @@ namespace Jackett.Indexers if (!string.IsNullOrEmpty(query.ImdbID)) { - movieListSearchUrl = string.Format("{0}?json=noredirect&searchstr={1}", SearchUrl, HttpUtility.UrlEncode(query.ImdbID)); + movieListSearchUrl = string.Format("{0}?json=noredirect&searchstr={1}", SearchUrl, WebUtility.UrlEncode(query.ImdbID)); } else if (!string.IsNullOrEmpty(query.GetQueryString())) { - movieListSearchUrl = string.Format("{0}?json=noredirect&searchstr={1}", SearchUrl, HttpUtility.UrlEncode(query.GetQueryString())); + movieListSearchUrl = string.Format("{0}?json=noredirect&searchstr={1}", SearchUrl, WebUtility.UrlEncode(query.GetQueryString())); } else { @@ -142,7 +143,7 @@ namespace Jackett.Indexers release.Description = string.Format("Title: {0}", movie_title); release.BannerUrl = coverUri; release.Imdb = movie_imdbid; - release.Comments = new Uri(string.Format("{0}?id={1}", SearchUrl, HttpUtility.UrlEncode(movie_groupid))); + release.Comments = new Uri(string.Format("{0}?id={1}", SearchUrl, WebUtility.UrlEncode(movie_groupid))); release.Guid = release.Comments; release.Size = long.Parse((string)torrent["Size"]); release.Grabs = long.Parse((string)torrent["Snatched"]); @@ -151,7 +152,7 @@ namespace Jackett.Indexers release.PublishDate = DateTime.ParseExact((string)torrent["UploadTime"], "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal).ToLocalTime(); release.Link = new Uri(string.Format("{0}?action=download&id={1}&authkey={2}&torrent_pass={3}", - SearchUrl, HttpUtility.UrlEncode((string)torrent["Id"]), HttpUtility.UrlEncode(AuthKey), HttpUtility.UrlEncode(configData.Passkey.Value))); + SearchUrl, WebUtility.UrlEncode((string)torrent["Id"]), WebUtility.UrlEncode(AuthKey), WebUtility.UrlEncode(configData.Passkey.Value))); release.MinimumRatio = 1; release.MinimumSeedTime = 345600; release.Category = new List { 2000 }; diff --git a/src/Jackett/Indexers/PiXELHD.cs b/src/Jackett.Common/Indexers/PiXELHD.cs similarity index 98% rename from src/Jackett/Indexers/PiXELHD.cs rename to src/Jackett.Common/Indexers/PiXELHD.cs index 2d45c0757..eba98bc4e 100644 --- a/src/Jackett/Indexers/PiXELHD.cs +++ b/src/Jackett.Common/Indexers/PiXELHD.cs @@ -32,7 +32,7 @@ namespace Jackett.Indexers private string input_username = null; private string input_password = null; - public PiXELHD(IIndexerConfigurationService configService, IWebClient webClient, Logger logger, IProtectionService protectionService) + public PiXELHD(IIndexerConfigurationService configService, WebClient webClient, Logger logger, IProtectionService protectionService) : base(name: "PiXELHD", description: "PixelHD (PxHD) is a Private Torrent Tracker for HD .MP4 MOVIES / TV", link: "https://pixelhd.me/", @@ -44,7 +44,7 @@ namespace Jackett.Indexers configData: new ConfigurationDataCaptchaLogin() ) { - Encoding = Encoding.GetEncoding("UTF-8"); + Encoding = Encoding.UTF8; Language = "en-us"; Type = "private"; diff --git a/src/Jackett/Indexers/PirateTheNet.cs b/src/Jackett.Common/Indexers/PirateTheNet.cs similarity index 99% rename from src/Jackett/Indexers/PirateTheNet.cs rename to src/Jackett.Common/Indexers/PirateTheNet.cs index a9b17c669..ba539c04f 100644 --- a/src/Jackett/Indexers/PirateTheNet.cs +++ b/src/Jackett.Common/Indexers/PirateTheNet.cs @@ -30,7 +30,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public PirateTheNet(IIndexerConfigurationService configService, IWebClient w, Logger l, IProtectionService ps) + public PirateTheNet(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps) : base(name: "PirateTheNet", description: "A movie tracker", link: "http://piratethenet.org/", @@ -41,7 +41,7 @@ namespace Jackett.Indexers p: ps, configData: new ConfigurationDataBasicLoginWithRSSAndDisplay()) { - Encoding = Encoding.GetEncoding("UTF-8"); + Encoding = Encoding.UTF8; Language = "en-us"; Type = "private"; diff --git a/src/Jackett/Indexers/PolishTracker.cs b/src/Jackett.Common/Indexers/PolishTracker.cs similarity index 98% rename from src/Jackett/Indexers/PolishTracker.cs rename to src/Jackett.Common/Indexers/PolishTracker.cs index 0350127fa..b6920fccb 100644 --- a/src/Jackett/Indexers/PolishTracker.cs +++ b/src/Jackett.Common/Indexers/PolishTracker.cs @@ -30,7 +30,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public PolishTracker(IIndexerConfigurationService configService, IWebClient wc, Logger l, IProtectionService ps) + public PolishTracker(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps) : base(name: "PolishTracker", description: "Polish Tracker is a POLISH Private site for 0DAY / MOVIES / GENERAL", link: "https://pte.nu/", @@ -41,7 +41,7 @@ namespace Jackett.Indexers p: ps, configData: new ConfigurationDataBasicLoginWithRSSAndDisplay()) { - Encoding = Encoding.GetEncoding("UTF-8"); +Encoding = Encoding.UTF8; Language = "pl-pl"; Type = "private"; diff --git a/src/Jackett/Indexers/Pretome.cs b/src/Jackett.Common/Indexers/Pretome.cs similarity index 99% rename from src/Jackett/Indexers/Pretome.cs rename to src/Jackett.Common/Indexers/Pretome.cs index a2c28b670..72ea35e63 100644 --- a/src/Jackett/Indexers/Pretome.cs +++ b/src/Jackett.Common/Indexers/Pretome.cs @@ -30,7 +30,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public Pretome(IIndexerConfigurationService configService, IWebClient wc, Logger l, IProtectionService ps) + public Pretome(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps) : base(name: "PreToMe", description: "BitTorrent site for High Quality, High Definition (HD) movies and TV Shows", link: "https://pretome.info/", diff --git a/src/Jackett/Indexers/PrivateHD.cs b/src/Jackett.Common/Indexers/PrivateHD.cs similarity index 89% rename from src/Jackett/Indexers/PrivateHD.cs rename to src/Jackett.Common/Indexers/PrivateHD.cs index d547eacca..d2b795559 100644 --- a/src/Jackett/Indexers/PrivateHD.cs +++ b/src/Jackett.Common/Indexers/PrivateHD.cs @@ -6,7 +6,7 @@ namespace Jackett.Indexers { public class PrivateHD : AvistazTracker, IIndexer { - public PrivateHD(IIndexerConfigurationService configService, IWebClient webClient, Logger logger, IProtectionService protectionService) + public PrivateHD(IIndexerConfigurationService configService, WebClient webClient, Logger logger, IProtectionService protectionService) : base(name: "PrivateHD", desc: "BitTorrent site for High Quality, High Definition (HD) movies and TV Shows", link: "https://privatehd.to/", diff --git a/src/Jackett/Indexers/Psytorrents.cs b/src/Jackett.Common/Indexers/Psytorrents.cs similarity index 91% rename from src/Jackett/Indexers/Psytorrents.cs rename to src/Jackett.Common/Indexers/Psytorrents.cs index 0246429af..09d22c125 100644 --- a/src/Jackett/Indexers/Psytorrents.cs +++ b/src/Jackett.Common/Indexers/Psytorrents.cs @@ -8,7 +8,7 @@ namespace Jackett.Indexers { public class Psytorrents : GazelleTracker { - public Psytorrents(IIndexerConfigurationService configService, IWebClient webClient, Logger logger, IProtectionService protectionService) + public Psytorrents(IIndexerConfigurationService configService, WebClient webClient, Logger logger, IProtectionService protectionService) : base(name: "Psytorrents", desc: "Psytorrents (PSY) is a Private Torrent Tracker for ELECTRONIC MUSIC", link: "https://psytorrents.info/", diff --git a/src/Jackett/Indexers/Rarbg.cs b/src/Jackett.Common/Indexers/Rarbg.cs similarity index 98% rename from src/Jackett/Indexers/Rarbg.cs rename to src/Jackett.Common/Indexers/Rarbg.cs index a730a6244..a10bd84bc 100644 --- a/src/Jackett/Indexers/Rarbg.cs +++ b/src/Jackett.Common/Indexers/Rarbg.cs @@ -5,6 +5,7 @@ using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks; +using Jacket.Common; using Jackett.Models; using Jackett.Models.IndexerConfig; using Jackett.Services.Interfaces; @@ -41,7 +42,7 @@ namespace Jackett.Indexers private bool HasValidToken { get { return !string.IsNullOrEmpty(token) && lastTokenFetch > DateTime.Now - TOKEN_DURATION; } } - public Rarbg(IIndexerConfigurationService configService, IWebClient wc, Logger l, IProtectionService ps) + public Rarbg(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps) : base(name: "RARBG", description: "RARBG is a Public torrent site for MOVIES / TV / GENERAL", link: "https://rarbg.to/", @@ -129,7 +130,7 @@ namespace Jackett.Indexers var queryCollection = new NameValueCollection(); queryCollection.Add("token", token); queryCollection.Add("format", "json_extended"); - queryCollection.Add("app_id", "jackett_v" + Engine.ConfigService.GetVersion()); + queryCollection.Add("app_id", "jackett_v" + JackettStartup.JackettVersion); queryCollection.Add("limit", "100"); queryCollection.Add("ranked", "0"); diff --git a/src/Jackett/Indexers/Redacted.cs b/src/Jackett.Common/Indexers/Redacted.cs similarity index 93% rename from src/Jackett/Indexers/Redacted.cs rename to src/Jackett.Common/Indexers/Redacted.cs index 087054dd9..f0f98f1da 100644 --- a/src/Jackett/Indexers/Redacted.cs +++ b/src/Jackett.Common/Indexers/Redacted.cs @@ -9,7 +9,7 @@ namespace Jackett.Indexers { public class PassTheHeadphones : GazelleTracker { - public PassTheHeadphones(IIndexerConfigurationService configService, IWebClient webClient, Logger logger, IProtectionService protectionService) + public PassTheHeadphones(IIndexerConfigurationService configService, WebClient webClient, Logger logger, IProtectionService protectionService) : base(name: "Redacted", desc: "A music tracker", link: "https://redacted.ch/", diff --git a/src/Jackett/Indexers/RevolutionTT.cs b/src/Jackett.Common/Indexers/RevolutionTT.cs similarity index 98% rename from src/Jackett/Indexers/RevolutionTT.cs rename to src/Jackett.Common/Indexers/RevolutionTT.cs index 1d73ff07f..29090751d 100644 --- a/src/Jackett/Indexers/RevolutionTT.cs +++ b/src/Jackett.Common/Indexers/RevolutionTT.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; +using System.Net; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; @@ -33,7 +34,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public RevolutionTT(IIndexerConfigurationService configService, IWebClient wc, Logger l, IProtectionService ps) + public RevolutionTT(IIndexerConfigurationService configService, Utils.Clients.WebClient wc, Logger l, IProtectionService ps) : base(name: "RevolutionTT", description: "The Revolution has begun", link: "https://revolutiontt.me/", @@ -292,8 +293,8 @@ namespace Jackett.Indexers } else { - searchUrl += "?titleonly=1&search=" + HttpUtility.UrlEncode(searchString); - string.Format(SearchUrl, HttpUtility.UrlEncode(searchString)); + searchUrl += "?titleonly=1&search=" + WebUtility.UrlEncode(searchString); + string.Format(SearchUrl, WebUtility.UrlEncode(searchString)); var cats = MapTorznabCapsToTrackers(query); if (cats.Count > 0) diff --git a/src/Jackett/Indexers/SceneFZ.cs b/src/Jackett.Common/Indexers/SceneFZ.cs similarity index 99% rename from src/Jackett/Indexers/SceneFZ.cs rename to src/Jackett.Common/Indexers/SceneFZ.cs index bd0007668..2cdddf88f 100644 --- a/src/Jackett/Indexers/SceneFZ.cs +++ b/src/Jackett.Common/Indexers/SceneFZ.cs @@ -4,6 +4,7 @@ using System.Collections.Specialized; using System.Globalization; using System.IO; using System.Linq; +using System.Net; using System.Reflection; using System.Text; using System.Text.RegularExpressions; @@ -43,7 +44,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public SceneFZ(IIndexerConfigurationService configService, IWebClient w, Logger l, IProtectionService ps) + public SceneFZ(IIndexerConfigurationService configService, Utils.Clients.WebClient w, Logger l, IProtectionService ps) : base( name: "SceneFZ", description: "Torrent tracker. Tracking over 50.000 torrent files.", @@ -134,7 +135,7 @@ namespace Jackett.Indexers }; // Getting login form to retrieve PHPSESSID - var myRequest = new WebRequest() + var myRequest = new Utils.Clients.WebRequest() { Url = LoginUrl }; @@ -402,7 +403,7 @@ namespace Jackett.Indexers if (!string.IsNullOrWhiteSpace(term)) { // Add search term - queryCollection.Add("search", HttpUtility.UrlEncode(term)); + queryCollection.Add("search", WebUtility.UrlEncode(term)); queryCollection.Add("searchin", "0"); queryCollection.Add("cat", "0"); queryCollection.Add("incldead", "0"); @@ -625,7 +626,7 @@ namespace Jackett.Indexers goto case "debug"; case "debug": // Only if Debug Level Enabled on Jackett - if (Engine.Logger.IsDebugEnabled) + if (logger.IsDebugEnabled) { logger.Debug(message); } diff --git a/src/Jackett/Indexers/SceneTime.cs b/src/Jackett.Common/Indexers/SceneTime.cs similarity index 99% rename from src/Jackett/Indexers/SceneTime.cs rename to src/Jackett.Common/Indexers/SceneTime.cs index 8be3cbd3e..388fa7b58 100644 --- a/src/Jackett/Indexers/SceneTime.cs +++ b/src/Jackett.Common/Indexers/SceneTime.cs @@ -28,7 +28,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public SceneTime(IIndexerConfigurationService configService, IWebClient w, Logger l, IProtectionService ps) + public SceneTime(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps) : base(name: "SceneTime", description: "Always on time", link: "https://www.scenetime.com/", diff --git a/src/Jackett/Indexers/Shazbat.cs b/src/Jackett.Common/Indexers/Shazbat.cs similarity index 99% rename from src/Jackett/Indexers/Shazbat.cs rename to src/Jackett.Common/Indexers/Shazbat.cs index 6f74a71f3..cd825b99f 100644 --- a/src/Jackett/Indexers/Shazbat.cs +++ b/src/Jackett.Common/Indexers/Shazbat.cs @@ -29,7 +29,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public Shazbat(IIndexerConfigurationService configService, IWebClient c, Logger l, IProtectionService ps) + public Shazbat(IIndexerConfigurationService configService, WebClient c, Logger l, IProtectionService ps) : base(name: "Shazbat", description: "Modern indexer", link: "https://www.shazbat.tv/", diff --git a/src/Jackett/Indexers/ShowRSS.cs b/src/Jackett.Common/Indexers/ShowRSS.cs similarity index 98% rename from src/Jackett/Indexers/ShowRSS.cs rename to src/Jackett.Common/Indexers/ShowRSS.cs index 45c786331..5231bc2dc 100644 --- a/src/Jackett/Indexers/ShowRSS.cs +++ b/src/Jackett.Common/Indexers/ShowRSS.cs @@ -25,7 +25,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public ShowRSS(IIndexerConfigurationService configService, IWebClient wc, Logger l, IProtectionService ps) + public ShowRSS(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps) : base(name: "ShowRSS", description: "showRSS is a service that allows you to keep track of your favorite TV shows", link: "https://showrss.info/", diff --git a/src/Jackett/Indexers/SpeedCD.cs b/src/Jackett.Common/Indexers/SpeedCD.cs similarity index 99% rename from src/Jackett/Indexers/SpeedCD.cs rename to src/Jackett.Common/Indexers/SpeedCD.cs index 1aaa713c2..ef2db64be 100644 --- a/src/Jackett/Indexers/SpeedCD.cs +++ b/src/Jackett.Common/Indexers/SpeedCD.cs @@ -27,7 +27,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public SpeedCD(IIndexerConfigurationService configService, IWebClient wc, Logger l, IProtectionService ps) + public SpeedCD(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps) : base(name: "Speed.cd", description: "Your home now!", link: "https://speed.cd/", diff --git a/src/Jackett/Indexers/Superbits.cs b/src/Jackett.Common/Indexers/Superbits.cs similarity index 98% rename from src/Jackett/Indexers/Superbits.cs rename to src/Jackett.Common/Indexers/Superbits.cs index 7ff6d0f6a..8b22382cf 100644 --- a/src/Jackett/Indexers/Superbits.cs +++ b/src/Jackett.Common/Indexers/Superbits.cs @@ -26,7 +26,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public Superbits(IIndexerConfigurationService configService, IWebClient w, Logger l, IProtectionService ps) + public Superbits(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps) : base(name: "Superbits", description: "SuperBits is a SWEDISH Private Torrent Tracker for MOVIES / TV / GENERAL", link: "https://superbits.org/", @@ -37,7 +37,7 @@ namespace Jackett.Indexers p: ps, configData: new ConfigurationDataBasicLogin()) { - Encoding = Encoding.GetEncoding("UTF-8"); + Encoding = Encoding.UTF8; Language = "sv-sw"; Type = "private"; diff --git a/src/Jackett/Indexers/Synthesiz3r.cs b/src/Jackett.Common/Indexers/Synthesiz3r.cs similarity index 94% rename from src/Jackett/Indexers/Synthesiz3r.cs rename to src/Jackett.Common/Indexers/Synthesiz3r.cs index 146f3aad4..9ddeec568 100644 --- a/src/Jackett/Indexers/Synthesiz3r.cs +++ b/src/Jackett.Common/Indexers/Synthesiz3r.cs @@ -9,7 +9,7 @@ namespace Jackett.Indexers { public class Synthesiz3r : GazelleTracker { - public Synthesiz3r(IIndexerConfigurationService configService, IWebClient webClient, Logger logger, IProtectionService protectionService) + public Synthesiz3r(IIndexerConfigurationService configService, WebClient webClient, Logger logger, IProtectionService protectionService) : base(name: "Synthesiz3r", desc: "Synthesiz3r (ST3) is a Private Torrent Tracker for ELECTRONIC MUSIC", link: "https://synthesiz3r.com/", diff --git a/src/Jackett/Indexers/TVChaosUK.cs b/src/Jackett.Common/Indexers/TVChaosUK.cs similarity index 99% rename from src/Jackett/Indexers/TVChaosUK.cs rename to src/Jackett.Common/Indexers/TVChaosUK.cs index abb091905..e24294b9c 100644 --- a/src/Jackett/Indexers/TVChaosUK.cs +++ b/src/Jackett.Common/Indexers/TVChaosUK.cs @@ -32,7 +32,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public TVChaosUK(IIndexerConfigurationService configService, IWebClient wc, Logger l, IProtectionService ps) + public TVChaosUK(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps) : base(name: "TV Chaos", description: "Total Chaos", link: "https://www.tvchaosuk.com/", @@ -43,7 +43,7 @@ namespace Jackett.Indexers p: ps, configData: new ConfigurationDataBasicLoginWithRSS()) { - Encoding = Encoding.GetEncoding("UTF-8"); + Encoding = Encoding.UTF8; Language = "en-uk"; Type = "private"; diff --git a/src/Jackett/Indexers/TVVault.cs b/src/Jackett.Common/Indexers/TVVault.cs similarity index 98% rename from src/Jackett/Indexers/TVVault.cs rename to src/Jackett.Common/Indexers/TVVault.cs index 935bef80a..592494a03 100644 --- a/src/Jackett/Indexers/TVVault.cs +++ b/src/Jackett.Common/Indexers/TVVault.cs @@ -26,7 +26,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public TVVault(IIndexerConfigurationService configService, IWebClient wc, Logger l, IProtectionService ps) + public TVVault(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps) : base(name: "TV-Vault", description: "A TV tracker for old shows.", link: "https://tv-vault.me/", @@ -37,7 +37,7 @@ namespace Jackett.Indexers p: ps, configData: new ConfigurationDataBasicLoginWithRSSAndDisplay()) { - Encoding = Encoding.GetEncoding("UTF-8"); + Encoding = Encoding.UTF8; Language = "en-us"; Type = "private"; diff --git a/src/Jackett/Indexers/TehConnection.cs b/src/Jackett.Common/Indexers/TehConnection.cs similarity index 97% rename from src/Jackett/Indexers/TehConnection.cs rename to src/Jackett.Common/Indexers/TehConnection.cs index 388f8316a..ad3920397 100644 --- a/src/Jackett/Indexers/TehConnection.cs +++ b/src/Jackett.Common/Indexers/TehConnection.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; +using System.Net; using System.Text; using System.Threading.Tasks; using System.Web; @@ -28,7 +29,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public TehConnection(IIndexerConfigurationService configService, IWebClient c, Logger l, IProtectionService ps) + public TehConnection(IIndexerConfigurationService configService, Utils.Clients.WebClient c, Logger l, IProtectionService ps) : base(name: "TehConnection", description: "Working towards providing a well-seeded archive of all available digital forms of cinema and film in their highest possible quality", link: "https://tehconnection.eu/", @@ -41,7 +42,7 @@ namespace Jackett.Indexers Separate options with a space if using more than one option.
Filter options available:
QualityEncodeOnly
FreeLeechOnly")) { - Encoding = Encoding.GetEncoding("UTF-8"); + Encoding = Encoding.UTF8; Language = "en-us"; Type = "private"; @@ -109,11 +110,11 @@ namespace Jackett.Indexers if (!string.IsNullOrEmpty(query.ImdbID)) { - movieListSearchUrl = string.Format("{0}?action=basic&searchstr={1}", SearchUrl, HttpUtility.UrlEncode(query.ImdbID)); + movieListSearchUrl = string.Format("{0}?action=basic&searchstr={1}", SearchUrl, WebUtility.UrlEncode(query.ImdbID)); } else if (!string.IsNullOrEmpty(query.GetQueryString())) { - movieListSearchUrl = string.Format("{0}?action=basic&searchstr={1}", SearchUrl, HttpUtility.UrlEncode(query.GetQueryString())); + movieListSearchUrl = string.Format("{0}?action=basic&searchstr={1}", SearchUrl, WebUtility.UrlEncode(query.GetQueryString())); } else { diff --git a/src/Jackett/Indexers/TorrentBytes.cs b/src/Jackett.Common/Indexers/TorrentBytes.cs similarity index 99% rename from src/Jackett/Indexers/TorrentBytes.cs rename to src/Jackett.Common/Indexers/TorrentBytes.cs index 2c48175e8..c520d7680 100644 --- a/src/Jackett/Indexers/TorrentBytes.cs +++ b/src/Jackett.Common/Indexers/TorrentBytes.cs @@ -26,7 +26,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public TorrentBytes(IIndexerConfigurationService configService, IWebClient wc, Logger l, IProtectionService ps) + public TorrentBytes(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps) : base(name: "TorrentBytes", description: "A decade of torrentbytes", link: "https://www.torrentbytes.net/", diff --git a/src/Jackett/Indexers/TorrentDay.cs b/src/Jackett.Common/Indexers/TorrentDay.cs similarity index 99% rename from src/Jackett/Indexers/TorrentDay.cs rename to src/Jackett.Common/Indexers/TorrentDay.cs index 8cc35e32e..4b2c9d7ed 100644 --- a/src/Jackett/Indexers/TorrentDay.cs +++ b/src/Jackett.Common/Indexers/TorrentDay.cs @@ -41,7 +41,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public TorrentDay(IIndexerConfigurationService configService, IWebClient wc, Logger l, IProtectionService ps) + public TorrentDay(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps) : base(name: "TorrentDay", description: "TorrentDay (TD) is a Private site for TV / MOVIES / GENERAL", link: "https://torrentday.it/", @@ -52,7 +52,7 @@ namespace Jackett.Indexers p: ps, configData: new ConfigurationDataRecaptchaLogin()) { - Encoding = Encoding.GetEncoding("UTF-8"); + Encoding = Encoding.UTF8; Language = "en-us"; Type = "private"; diff --git a/src/Jackett/Indexers/TorrentHeaven.cs b/src/Jackett.Common/Indexers/TorrentHeaven.cs similarity index 99% rename from src/Jackett/Indexers/TorrentHeaven.cs rename to src/Jackett.Common/Indexers/TorrentHeaven.cs index 7bb7c8cf6..f2968ab2b 100644 --- a/src/Jackett/Indexers/TorrentHeaven.cs +++ b/src/Jackett.Common/Indexers/TorrentHeaven.cs @@ -29,7 +29,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public TorrentHeaven(IIndexerConfigurationService configService, IWebClient wc, Logger l, IProtectionService ps) + public TorrentHeaven(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps) : base(name: "TorrentHeaven", description: "A German general tracker.", link: "https://torrentheaven.myfqdn.info/", diff --git a/src/Jackett/Indexers/TorrentLeech.cs b/src/Jackett.Common/Indexers/TorrentLeech.cs similarity index 97% rename from src/Jackett/Indexers/TorrentLeech.cs rename to src/Jackett.Common/Indexers/TorrentLeech.cs index 09519394c..0a51debdd 100644 --- a/src/Jackett/Indexers/TorrentLeech.cs +++ b/src/Jackett.Common/Indexers/TorrentLeech.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; +using System.Net; using System.Text; using System.Threading.Tasks; using System.Web; @@ -27,7 +28,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public TorrentLeech(IIndexerConfigurationService configService, IWebClient wc, Logger l, IProtectionService ps) + public TorrentLeech(IIndexerConfigurationService configService, Utils.Clients.WebClient wc, Logger l, IProtectionService ps) : base(name: "TorrentLeech", description: "This is what happens when you seed", link: "https://www.torrentleech.org/", @@ -125,9 +126,9 @@ namespace Jackett.Indexers if (!string.IsNullOrWhiteSpace(searchString)) { - searchUrl += "query/" + HttpUtility.UrlEncode(searchString) + "/"; + searchUrl += "query/" + WebUtility.UrlEncode(searchString) + "/"; } - string.Format(SearchUrl, HttpUtility.UrlEncode(searchString)); + string.Format(SearchUrl, WebUtility.UrlEncode(searchString)); var cats = MapTorznabCapsToTrackers(query); if (cats.Count > 0) diff --git a/src/Jackett/Indexers/TorrentNetwork.cs b/src/Jackett.Common/Indexers/TorrentNetwork.cs similarity index 98% rename from src/Jackett/Indexers/TorrentNetwork.cs rename to src/Jackett.Common/Indexers/TorrentNetwork.cs index e4a64b109..036f343b3 100644 --- a/src/Jackett/Indexers/TorrentNetwork.cs +++ b/src/Jackett.Common/Indexers/TorrentNetwork.cs @@ -31,7 +31,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public TorrentNetwork(IIndexerConfigurationService configService, IWebClient wc, Logger l, IProtectionService ps) + public TorrentNetwork(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps) : base(name: "Torrent Network", description: "Torrent Network (TN) is a GERMAN Private site for TV / MOVIES / GENERAL", link: "https://tntracker.org/", @@ -42,7 +42,7 @@ namespace Jackett.Indexers p: ps, configData: new ConfigurationDataBasicLoginWithRSSAndDisplay()) { - Encoding = Encoding.GetEncoding("UTF-8"); + Encoding = Encoding.UTF8; Language = "de-de"; Type = "private"; diff --git a/src/Jackett/Indexers/TorrentSyndikat.cs b/src/Jackett.Common/Indexers/TorrentSyndikat.cs similarity index 99% rename from src/Jackett/Indexers/TorrentSyndikat.cs rename to src/Jackett.Common/Indexers/TorrentSyndikat.cs index bbe894cf9..0ff54a2a4 100644 --- a/src/Jackett/Indexers/TorrentSyndikat.cs +++ b/src/Jackett.Common/Indexers/TorrentSyndikat.cs @@ -30,7 +30,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public TorrentSyndikat(IIndexerConfigurationService configService, IWebClient w, Logger l, IProtectionService ps) + public TorrentSyndikat(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps) : base(name: "Torrent-Syndikat", description: "A German general tracker", link: "https://torrent-syndikat.org/", @@ -41,7 +41,7 @@ namespace Jackett.Indexers p: ps, configData: new ConfigurationDataBasicLoginWithRSSAndDisplay()) { - Encoding = Encoding.GetEncoding("UTF-8"); + Encoding = Encoding.UTF8; Language = "de-de"; Type = "private"; diff --git a/src/Jackett/Indexers/Torrentech.cs b/src/Jackett.Common/Indexers/Torrentech.cs similarity index 96% rename from src/Jackett/Indexers/Torrentech.cs rename to src/Jackett.Common/Indexers/Torrentech.cs index 034b4096d..c9d8553c1 100644 --- a/src/Jackett/Indexers/Torrentech.cs +++ b/src/Jackett.Common/Indexers/Torrentech.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; using System.Collections.Specialized; +using System.Linq; +using System.Net; using System.Text; using System.Threading.Tasks; using System.Web; @@ -11,6 +13,7 @@ using Jackett.Models.IndexerConfig; using Jackett.Services.Interfaces; using Jackett.Utils; using Jackett.Utils.Clients; +using Microsoft.AspNetCore.WebUtilities; using Newtonsoft.Json.Linq; using NLog; @@ -27,7 +30,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public Torrentech(IIndexerConfigurationService configService, IWebClient wc, Logger l, IProtectionService ps) + public Torrentech(IIndexerConfigurationService configService, Utils.Clients.WebClient wc, Logger l, IProtectionService ps) : base(name: "Torrentech", description: "TorrenTech (TTH) is a Private Torrent Tracker for ELECTRONIC MUSIC", link: "https://www.torrentech.org/", @@ -133,7 +136,7 @@ namespace Jackett.Indexers release.DownloadVolumeFactor = 1; release.UploadVolumeFactor = 1; - var id = HttpUtility.ParseQueryString(release.Comments.Query).Get("showtopic"); + var id = QueryHelpers.ParseQuery(release.Comments.Query)["showtopic"].FirstOrDefault(); var desc = Row.QuerySelector("span.desc"); var forange = desc.QuerySelector("font.forange"); @@ -163,7 +166,7 @@ namespace Jackett.Indexers release.Description += e.TextContent + "\n"; } } - release.Description = HttpUtility.HtmlEncode(release.Description.Trim()); + release.Description = WebUtility.HtmlEncode(release.Description.Trim()); release.Description = release.Description.Replace("\n", "
"); if (format.Contains("MP3")) diff --git a/src/Jackett/Indexers/TransmitheNet.cs b/src/Jackett.Common/Indexers/TransmitheNet.cs similarity index 97% rename from src/Jackett/Indexers/TransmitheNet.cs rename to src/Jackett.Common/Indexers/TransmitheNet.cs index 8bd24d646..adb90d76f 100644 --- a/src/Jackett/Indexers/TransmitheNet.cs +++ b/src/Jackett.Common/Indexers/TransmitheNet.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Globalization; +using System.Net; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; @@ -27,7 +28,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public TransmitheNet(IIndexerConfigurationService configService, IWebClient c, Logger l, IProtectionService ps) + public TransmitheNet(IIndexerConfigurationService configService, Utils.Clients.WebClient c, Logger l, IProtectionService ps) : base(name: "Nebulance", description: " At Nebulance we will change the way you think about TV", link: "https://nebulance.io/", @@ -38,7 +39,7 @@ namespace Jackett.Indexers p: ps, configData: new ConfigurationDataBasicLogin("For best results, change the 'Torrents per page' setting to 100 in your profile on the NBL webpage.")) { - Encoding = Encoding.GetEncoding("UTF-8"); + Encoding = Encoding.UTF8; Language = "en-us"; Type = "private"; } @@ -88,7 +89,7 @@ namespace Jackett.Indexers Url = SearchUrl; else { - Url = $"{SearchUrl}&searchtext={HttpUtility.UrlEncode(query.GetQueryString())}"; + Url = $"{SearchUrl}&searchtext={WebUtility.UrlEncode(query.GetQueryString())}"; } var response = await RequestStringWithCookiesAndRetry(Url); diff --git a/src/Jackett/Indexers/WiHD.cs b/src/Jackett.Common/Indexers/WiHD.cs similarity index 99% rename from src/Jackett/Indexers/WiHD.cs rename to src/Jackett.Common/Indexers/WiHD.cs index bb5092373..5616279e3 100644 --- a/src/Jackett/Indexers/WiHD.cs +++ b/src/Jackett.Common/Indexers/WiHD.cs @@ -41,7 +41,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public WiHD(IIndexerConfigurationService configService, IWebClient w, Logger l, IProtectionService ps) + public WiHD(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps) : base( name: "WiHD", description: "Your World in High Definition", @@ -804,7 +804,7 @@ namespace Jackett.Indexers goto case "debug"; case "debug": // Only if Debug Level Enabled on Jackett - if (Engine.Logger.IsDebugEnabled) + if (logger.IsDebugEnabled) { logger.Debug(message); } diff --git a/src/Jackett/Indexers/XSpeeds.cs b/src/Jackett.Common/Indexers/XSpeeds.cs similarity index 99% rename from src/Jackett/Indexers/XSpeeds.cs rename to src/Jackett.Common/Indexers/XSpeeds.cs index 64ed09964..290f72051 100644 --- a/src/Jackett/Indexers/XSpeeds.cs +++ b/src/Jackett.Common/Indexers/XSpeeds.cs @@ -35,7 +35,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public XSpeeds(IIndexerConfigurationService configService, IWebClient wc, Logger l, IProtectionService ps) + public XSpeeds(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps) : base(name: "XSpeeds", description: "XSpeeds (XS) is a Private Torrent Tracker for MOVIES / TV / GENERAL", link: "https://www.xspeeds.eu/", @@ -46,7 +46,7 @@ namespace Jackett.Indexers p: ps, configData: new ConfigurationDataBasicLoginWithRSSAndDisplay()) { - Encoding = Encoding.GetEncoding("UTF-8"); + Encoding = Encoding.UTF8; Language = "en-us"; Type = "private"; diff --git a/src/Jackett/Indexers/Xthor.cs b/src/Jackett.Common/Indexers/Xthor.cs similarity index 98% rename from src/Jackett/Indexers/Xthor.cs rename to src/Jackett.Common/Indexers/Xthor.cs index e42461900..4716a7e18 100644 --- a/src/Jackett/Indexers/Xthor.cs +++ b/src/Jackett.Common/Indexers/Xthor.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Collections.Specialized; using System.IO; using System.Linq; +using System.Net; using System.Reflection; using System.Text; using System.Threading.Tasks; @@ -32,7 +33,7 @@ namespace Jackett.Indexers public Dictionary EmulatedBrowserHeaders { get; } = new Dictionary(); private ConfigurationDataXthor ConfigData => (ConfigurationDataXthor)configData; - public Xthor(IIndexerConfigurationService configService, IWebClient w, Logger l, IProtectionService ps) + public Xthor(IIndexerConfigurationService configService, Utils.Clients.WebClient w, Logger l, IProtectionService ps) : base( name: "Xthor", description: "General French Private Tracker", @@ -315,7 +316,7 @@ namespace Jackett.Indexers { // Add search term // ReSharper disable once AssignNullToNotNullAttribute - parameters.Add("search", HttpUtility.UrlEncode(term)); + parameters.Add("search", WebUtility.UrlEncode(term)); } else { @@ -436,7 +437,7 @@ namespace Jackett.Indexers Output("\nQuerying tracker for results...."); // Build WebRequest for index - var myIndexRequest = new WebRequest() + var myIndexRequest = new Utils.Clients.WebRequest() { Type = RequestType.GET, Url = request, @@ -565,7 +566,7 @@ namespace Jackett.Indexers goto case "debug"; case "debug": // Only if Debug Level Enabled on Jackett - if (Engine.Logger.IsDebugEnabled) + if (logger.IsDebugEnabled) { logger.Debug(message); } diff --git a/src/Jackett/Indexers/cgpeers.cs b/src/Jackett.Common/Indexers/cgpeers.cs similarity index 94% rename from src/Jackett/Indexers/cgpeers.cs rename to src/Jackett.Common/Indexers/cgpeers.cs index 362bffa9f..343d84f56 100644 --- a/src/Jackett/Indexers/cgpeers.cs +++ b/src/Jackett.Common/Indexers/cgpeers.cs @@ -8,7 +8,7 @@ namespace Jackett.Indexers { public class CGPeers : GazelleTracker { - public CGPeers(IIndexerConfigurationService configService, IWebClient webClient, Logger logger, IProtectionService protectionService) + public CGPeers(IIndexerConfigurationService configService, WebClient webClient, Logger logger, IProtectionService protectionService) : base(name: "CGPeers", desc: "CGPeers is a Private Torrent Tracker for GRAPHICS SOFTWARE / TUTORIALS / ETC", link: "https://www.cgpeers.com/", diff --git a/src/Jackett/Indexers/myAmity.cs b/src/Jackett.Common/Indexers/myAmity.cs similarity index 98% rename from src/Jackett/Indexers/myAmity.cs rename to src/Jackett.Common/Indexers/myAmity.cs index 5e2ff881f..2a7197638 100644 --- a/src/Jackett/Indexers/myAmity.cs +++ b/src/Jackett.Common/Indexers/myAmity.cs @@ -26,7 +26,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public myAmity(IIndexerConfigurationService configService, IWebClient wc, Logger l, IProtectionService ps) + public myAmity(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps) : base(name: "myAmity", description: "A German general tracker.", link: "https://ttv2.myamity.info/", @@ -37,7 +37,7 @@ namespace Jackett.Indexers p: ps, configData: new ConfigurationDataBasicLoginWithRSSAndDisplay()) { - Encoding = Encoding.GetEncoding("UTF-8"); + Encoding = Encoding.UTF8; Language = "de-de"; Type = "private"; diff --git a/src/Jackett/Indexers/notwhatcd.cs b/src/Jackett.Common/Indexers/notwhatcd.cs similarity index 94% rename from src/Jackett/Indexers/notwhatcd.cs rename to src/Jackett.Common/Indexers/notwhatcd.cs index 6d4692377..d9f7e753e 100644 --- a/src/Jackett/Indexers/notwhatcd.cs +++ b/src/Jackett.Common/Indexers/notwhatcd.cs @@ -9,7 +9,7 @@ namespace Jackett.Indexers { public class notwhatcd : GazelleTracker { - public notwhatcd(IIndexerConfigurationService configService, IWebClient webClient, Logger logger, IProtectionService protectionService) + public notwhatcd(IIndexerConfigurationService configService, WebClient webClient, Logger logger, IProtectionService protectionService) : base(name: "notwhat.cd", desc: "A music tracker", link: "https://notwhat.cd/", diff --git a/src/Jackett/Indexers/rutracker.cs b/src/Jackett.Common/Indexers/rutracker.cs similarity index 99% rename from src/Jackett/Indexers/rutracker.cs rename to src/Jackett.Common/Indexers/rutracker.cs index aab7229d1..33d044ac7 100644 --- a/src/Jackett/Indexers/rutracker.cs +++ b/src/Jackett.Common/Indexers/rutracker.cs @@ -30,7 +30,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public RuTracker(IIndexerConfigurationService configService, IWebClient wc, Logger l, IProtectionService ps) + public RuTracker(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps) : base(name: "RuTracker", description: "RuTracker is a Semi-Private Russian torrent site with a thriving file-sharing community", link: "https://rutracker.org/", diff --git a/src/Jackett/Indexers/x264.cs b/src/Jackett.Common/Indexers/x264.cs similarity index 99% rename from src/Jackett/Indexers/x264.cs rename to src/Jackett.Common/Indexers/x264.cs index b4c4ad979..fea1ce5b5 100644 --- a/src/Jackett/Indexers/x264.cs +++ b/src/Jackett.Common/Indexers/x264.cs @@ -27,7 +27,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public x264(IIndexerConfigurationService configService, IWebClient w, Logger l, IProtectionService ps) + public x264(IIndexerConfigurationService configService, WebClient w, Logger l, IProtectionService ps) : base(name: "x264", description: "A movie/TV tracker", link: "https://x264.me/", diff --git a/src/Jackett/Indexers/yts.cs b/src/Jackett.Common/Indexers/yts.cs similarity index 98% rename from src/Jackett/Indexers/yts.cs rename to src/Jackett.Common/Indexers/yts.cs index 8bbfa63af..632ed53ee 100644 --- a/src/Jackett/Indexers/yts.cs +++ b/src/Jackett.Common/Indexers/yts.cs @@ -33,7 +33,7 @@ namespace Jackett.Indexers set { base.configData = value; } } - public Yts(IIndexerConfigurationService configService, IWebClient wc, Logger l, IProtectionService ps) + public Yts(IIndexerConfigurationService configService, WebClient wc, Logger l, IProtectionService ps) : base(name: "YTS", description: "YTS is a Public torrent site specialising in HD movies of small size", link: "https://yts.ag/", diff --git a/src/Jackett.Common/Jacket.Common.csproj b/src/Jackett.Common/Jacket.Common.csproj new file mode 100644 index 000000000..e472550e6 --- /dev/null +++ b/src/Jackett.Common/Jacket.Common.csproj @@ -0,0 +1,68 @@ + + + + netstandard2.0;net452 + + + + + + + + + + + + + + + + + + + + + + + + + + TorznabCatType.tt + True + True + + + + + + TextTemplatingFileGenerator + TorznabCatType.generated.cs + + + + + + + + + + + + + + + 1.3.6.1 + + + 1.0.0-alpha2 + + + 4.4.0 + + + 2.0.0 + + + + + diff --git a/src/Jackett.Common/JackettStartup.cs b/src/Jackett.Common/JackettStartup.cs new file mode 100644 index 000000000..72622c8d7 --- /dev/null +++ b/src/Jackett.Common/JackettStartup.cs @@ -0,0 +1,79 @@ +using System; +using System.Reflection; + +namespace Jacket.Common +{ + public class JackettStartup + { + public static bool TracingEnabled + { + get; + set; + } + + public static bool LogRequests + { + get; + set; + } + + public static string ClientOverride + { + get; + set; + } + + public static string ProxyConnection + { + get; + set; + } + + public static bool? DoSSLFix + { + get; + set; + } + + public static bool? IgnoreSslErrors + { + get; + set; + } + + public static string CustomDataFolder + { + get; + set; + } + + public static string BasePath + { + get; + set; + } + + public static bool NoRestart + { + get; + set; + } + + public static string JackettVersion + { + get + { + return Assembly.GetExecutingAssembly()?.GetName()?.Version?.ToString() ?? "Unknown Version"; + } + } + + public static bool IsWindows + { + get + { + return Environment.OSVersion.Platform == PlatformID.Win32NT; + } + } + + } +} diff --git a/src/Jackett/Models/CachedLog.cs b/src/Jackett.Common/Models/CachedLog.cs similarity index 100% rename from src/Jackett/Models/CachedLog.cs rename to src/Jackett.Common/Models/CachedLog.cs diff --git a/src/Jackett/Models/CachedQueryResult.cs b/src/Jackett.Common/Models/CachedQueryResult.cs similarity index 100% rename from src/Jackett/Models/CachedQueryResult.cs rename to src/Jackett.Common/Models/CachedQueryResult.cs diff --git a/src/Jackett/Models/CachedResult.cs b/src/Jackett.Common/Models/CachedResult.cs similarity index 100% rename from src/Jackett/Models/CachedResult.cs rename to src/Jackett.Common/Models/CachedResult.cs diff --git a/src/Jackett/Models/CategoryMapping.cs b/src/Jackett.Common/Models/CategoryMapping.cs similarity index 100% rename from src/Jackett/Models/CategoryMapping.cs rename to src/Jackett.Common/Models/CategoryMapping.cs diff --git a/src/Jackett/Models/ChannelInfo.cs b/src/Jackett.Common/Models/ChannelInfo.cs similarity index 100% rename from src/Jackett/Models/ChannelInfo.cs rename to src/Jackett.Common/Models/ChannelInfo.cs diff --git a/src/Jackett/Models/Config/ServerConfig.cs b/src/Jackett.Common/Models/Config/ServerConfig.cs similarity index 100% rename from src/Jackett/Models/Config/ServerConfig.cs rename to src/Jackett.Common/Models/Config/ServerConfig.cs diff --git a/src/Jackett/Models/DTO/ApiSearch.cs b/src/Jackett.Common/Models/DTO/ApiSearch.cs similarity index 100% rename from src/Jackett/Models/DTO/ApiSearch.cs rename to src/Jackett.Common/Models/DTO/ApiSearch.cs diff --git a/src/Jackett/Models/DTO/Config.cs b/src/Jackett.Common/Models/DTO/Config.cs similarity index 100% rename from src/Jackett/Models/DTO/Config.cs rename to src/Jackett.Common/Models/DTO/Config.cs diff --git a/src/Jackett/Models/DTO/Indexer.cs b/src/Jackett.Common/Models/DTO/Indexer.cs similarity index 98% rename from src/Jackett/Models/DTO/Indexer.cs rename to src/Jackett.Common/Models/DTO/Indexer.cs index dd992f6b9..7b4427f46 100644 --- a/src/Jackett/Models/DTO/Indexer.cs +++ b/src/Jackett.Common/Models/DTO/Indexer.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using System.Linq; -using Jackett.Controllers.V20; using Jackett.Indexers; namespace Jackett.Models.DTO diff --git a/src/Jackett/Models/DTO/ManualSearchResult.cs b/src/Jackett.Common/Models/DTO/ManualSearchResult.cs similarity index 100% rename from src/Jackett/Models/DTO/ManualSearchResult.cs rename to src/Jackett.Common/Models/DTO/ManualSearchResult.cs diff --git a/src/Jackett/Models/DTO/ServerConfig.cs b/src/Jackett.Common/Models/DTO/ServerConfig.cs similarity index 96% rename from src/Jackett/Models/DTO/ServerConfig.cs rename to src/Jackett.Common/Models/DTO/ServerConfig.cs index 3f6e103d3..8d82c7cfc 100644 --- a/src/Jackett/Models/DTO/ServerConfig.cs +++ b/src/Jackett.Common/Models/DTO/ServerConfig.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using Jacket.Common; using Jackett.Services; namespace Jackett.Models.DTO @@ -38,7 +39,7 @@ namespace Jackett.Models.DTO updatedisabled = config.UpdateDisabled; prerelease = config.UpdatePrerelease; password = string.IsNullOrEmpty(config.AdminPassword) ? string.Empty : config.AdminPassword.Substring(0, 10); - logging = Startup.TracingEnabled; + logging = JackettStartup.TracingEnabled; basepathoverride = config.BasePathOverride; omdbkey = config.OmdbApiKey; app_version = version; diff --git a/src/Jackett/Models/DTO/TorrentPotatoRequest.cs b/src/Jackett.Common/Models/DTO/TorrentPotatoRequest.cs similarity index 100% rename from src/Jackett/Models/DTO/TorrentPotatoRequest.cs rename to src/Jackett.Common/Models/DTO/TorrentPotatoRequest.cs diff --git a/src/Jackett/Models/DTO/TorrentPotatoResponse.cs b/src/Jackett.Common/Models/DTO/TorrentPotatoResponse.cs similarity index 100% rename from src/Jackett/Models/DTO/TorrentPotatoResponse.cs rename to src/Jackett.Common/Models/DTO/TorrentPotatoResponse.cs diff --git a/src/Jackett/Models/DTO/TorrentPotatoResponseItem.cs b/src/Jackett.Common/Models/DTO/TorrentPotatoResponseItem.cs similarity index 100% rename from src/Jackett/Models/DTO/TorrentPotatoResponseItem.cs rename to src/Jackett.Common/Models/DTO/TorrentPotatoResponseItem.cs diff --git a/src/Jackett/Models/DTO/TorznabRequest.cs b/src/Jackett.Common/Models/DTO/TorznabRequest.cs similarity index 100% rename from src/Jackett/Models/DTO/TorznabRequest.cs rename to src/Jackett.Common/Models/DTO/TorznabRequest.cs diff --git a/src/Jackett/Models/GitHub/Asset.cs b/src/Jackett.Common/Models/GitHub/Asset.cs similarity index 100% rename from src/Jackett/Models/GitHub/Asset.cs rename to src/Jackett.Common/Models/GitHub/Asset.cs diff --git a/src/Jackett/Models/GitHub/Release.cs b/src/Jackett.Common/Models/GitHub/Release.cs similarity index 100% rename from src/Jackett/Models/GitHub/Release.cs rename to src/Jackett.Common/Models/GitHub/Release.cs diff --git a/src/Jackett/Models/IndexerConfig/Bespoke/ConfigurationDataAbnormal.cs b/src/Jackett.Common/Models/IndexerConfig/Bespoke/ConfigurationDataAbnormal.cs similarity index 100% rename from src/Jackett/Models/IndexerConfig/Bespoke/ConfigurationDataAbnormal.cs rename to src/Jackett.Common/Models/IndexerConfig/Bespoke/ConfigurationDataAbnormal.cs diff --git a/src/Jackett/Models/IndexerConfig/Bespoke/ConfigurationDataAnimeBytes.cs b/src/Jackett.Common/Models/IndexerConfig/Bespoke/ConfigurationDataAnimeBytes.cs similarity index 100% rename from src/Jackett/Models/IndexerConfig/Bespoke/ConfigurationDataAnimeBytes.cs rename to src/Jackett.Common/Models/IndexerConfig/Bespoke/ConfigurationDataAnimeBytes.cs diff --git a/src/Jackett/Models/IndexerConfig/Bespoke/ConfigurationDataFileList.cs b/src/Jackett.Common/Models/IndexerConfig/Bespoke/ConfigurationDataFileList.cs similarity index 100% rename from src/Jackett/Models/IndexerConfig/Bespoke/ConfigurationDataFileList.cs rename to src/Jackett.Common/Models/IndexerConfig/Bespoke/ConfigurationDataFileList.cs diff --git a/src/Jackett/Models/IndexerConfig/Bespoke/ConfigurationDataNCore.cs b/src/Jackett.Common/Models/IndexerConfig/Bespoke/ConfigurationDataNCore.cs similarity index 100% rename from src/Jackett/Models/IndexerConfig/Bespoke/ConfigurationDataNCore.cs rename to src/Jackett.Common/Models/IndexerConfig/Bespoke/ConfigurationDataNCore.cs diff --git a/src/Jackett/Models/IndexerConfig/Bespoke/ConfigurationDataNorbits.cs b/src/Jackett.Common/Models/IndexerConfig/Bespoke/ConfigurationDataNorbits.cs similarity index 100% rename from src/Jackett/Models/IndexerConfig/Bespoke/ConfigurationDataNorbits.cs rename to src/Jackett.Common/Models/IndexerConfig/Bespoke/ConfigurationDataNorbits.cs diff --git a/src/Jackett/Models/IndexerConfig/Bespoke/ConfigurationDataSceneFZ.cs b/src/Jackett.Common/Models/IndexerConfig/Bespoke/ConfigurationDataSceneFZ.cs similarity index 100% rename from src/Jackett/Models/IndexerConfig/Bespoke/ConfigurationDataSceneFZ.cs rename to src/Jackett.Common/Models/IndexerConfig/Bespoke/ConfigurationDataSceneFZ.cs diff --git a/src/Jackett/Models/IndexerConfig/Bespoke/ConfigurationDataWiHD.cs b/src/Jackett.Common/Models/IndexerConfig/Bespoke/ConfigurationDataWiHD.cs similarity index 100% rename from src/Jackett/Models/IndexerConfig/Bespoke/ConfigurationDataWiHD.cs rename to src/Jackett.Common/Models/IndexerConfig/Bespoke/ConfigurationDataWiHD.cs diff --git a/src/Jackett/Models/IndexerConfig/Bespoke/ConfigurationDataXthor.cs b/src/Jackett.Common/Models/IndexerConfig/Bespoke/ConfigurationDataXthor.cs similarity index 100% rename from src/Jackett/Models/IndexerConfig/Bespoke/ConfigurationDataXthor.cs rename to src/Jackett.Common/Models/IndexerConfig/Bespoke/ConfigurationDataXthor.cs diff --git a/src/Jackett/Models/IndexerConfig/ConfigurationData.cs b/src/Jackett.Common/Models/IndexerConfig/ConfigurationData.cs similarity index 100% rename from src/Jackett/Models/IndexerConfig/ConfigurationData.cs rename to src/Jackett.Common/Models/IndexerConfig/ConfigurationData.cs diff --git a/src/Jackett/Models/IndexerConfig/ConfigurationDataAPIKey.cs b/src/Jackett.Common/Models/IndexerConfig/ConfigurationDataAPIKey.cs similarity index 100% rename from src/Jackett/Models/IndexerConfig/ConfigurationDataAPIKey.cs rename to src/Jackett.Common/Models/IndexerConfig/ConfigurationDataAPIKey.cs diff --git a/src/Jackett/Models/IndexerConfig/ConfigurationDataBasicLogin.cs b/src/Jackett.Common/Models/IndexerConfig/ConfigurationDataBasicLogin.cs similarity index 100% rename from src/Jackett/Models/IndexerConfig/ConfigurationDataBasicLogin.cs rename to src/Jackett.Common/Models/IndexerConfig/ConfigurationDataBasicLogin.cs diff --git a/src/Jackett/Models/IndexerConfig/ConfigurationDataBasicLoginWithFilter.cs b/src/Jackett.Common/Models/IndexerConfig/ConfigurationDataBasicLoginWithFilter.cs similarity index 100% rename from src/Jackett/Models/IndexerConfig/ConfigurationDataBasicLoginWithFilter.cs rename to src/Jackett.Common/Models/IndexerConfig/ConfigurationDataBasicLoginWithFilter.cs diff --git a/src/Jackett/Models/IndexerConfig/ConfigurationDataBasicLoginWithFilterAndPasskey.cs b/src/Jackett.Common/Models/IndexerConfig/ConfigurationDataBasicLoginWithFilterAndPasskey.cs similarity index 100% rename from src/Jackett/Models/IndexerConfig/ConfigurationDataBasicLoginWithFilterAndPasskey.cs rename to src/Jackett.Common/Models/IndexerConfig/ConfigurationDataBasicLoginWithFilterAndPasskey.cs diff --git a/src/Jackett/Models/IndexerConfig/ConfigurationDataBasicLoginWithRSS.cs b/src/Jackett.Common/Models/IndexerConfig/ConfigurationDataBasicLoginWithRSS.cs similarity index 100% rename from src/Jackett/Models/IndexerConfig/ConfigurationDataBasicLoginWithRSS.cs rename to src/Jackett.Common/Models/IndexerConfig/ConfigurationDataBasicLoginWithRSS.cs diff --git a/src/Jackett/Models/IndexerConfig/ConfigurationDataBasicLoginWithRSSAndDisplay.cs b/src/Jackett.Common/Models/IndexerConfig/ConfigurationDataBasicLoginWithRSSAndDisplay.cs similarity index 100% rename from src/Jackett/Models/IndexerConfig/ConfigurationDataBasicLoginWithRSSAndDisplay.cs rename to src/Jackett.Common/Models/IndexerConfig/ConfigurationDataBasicLoginWithRSSAndDisplay.cs diff --git a/src/Jackett/Models/IndexerConfig/ConfigurationDataCaptchaLogin.cs b/src/Jackett.Common/Models/IndexerConfig/ConfigurationDataCaptchaLogin.cs similarity index 100% rename from src/Jackett/Models/IndexerConfig/ConfigurationDataCaptchaLogin.cs rename to src/Jackett.Common/Models/IndexerConfig/ConfigurationDataCaptchaLogin.cs diff --git a/src/Jackett/Models/IndexerConfig/ConfigurationDataCookie.cs b/src/Jackett.Common/Models/IndexerConfig/ConfigurationDataCookie.cs similarity index 100% rename from src/Jackett/Models/IndexerConfig/ConfigurationDataCookie.cs rename to src/Jackett.Common/Models/IndexerConfig/ConfigurationDataCookie.cs diff --git a/src/Jackett/Models/IndexerConfig/ConfigurationDataLoginLink.cs b/src/Jackett.Common/Models/IndexerConfig/ConfigurationDataLoginLink.cs similarity index 100% rename from src/Jackett/Models/IndexerConfig/ConfigurationDataLoginLink.cs rename to src/Jackett.Common/Models/IndexerConfig/ConfigurationDataLoginLink.cs diff --git a/src/Jackett/Models/IndexerConfig/ConfigurationDataLoginTokin.cs b/src/Jackett.Common/Models/IndexerConfig/ConfigurationDataLoginTokin.cs similarity index 100% rename from src/Jackett/Models/IndexerConfig/ConfigurationDataLoginTokin.cs rename to src/Jackett.Common/Models/IndexerConfig/ConfigurationDataLoginTokin.cs diff --git a/src/Jackett/Models/IndexerConfig/ConfigurationDataPinNumber.cs b/src/Jackett.Common/Models/IndexerConfig/ConfigurationDataPinNumber.cs similarity index 100% rename from src/Jackett/Models/IndexerConfig/ConfigurationDataPinNumber.cs rename to src/Jackett.Common/Models/IndexerConfig/ConfigurationDataPinNumber.cs diff --git a/src/Jackett/Models/IndexerConfig/ConfigurationDataRecaptchaLogin.cs b/src/Jackett.Common/Models/IndexerConfig/ConfigurationDataRecaptchaLogin.cs similarity index 100% rename from src/Jackett/Models/IndexerConfig/ConfigurationDataRecaptchaLogin.cs rename to src/Jackett.Common/Models/IndexerConfig/ConfigurationDataRecaptchaLogin.cs diff --git a/src/Jackett/Models/IndexerConfig/ConfigurationDataUrl.cs b/src/Jackett.Common/Models/IndexerConfig/ConfigurationDataUrl.cs similarity index 100% rename from src/Jackett/Models/IndexerConfig/ConfigurationDataUrl.cs rename to src/Jackett.Common/Models/IndexerConfig/ConfigurationDataUrl.cs diff --git a/src/Jackett/Models/IndexerConfig/ConfigurationDataUserPasskey.cs b/src/Jackett.Common/Models/IndexerConfig/ConfigurationDataUserPasskey.cs similarity index 100% rename from src/Jackett/Models/IndexerConfig/ConfigurationDataUserPasskey.cs rename to src/Jackett.Common/Models/IndexerConfig/ConfigurationDataUserPasskey.cs diff --git a/src/Jackett/Models/IndexerConfig/ISerializableConfig.cs b/src/Jackett.Common/Models/IndexerConfig/ISerializableConfig.cs similarity index 100% rename from src/Jackett/Models/IndexerConfig/ISerializableConfig.cs rename to src/Jackett.Common/Models/IndexerConfig/ISerializableConfig.cs diff --git a/src/Jackett/Models/IndexerConfigurationStatus.cs b/src/Jackett.Common/Models/IndexerConfigurationStatus.cs similarity index 100% rename from src/Jackett/Models/IndexerConfigurationStatus.cs rename to src/Jackett.Common/Models/IndexerConfigurationStatus.cs diff --git a/src/Jackett/Models/IndexerDefinition.cs b/src/Jackett.Common/Models/IndexerDefinition.cs similarity index 100% rename from src/Jackett/Models/IndexerDefinition.cs rename to src/Jackett.Common/Models/IndexerDefinition.cs diff --git a/src/Jackett/Models/ReleaseInfo.cs b/src/Jackett.Common/Models/ReleaseInfo.cs similarity index 100% rename from src/Jackett/Models/ReleaseInfo.cs rename to src/Jackett.Common/Models/ReleaseInfo.cs diff --git a/src/Jackett/Models/ResultPage.cs b/src/Jackett.Common/Models/ResultPage.cs similarity index 100% rename from src/Jackett/Models/ResultPage.cs rename to src/Jackett.Common/Models/ResultPage.cs diff --git a/src/Jackett/Models/TorznabCapabilities.cs b/src/Jackett.Common/Models/TorznabCapabilities.cs similarity index 100% rename from src/Jackett/Models/TorznabCapabilities.cs rename to src/Jackett.Common/Models/TorznabCapabilities.cs diff --git a/src/Jackett/Models/TorznabCatType.cs b/src/Jackett.Common/Models/TorznabCatType.cs similarity index 100% rename from src/Jackett/Models/TorznabCatType.cs rename to src/Jackett.Common/Models/TorznabCatType.cs diff --git a/src/Jackett/Models/TorznabCatType.generated.cs b/src/Jackett.Common/Models/TorznabCatType.generated.cs similarity index 100% rename from src/Jackett/Models/TorznabCatType.generated.cs rename to src/Jackett.Common/Models/TorznabCatType.generated.cs diff --git a/src/Jackett/Models/TorznabCatType.tt b/src/Jackett.Common/Models/TorznabCatType.tt similarity index 100% rename from src/Jackett/Models/TorznabCatType.tt rename to src/Jackett.Common/Models/TorznabCatType.tt diff --git a/src/Jackett/Models/TorznabCategory.cs b/src/Jackett.Common/Models/TorznabCategory.cs similarity index 100% rename from src/Jackett/Models/TorznabCategory.cs rename to src/Jackett.Common/Models/TorznabCategory.cs diff --git a/src/Jackett/Models/TorznabQuery.cs b/src/Jackett.Common/Models/TorznabQuery.cs similarity index 100% rename from src/Jackett/Models/TorznabQuery.cs rename to src/Jackett.Common/Models/TorznabQuery.cs diff --git a/src/Jackett/Models/TrackerCache.cs b/src/Jackett.Common/Models/TrackerCache.cs similarity index 100% rename from src/Jackett/Models/TrackerCache.cs rename to src/Jackett.Common/Models/TrackerCache.cs diff --git a/src/Jackett/Models/TrackerCacheResult.cs b/src/Jackett.Common/Models/TrackerCacheResult.cs similarity index 100% rename from src/Jackett/Models/TrackerCacheResult.cs rename to src/Jackett.Common/Models/TrackerCacheResult.cs diff --git a/src/Jackett/Services/CacheService.cs b/src/Jackett.Common/Services/CacheService.cs similarity index 100% rename from src/Jackett/Services/CacheService.cs rename to src/Jackett.Common/Services/CacheService.cs diff --git a/src/Jackett/Services/ConfigurationService.cs b/src/Jackett.Common/Services/ConfigurationService.cs similarity index 81% rename from src/Jackett/Services/ConfigurationService.cs rename to src/Jackett.Common/Services/ConfigurationService.cs index 486344806..52dfbdae6 100644 --- a/src/Jackett/Services/ConfigurationService.cs +++ b/src/Jackett.Common/Services/ConfigurationService.cs @@ -1,18 +1,13 @@ using Jackett.Utils; -using Newtonsoft.Json.Linq; using NLog; using System; using System.Collections.Generic; -using System.Diagnostics; using System.IO; -using System.Linq; using System.Reflection; using System.Security.AccessControl; using System.Security.Principal; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; using Jackett.Services.Interfaces; +using Jacket.Common; namespace Jackett.Services { @@ -41,8 +36,9 @@ namespace Jackett.Services if (System.Environment.OSVersion.Platform != PlatformID.Unix) { var access = dir.GetAccessControl(); - access.AddAccessRule(new FileSystemAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), FileSystemRights.FullControl, InheritanceFlags.ObjectInherit | InheritanceFlags.ContainerInherit, PropagationFlags.None, AccessControlType.Allow)); - Directory.SetAccessControl(GetAppDataFolder(), access); + var directorySecurity = new DirectorySecurity(GetAppDataFolder(), AccessControlSections.All); + directorySecurity.AddAccessRule(new FileSystemAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), FileSystemRights.FullControl, InheritanceFlags.ObjectInherit | InheritanceFlags.ContainerInherit, PropagationFlags.None, AccessControlType.Allow)); + dir.SetAccessControl(directorySecurity); } } @@ -70,11 +66,11 @@ namespace Jackett.Services { try { - processService.StartProcessAndLog(Application.ExecutablePath, "--MigrateSettings", true); + processService.StartProcessAndLog(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath, "--MigrateSettings", true); } catch { - Engine.Logger.Error("Unable to migrate settings when not running as administrator."); + logger.Error("Unable to migrate settings when not running as administrator."); Environment.ExitCode = 1; return; } @@ -106,9 +102,9 @@ namespace Jackett.Services if (!Directory.Exists(destFolder)) { var dir = Directory.CreateDirectory(destFolder); - var access = dir.GetAccessControl(); - access.AddAccessRule(new FileSystemAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), FileSystemRights.FullControl, InheritanceFlags.ObjectInherit | InheritanceFlags.ContainerInherit, PropagationFlags.None, AccessControlType.Allow)); - Directory.SetAccessControl(destFolder, access); + var directorySecurity = new DirectorySecurity(destFolder, AccessControlSections.All); + directorySecurity.AddAccessRule(new FileSystemAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), FileSystemRights.FullControl, InheritanceFlags.ObjectInherit | InheritanceFlags.ContainerInherit, PropagationFlags.None, AccessControlType.Allow)); + dir.SetAccessControl(directorySecurity); } if (!File.Exists(destPath)) { @@ -116,9 +112,10 @@ namespace Jackett.Services // The old files were created when running as admin so make sure they are editable by normal users / services. if (System.Environment.OSVersion.Platform != PlatformID.Unix) { - var access = File.GetAccessControl(destPath); - access.AddAccessRule(new FileSystemAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), FileSystemRights.FullControl, InheritanceFlags.None, PropagationFlags.None, AccessControlType.Allow)); - File.SetAccessControl(destPath, access); + var fileInfo = new FileInfo(destFolder); + var fileSecurity = new FileSecurity(destPath, AccessControlSections.All); + fileSecurity.AddAccessRule(new FileSystemAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), FileSystemRights.FullControl, InheritanceFlags.None, PropagationFlags.None, AccessControlType.Allow)); + fileInfo.SetAccessControl(fileSecurity); } } } @@ -166,7 +163,7 @@ namespace Jackett.Services public string ApplicationFolder() { - return Path.GetDirectoryName(Application.ExecutablePath); + return Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath); } public string GetContentFolder() @@ -215,10 +212,6 @@ namespace Jackett.Services return dirs; } - public string GetVersion() - { - return Assembly.GetExecutingAssembly().GetName().Version.ToString(); - } public string GetAppDataFolder() { @@ -231,9 +224,9 @@ namespace Jackett.Services /// public static string GetAppDataFolderStatic() { - if (!string.IsNullOrWhiteSpace(Startup.CustomDataFolder)) + if (!string.IsNullOrWhiteSpace(JackettStartup.CustomDataFolder)) { - return Startup.CustomDataFolder; + return JackettStartup.CustomDataFolder; } if (System.Environment.OSVersion.Platform == PlatformID.Unix) @@ -260,5 +253,10 @@ namespace Jackett.Services { return Path.Combine(GetAppDataFolder(), "sonarr_api.json"); } + + public string GetVersion() + { + return JackettStartup.JackettVersion; + } } } diff --git a/src/Jackett/Services/ImdbResolver.cs b/src/Jackett.Common/Services/ImdbResolver.cs similarity index 90% rename from src/Jackett/Services/ImdbResolver.cs rename to src/Jackett.Common/Services/ImdbResolver.cs index 8d387c5b2..489cd1869 100644 --- a/src/Jackett/Services/ImdbResolver.cs +++ b/src/Jackett.Common/Services/ImdbResolver.cs @@ -20,7 +20,7 @@ namespace Jackett.Services public class OmdbResolver : IImdbResolver { - public OmdbResolver(IWebClient webClient, NonNull omdbApiKey) + public OmdbResolver(WebClient webClient, NonNull omdbApiKey) { WebClient = webClient; apiKey = omdbApiKey; @@ -40,7 +40,7 @@ namespace Jackett.Services return movie; } - private IWebClient WebClient; + private WebClient WebClient; private string apiKey; } } diff --git a/src/Jackett/Services/IndexerConfigurationService.cs b/src/Jackett.Common/Services/IndexerConfigurationService.cs similarity index 100% rename from src/Jackett/Services/IndexerConfigurationService.cs rename to src/Jackett.Common/Services/IndexerConfigurationService.cs diff --git a/src/Jackett/Services/IndexerManagerService.cs b/src/Jackett.Common/Services/IndexerManagerService.cs similarity index 91% rename from src/Jackett/Services/IndexerManagerService.cs rename to src/Jackett.Common/Services/IndexerManagerService.cs index ac7877794..76fa429e1 100644 --- a/src/Jackett/Services/IndexerManagerService.cs +++ b/src/Jackett.Common/Services/IndexerManagerService.cs @@ -13,6 +13,7 @@ using Jackett.Indexers.Meta; using YamlDotNet.Serialization; using YamlDotNet.Serialization.NamingConventions; using Jackett.Services.Interfaces; +using Jackett.Models.Config; namespace Jackett.Services { @@ -22,22 +23,23 @@ namespace Jackett.Services private ICacheService cacheService; private IIndexerConfigurationService configService; private IProtectionService protectionService; - private IWebClient webClient; + private WebClient webClient; private IProcessService processService; private IConfigurationService globalConfigService; - + private ServerConfig serverConfig; private Logger logger; private Dictionary indexers = new Dictionary(); private AggregateIndexer aggregateIndexer; - public IndexerManagerService(IIndexerConfigurationService config, IProtectionService protectionService, IWebClient webClient, Logger l, ICacheService cache, IProcessService processService, IConfigurationService globalConfigService) + public IndexerManagerService(IIndexerConfigurationService config, IProtectionService protectionService, WebClient webClient, Logger l, ICacheService cache, IProcessService processService, IConfigurationService globalConfigService, ServerConfig serverConfig) { configService = config; this.protectionService = protectionService; this.webClient = webClient; this.processService = processService; this.globalConfigService = globalConfigService; + this.serverConfig = serverConfig; logger = l; cacheService = cache; } @@ -60,12 +62,12 @@ namespace Jackett.Services var indexerTypes = allNonMetaInstantiatableIndexerTypes.Where(p => p.Name != "CardigannIndexer"); var ixs = indexerTypes.Select(type => { - var constructorArgumentTypes = new Type[] { typeof(IIndexerConfigurationService), typeof(IWebClient), typeof(Logger), typeof(IProtectionService) }; + var constructorArgumentTypes = new Type[] { typeof(IIndexerConfigurationService), typeof(WebClient), typeof(Logger), typeof(IProtectionService) }; var constructor = type.GetConstructor(constructorArgumentTypes); if (constructor != null) { // create own webClient instance for each indexer (seperate cookies stores, etc.) - var indexerWebClientInstance = (IWebClient)Activator.CreateInstance(webClient.GetType(), processService, logger, globalConfigService); + var indexerWebClientInstance = (WebClient)Activator.CreateInstance(webClient.GetType(), processService, logger, globalConfigService, serverConfig); var arguments = new object[] { configService, indexerWebClientInstance, logger, protectionService }; var indexer = (IIndexer)constructor.Invoke(arguments); @@ -122,7 +124,7 @@ namespace Jackett.Services try { // create own webClient instance for each indexer (seperate cookies stores, etc.) - var indexerWebClientInstance = (IWebClient)Activator.CreateInstance(webClient.GetType(), processService, logger, globalConfigService); + var indexerWebClientInstance = (WebClient)Activator.CreateInstance(webClient.GetType(), processService, logger, globalConfigService, serverConfig); IIndexer indexer = new CardigannIndexer(configService, indexerWebClientInstance, logger, protectionService, definition); configService.Load(indexer); @@ -154,7 +156,7 @@ namespace Jackett.Services public void InitAggregateIndexer() { - var omdbApiKey = Engine.Server.Config.OmdbApiKey; + var omdbApiKey = serverConfig.OmdbApiKey; IFallbackStrategyProvider fallbackStrategyProvider = null; IResultFilterProvider resultFilterProvider = null; if (!omdbApiKey.IsNullOrEmptyOrWhitespace()) diff --git a/src/Jackett/Services/Interfaces/ICacheService.cs b/src/Jackett.Common/Services/Interfaces/ICacheService.cs similarity index 100% rename from src/Jackett/Services/Interfaces/ICacheService.cs rename to src/Jackett.Common/Services/Interfaces/ICacheService.cs diff --git a/src/Jackett/Services/Interfaces/IConfigurationService.cs b/src/Jackett.Common/Services/Interfaces/IConfigurationService.cs similarity index 100% rename from src/Jackett/Services/Interfaces/IConfigurationService.cs rename to src/Jackett.Common/Services/Interfaces/IConfigurationService.cs diff --git a/src/Jackett/Services/Interfaces/IImdbResolver.cs b/src/Jackett.Common/Services/Interfaces/IImdbResolver.cs similarity index 100% rename from src/Jackett/Services/Interfaces/IImdbResolver.cs rename to src/Jackett.Common/Services/Interfaces/IImdbResolver.cs diff --git a/src/Jackett/Services/Interfaces/IIndexerConfigurationService.cs b/src/Jackett.Common/Services/Interfaces/IIndexerConfigurationService.cs similarity index 100% rename from src/Jackett/Services/Interfaces/IIndexerConfigurationService.cs rename to src/Jackett.Common/Services/Interfaces/IIndexerConfigurationService.cs diff --git a/src/Jackett/Services/Interfaces/IIndexerManagerService.cs b/src/Jackett.Common/Services/Interfaces/IIndexerManagerService.cs similarity index 100% rename from src/Jackett/Services/Interfaces/IIndexerManagerService.cs rename to src/Jackett.Common/Services/Interfaces/IIndexerManagerService.cs diff --git a/src/Jackett/Services/Interfaces/ILogCacheService.cs b/src/Jackett.Common/Services/Interfaces/ILogCacheService.cs similarity index 100% rename from src/Jackett/Services/Interfaces/ILogCacheService.cs rename to src/Jackett.Common/Services/Interfaces/ILogCacheService.cs diff --git a/src/Jackett/Services/Interfaces/IProcessService.cs b/src/Jackett.Common/Services/Interfaces/IProcessService.cs similarity index 100% rename from src/Jackett/Services/Interfaces/IProcessService.cs rename to src/Jackett.Common/Services/Interfaces/IProcessService.cs diff --git a/src/Jackett/Services/Interfaces/IProtectionService.cs b/src/Jackett.Common/Services/Interfaces/IProtectionService.cs similarity index 81% rename from src/Jackett/Services/Interfaces/IProtectionService.cs rename to src/Jackett.Common/Services/Interfaces/IProtectionService.cs index 51647cf61..c3be529ea 100644 --- a/src/Jackett/Services/Interfaces/IProtectionService.cs +++ b/src/Jackett.Common/Services/Interfaces/IProtectionService.cs @@ -2,8 +2,6 @@ { public interface IProtectionService { - byte[] InstanceKey { get; set; } - string Protect(string plainText); string UnProtect(string plainText); } diff --git a/src/Jackett/Services/Interfaces/IRunTimeService.cs b/src/Jackett.Common/Services/Interfaces/IRunTimeService.cs similarity index 100% rename from src/Jackett/Services/Interfaces/IRunTimeService.cs rename to src/Jackett.Common/Services/Interfaces/IRunTimeService.cs diff --git a/src/Jackett/Services/Interfaces/ISecuityService.cs b/src/Jackett.Common/Services/Interfaces/ISecuityService.cs similarity index 100% rename from src/Jackett/Services/Interfaces/ISecuityService.cs rename to src/Jackett.Common/Services/Interfaces/ISecuityService.cs diff --git a/src/Jackett/Services/Interfaces/ISerializeService.cs b/src/Jackett.Common/Services/Interfaces/ISerializeService.cs similarity index 100% rename from src/Jackett/Services/Interfaces/ISerializeService.cs rename to src/Jackett.Common/Services/Interfaces/ISerializeService.cs diff --git a/src/Jackett/Services/Interfaces/IServerService.cs b/src/Jackett.Common/Services/Interfaces/IServerService.cs similarity index 82% rename from src/Jackett/Services/Interfaces/IServerService.cs rename to src/Jackett.Common/Services/Interfaces/IServerService.cs index 1a72d35bb..d7c4a0d5e 100644 --- a/src/Jackett/Services/Interfaces/IServerService.cs +++ b/src/Jackett.Common/Services/Interfaces/IServerService.cs @@ -1,5 +1,4 @@ -using Jackett.Models.Config; -using System; +using System; using System.Collections.Generic; using System.Net.Http; @@ -11,8 +10,6 @@ namespace Jackett.Services.Interfaces void Start(); void Stop(); void ReserveUrls(bool doInstall = true); - ServerConfig Config { get; } - void SaveConfig(); Uri ConvertToProxyLink(Uri link, string serverUrl, string indexerId, string action = "dl", string file = "t.torrent"); string BasePath(); string GetServerUrl(HttpRequestMessage Request); diff --git a/src/Jackett/Services/Interfaces/IServiceConfigService.cs b/src/Jackett.Common/Services/Interfaces/IServiceConfigService.cs similarity index 100% rename from src/Jackett/Services/Interfaces/IServiceConfigService.cs rename to src/Jackett.Common/Services/Interfaces/IServiceConfigService.cs diff --git a/src/Jackett/Services/Interfaces/ITrayLockService.cs b/src/Jackett.Common/Services/Interfaces/ITrayLockService.cs similarity index 100% rename from src/Jackett/Services/Interfaces/ITrayLockService.cs rename to src/Jackett.Common/Services/Interfaces/ITrayLockService.cs diff --git a/src/Jackett/Services/Interfaces/IUpdateService.cs b/src/Jackett.Common/Services/Interfaces/IUpdateService.cs similarity index 100% rename from src/Jackett/Services/Interfaces/IUpdateService.cs rename to src/Jackett.Common/Services/Interfaces/IUpdateService.cs diff --git a/src/Jackett/Services/LogCacheService.cs b/src/Jackett.Common/Services/LogCacheService.cs similarity index 93% rename from src/Jackett/Services/LogCacheService.cs rename to src/Jackett.Common/Services/LogCacheService.cs index c2a7e0d4d..ff4ef6925 100644 --- a/src/Jackett/Services/LogCacheService.cs +++ b/src/Jackett.Common/Services/LogCacheService.cs @@ -12,7 +12,7 @@ namespace Jackett.Services { [Target("LogService")] - class LogCacheService: TargetWithLayout, ILogCacheService + public class LogCacheService: TargetWithLayout, ILogCacheService { private static List logs = new List(); diff --git a/src/Jackett/Services/ProcessService.cs b/src/Jackett.Common/Services/ProcessService.cs similarity index 100% rename from src/Jackett/Services/ProcessService.cs rename to src/Jackett.Common/Services/ProcessService.cs diff --git a/src/Jackett/Services/SerializeService.cs b/src/Jackett.Common/Services/SerializeService.cs similarity index 100% rename from src/Jackett/Services/SerializeService.cs rename to src/Jackett.Common/Services/SerializeService.cs diff --git a/src/Jackett/Services/SpinService.cs b/src/Jackett.Common/Services/SpinService.cs similarity index 100% rename from src/Jackett/Services/SpinService.cs rename to src/Jackett.Common/Services/SpinService.cs diff --git a/src/Jackett/Services/TrayLockService.cs b/src/Jackett.Common/Services/TrayLockService.cs similarity index 100% rename from src/Jackett/Services/TrayLockService.cs rename to src/Jackett.Common/Services/TrayLockService.cs diff --git a/src/Jackett/Services/UpdateService.cs b/src/Jackett.Common/Services/UpdateService.cs similarity index 98% rename from src/Jackett/Services/UpdateService.cs rename to src/Jackett.Common/Services/UpdateService.cs index ee8ae979d..cafb32013 100644 --- a/src/Jackett/Services/UpdateService.cs +++ b/src/Jackett.Common/Services/UpdateService.cs @@ -1,7 +1,6 @@ using ICSharpCode.SharpZipLib.GZip; using ICSharpCode.SharpZipLib.Tar; using ICSharpCode.SharpZipLib.Zip; -using Jackett.Models.Config; using Jackett.Models.GitHub; using Jackett.Utils.Clients; using Newtonsoft.Json; @@ -18,6 +17,8 @@ using System.Text; using System.Threading; using System.Threading.Tasks; using Jackett.Services.Interfaces; +using Jacket.Common; +using Jackett.Models.Config; namespace Jackett.Services { @@ -25,13 +26,13 @@ namespace Jackett.Services public class UpdateService: IUpdateService { Logger logger; - IWebClient client; + WebClient client; IConfigurationService configService; ManualResetEvent locker = new ManualResetEvent(false); ITrayLockService lockService; bool forceupdatecheck = false; - public UpdateService(Logger l, IWebClient c, IConfigurationService cfg, ITrayLockService ls) + public UpdateService(Logger l, WebClient c, IConfigurationService cfg, ITrayLockService ls) { logger = l; client = c; @@ -126,7 +127,7 @@ namespace Jackett.Services var installDir = Path.GetDirectoryName(ExePath()); var updaterPath = Path.Combine(tempDir, "Jackett", "JackettUpdater.exe"); if (updaterPath != null) - StartUpdate(updaterPath, installDir, isWindows, Startup.NoRestart); + StartUpdate(updaterPath, installDir, isWindows, JackettStartup.NoRestart); } catch (Exception e) { diff --git a/src/Jackett/Utils/BrowserUtil.cs b/src/Jackett.Common/Utils/BrowserUtil.cs similarity index 100% rename from src/Jackett/Utils/BrowserUtil.cs rename to src/Jackett.Common/Utils/BrowserUtil.cs diff --git a/src/Jackett/Utils/Clients/BaseWebResult.cs b/src/Jackett.Common/Utils/Clients/BaseWebResult.cs similarity index 100% rename from src/Jackett/Utils/Clients/BaseWebResult.cs rename to src/Jackett.Common/Utils/Clients/BaseWebResult.cs diff --git a/src/Jackett/Utils/Clients/HttpWebClient.cs b/src/Jackett.Common/Utils/Clients/HttpWebClient.cs similarity index 95% rename from src/Jackett/Utils/Clients/HttpWebClient.cs rename to src/Jackett.Common/Utils/Clients/HttpWebClient.cs index 561a61898..6a8212e67 100644 --- a/src/Jackett/Utils/Clients/HttpWebClient.cs +++ b/src/Jackett.Common/Utils/Clients/HttpWebClient.cs @@ -14,25 +14,29 @@ using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using Jackett.Services.Interfaces; +using Jacket.Common; +using Jackett.Models.Config; namespace Jackett.Utils.Clients { - public class HttpWebClient : IWebClient + public class HttpWebClient : WebClient { static protected Dictionary> trustedCertificates = new Dictionary>(); - public HttpWebClient(IProcessService p, Logger l, IConfigurationService c) + public HttpWebClient(IProcessService p, Logger l, IConfigurationService c, ServerConfig sc) : base(p: p, l: l, - c: c) + c: c, + sc: sc) { + } override public void Init() { ServicePointManager.DefaultConnectionLimit = 1000; - if (Startup.IgnoreSslErrors == true) + if (JackettStartup.IgnoreSslErrors == true) { logger.Info(string.Format("HttpWebClient: Disabling certificate validation")); ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => { return true; }; @@ -82,19 +86,19 @@ namespace Jackett.Utils.Clients } var useProxy = false; WebProxy proxyServer = null; - var proxyUrl = Engine.Server.Config.ProxyUrl; + var proxyUrl = serverConfig.ProxyUrl; if (!string.IsNullOrWhiteSpace(proxyUrl)) { - if (Engine.Server.Config.ProxyPort.HasValue) + if (serverConfig.ProxyPort.HasValue) { - proxyServer = new WebProxy(proxyUrl, Engine.Server.Config.ProxyPort.Value); + proxyServer = new WebProxy(proxyUrl, serverConfig.ProxyPort.Value); } else { proxyServer = new WebProxy(proxyUrl); } - var username = Engine.Server.Config.ProxyUsername; - var password = Engine.Server.Config.ProxyPassword; + var username = serverConfig.ProxyUsername; + var password = serverConfig.ProxyPassword; if (!string.IsNullOrWhiteSpace(username) && !string.IsNullOrWhiteSpace(password)) { var creds = new NetworkCredential(username, password); diff --git a/src/Jackett/Utils/Clients/HttpWebClient2.cs b/src/Jackett.Common/Utils/Clients/HttpWebClient2.cs similarity index 95% rename from src/Jackett/Utils/Clients/HttpWebClient2.cs rename to src/Jackett.Common/Utils/Clients/HttpWebClient2.cs index f14ec15ee..3e11f31ba 100644 --- a/src/Jackett/Utils/Clients/HttpWebClient2.cs +++ b/src/Jackett.Common/Utils/Clients/HttpWebClient2.cs @@ -15,12 +15,14 @@ using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using Jackett.Services.Interfaces; +using Jacket.Common; +using Jackett.Models.Config; namespace Jackett.Utils.Clients { // Compared to HttpWebClient this implementation will reuse the HttpClient instance (one per indexer). // This should improve performance and avoid problems with too man open file handles. - public class HttpWebClient2 : IWebClient + public class HttpWebClient2 : WebClient { CookieContainer cookies; ClearanceHandler clearanceHandlr; @@ -29,27 +31,29 @@ namespace Jackett.Utils.Clients static protected Dictionary> trustedCertificates = new Dictionary>(); - public HttpWebClient2(IProcessService p, Logger l, IConfigurationService c) + public HttpWebClient2(IProcessService p, Logger l, IConfigurationService c, ServerConfig sc) : base(p: p, l: l, - c: c) + c: c, + sc: sc) { + cookies = new CookieContainer(); var useProxy = false; WebProxy proxyServer = null; - var proxyUrl = Engine.Server.Config.ProxyUrl; + var proxyUrl = serverConfig.ProxyUrl; if (!string.IsNullOrWhiteSpace(proxyUrl)) { - if (Engine.Server.Config.ProxyPort.HasValue) + if (serverConfig.ProxyPort.HasValue) { - proxyServer = new WebProxy(proxyUrl, Engine.Server.Config.ProxyPort.Value); + proxyServer = new WebProxy(proxyUrl, serverConfig.ProxyPort.Value); } else { proxyServer = new WebProxy(proxyUrl); } - var username = Engine.Server.Config.ProxyUsername; - var password = Engine.Server.Config.ProxyPassword; + var username = serverConfig.ProxyUsername; + var password = serverConfig.ProxyPassword; if (!string.IsNullOrWhiteSpace(username) && !string.IsNullOrWhiteSpace(password)) { var creds = new NetworkCredential(username, password); @@ -76,7 +80,7 @@ namespace Jackett.Utils.Clients override public void Init() { - if (Startup.IgnoreSslErrors == true) + if (JackettStartup.IgnoreSslErrors == true) { logger.Info(string.Format("HttpWebClient2: Disabling certificate validation")); ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => { return true; }; diff --git a/src/Jackett/Utils/Clients/UnixLibCurlWebClient.cs b/src/Jackett.Common/Utils/Clients/UnixLibCurlWebClient.cs similarity index 88% rename from src/Jackett/Utils/Clients/UnixLibCurlWebClient.cs rename to src/Jackett.Common/Utils/Clients/UnixLibCurlWebClient.cs index 81e5a079e..0b7469f28 100644 --- a/src/Jackett/Utils/Clients/UnixLibCurlWebClient.cs +++ b/src/Jackett.Common/Utils/Clients/UnixLibCurlWebClient.cs @@ -13,15 +13,18 @@ using System.Text; using System.Threading.Tasks; using CloudFlareUtilities; using Jackett.Services.Interfaces; +using Jacket.Common; +using Jackett.Models.Config; namespace Jackett.Utils.Clients { - public class UnixLibCurlWebClient : IWebClient + public class UnixLibCurlWebClient : WebClient { - public UnixLibCurlWebClient(IProcessService p, Logger l, IConfigurationService c) + public UnixLibCurlWebClient(IProcessService p, Logger l, IConfigurationService c, ServerConfig sc) : base(p: p, l: l, - c: c) + c: c, + sc: sc) { } @@ -36,27 +39,27 @@ namespace Jackett.Utils.Clients { try { - Engine.Logger.Info("LibCurl init " + Curl.GlobalInit(CurlInitFlag.All).ToString()); + logger.Info("LibCurl init " + Curl.GlobalInit(CurlInitFlag.All).ToString()); CurlHelper.OnErrorMessage += (msg) => { - Engine.Logger.Error(msg); + logger.Error(msg); }; } catch (Exception e) { - Engine.Logger.Warn("Libcurl failed to initalize. Did you install it?"); - Engine.Logger.Warn("Debian: apt-get install libcurl4-openssl-dev"); - Engine.Logger.Warn("Redhat: yum install libcurl-devel"); + logger.Warn("Libcurl failed to initalize. Did you install it?"); + logger.Warn("Debian: apt-get install libcurl4-openssl-dev"); + logger.Warn("Redhat: yum install libcurl-devel"); throw e; } var version = Curl.Version; - Engine.Logger.Info("LibCurl version " + version); + logger.Info("LibCurl version " + version); - if (!Startup.DoSSLFix.HasValue && version.IndexOf("NSS") > -1) + if (!JackettStartup.DoSSLFix.HasValue && version.IndexOf("NSS") > -1) { - Engine.Logger.Info("NSS Detected SSL ECC workaround enabled."); - Startup.DoSSLFix = true; + logger.Info("NSS Detected SSL ECC workaround enabled."); + JackettStartup.DoSSLFix = true; } } diff --git a/src/Jackett/Utils/Clients/UnixSafeCurlWebClient.cs b/src/Jackett.Common/Utils/Clients/UnixSafeCurlWebClient.cs similarity index 93% rename from src/Jackett/Utils/Clients/UnixSafeCurlWebClient.cs rename to src/Jackett.Common/Utils/Clients/UnixSafeCurlWebClient.cs index 016492f0e..4159a3757 100644 --- a/src/Jackett/Utils/Clients/UnixSafeCurlWebClient.cs +++ b/src/Jackett.Common/Utils/Clients/UnixSafeCurlWebClient.cs @@ -12,16 +12,20 @@ using System.Net.Http; using System.Text; using System.Threading.Tasks; using Jackett.Services.Interfaces; +using Jacket.Common; +using Jackett.Models.Config; namespace Jackett.Utils.Clients { - public class UnixSafeCurlWebClient : IWebClient + public class UnixSafeCurlWebClient : WebClient { - public UnixSafeCurlWebClient(IProcessService p, Logger l, IConfigurationService c) + public UnixSafeCurlWebClient(IProcessService p, Logger l, IConfigurationService c, ServerConfig sc) : base(p: p, l: l, - c: c) + c: c, + sc: sc) { + } override public void Init() @@ -31,9 +35,9 @@ namespace Jackett.Utils.Clients override protected async Task Run(WebRequest request) { var args = new StringBuilder(); - if (Engine.Server.Config.Proxy != null) + if (serverConfig.Proxy != null) { - args.AppendFormat("-x '" + Engine.Server.Config.Proxy + "' "); + args.AppendFormat("-x '" + serverConfig.Proxy + "' "); } args.AppendFormat("--url \"{0}\" ", request.Url); @@ -66,13 +70,13 @@ namespace Jackett.Utils.Clients var tempFile = Path.GetTempFileName(); args.AppendFormat("--output \"{0}\" ", tempFile); - if (Startup.DoSSLFix == true) + if (JackettStartup.DoSSLFix == true) { // http://stackoverflow.com/questions/31107851/how-to-fix-curl-35-cannot-communicate-securely-with-peer-no-common-encryptio // https://git.fedorahosted.org/cgit/mod_nss.git/plain/docs/mod_nss.html args.Append("--cipher " + SSLFix.CipherList); } - if (Startup.IgnoreSslErrors == true) + if (JackettStartup.IgnoreSslErrors == true) { args.Append("-k "); } @@ -92,7 +96,7 @@ namespace Jackett.Utils.Clients if (headSplit < 0) throw new Exception("Invalid response"); var headers = stdout.Substring(0, headSplit); - if (Startup.ProxyConnection != null) + if (JackettStartup.ProxyConnection != null) { // the proxy provided headers too so we need to split headers again var headSplit1 = stdout.IndexOf("\r\n\r\n",headSplit + 4); diff --git a/src/Jackett/Utils/Clients/WebByteResult.cs b/src/Jackett.Common/Utils/Clients/WebByteResult.cs similarity index 100% rename from src/Jackett/Utils/Clients/WebByteResult.cs rename to src/Jackett.Common/Utils/Clients/WebByteResult.cs diff --git a/src/Jackett/Utils/Clients/IWebClient.cs b/src/Jackett.Common/Utils/Clients/WebClient.cs similarity index 96% rename from src/Jackett/Utils/Clients/IWebClient.cs rename to src/Jackett.Common/Utils/Clients/WebClient.cs index c4eea8145..5bb89b2b2 100644 --- a/src/Jackett/Utils/Clients/IWebClient.cs +++ b/src/Jackett.Common/Utils/Clients/WebClient.cs @@ -9,13 +9,15 @@ using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using Jackett.Services.Interfaces; +using Jackett.Models.Config; namespace Jackett.Utils.Clients { - public abstract class IWebClient + public abstract class WebClient { protected Logger logger; protected IConfigurationService configService; + protected readonly ServerConfig serverConfig; protected IProcessService processService; protected DateTime lastRequest = DateTime.MinValue; protected TimeSpan requestDelayTimeSpan; @@ -34,11 +36,12 @@ namespace Jackett.Utils.Clients // not implemented by default } - public IWebClient(IProcessService p, Logger l, IConfigurationService c) + public WebClient(IProcessService p, Logger l, IConfigurationService c, ServerConfig sc) { processService = p; logger = l; configService = c; + serverConfig = sc; } async protected Task DelayRequest(WebRequest request) diff --git a/src/Jackett/Utils/Clients/WebClientResult.cs b/src/Jackett.Common/Utils/Clients/WebClientResult.cs similarity index 100% rename from src/Jackett/Utils/Clients/WebClientResult.cs rename to src/Jackett.Common/Utils/Clients/WebClientResult.cs diff --git a/src/Jackett/Utils/Clients/WebRequest.cs b/src/Jackett.Common/Utils/Clients/WebRequest.cs similarity index 100% rename from src/Jackett/Utils/Clients/WebRequest.cs rename to src/Jackett.Common/Utils/Clients/WebRequest.cs diff --git a/src/Jackett/Utils/DataUrl.cs b/src/Jackett.Common/Utils/DataUrl.cs similarity index 89% rename from src/Jackett/Utils/DataUrl.cs rename to src/Jackett.Common/Utils/DataUrl.cs index f77fbc181..8c9251752 100644 --- a/src/Jackett/Utils/DataUrl.cs +++ b/src/Jackett.Common/Utils/DataUrl.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Web; +using MimeMapping; namespace Jackett.Utils { @@ -12,7 +13,7 @@ namespace Jackett.Utils { public static string ReadFileToDataUrl(string file) { - string mime = MimeMapping.GetMimeMapping(file); + string mime = MimeUtility.GetMimeMapping(file); return "data:" + mime + ";base64," + Convert.ToBase64String(File.ReadAllBytes(file)); } diff --git a/src/Jackett/Utils/DateTimeUtil.cs b/src/Jackett.Common/Utils/DateTimeUtil.cs similarity index 100% rename from src/Jackett/Utils/DateTimeUtil.cs rename to src/Jackett.Common/Utils/DateTimeUtil.cs diff --git a/src/Jackett/Utils/Extensions.cs b/src/Jackett.Common/Utils/Extensions.cs similarity index 100% rename from src/Jackett/Utils/Extensions.cs rename to src/Jackett.Common/Utils/Extensions.cs diff --git a/src/Jackett/Utils/JsonContent.cs b/src/Jackett.Common/Utils/JsonContent.cs similarity index 100% rename from src/Jackett/Utils/JsonContent.cs rename to src/Jackett.Common/Utils/JsonContent.cs diff --git a/src/Jackett/Utils/JsonUtil.cs b/src/Jackett.Common/Utils/JsonUtil.cs similarity index 100% rename from src/Jackett/Utils/JsonUtil.cs rename to src/Jackett.Common/Utils/JsonUtil.cs diff --git a/src/Jackett/Utils/ParseUtil.cs b/src/Jackett.Common/Utils/ParseUtil.cs similarity index 96% rename from src/Jackett/Utils/ParseUtil.cs rename to src/Jackett.Common/Utils/ParseUtil.cs index af2774df7..d3f5fc52d 100644 --- a/src/Jackett/Utils/ParseUtil.cs +++ b/src/Jackett.Common/Utils/ParseUtil.cs @@ -1,6 +1,8 @@ using System.Globalization; +using System.Linq; using System.Text.RegularExpressions; using System.Web; +using Microsoft.AspNetCore.WebUtilities; namespace Jackett.Utils { @@ -81,8 +83,8 @@ namespace Jackett.Utils return null; var qsStr = url.Split(new char[] { '?' }, 2)[1]; qsStr = qsStr.Split(new char[] { '#' }, 2)[0]; - var qs = HttpUtility.ParseQueryString(qsStr); - return qs.Get(argument); + var qs = QueryHelpers.ParseQuery(qsStr); + return qs[argument].FirstOrDefault(); } public static long? GetLongFromString(string str) diff --git a/src/Jackett/Utils/ServerUtil.cs b/src/Jackett.Common/Utils/ServerUtil.cs similarity index 100% rename from src/Jackett/Utils/ServerUtil.cs rename to src/Jackett.Common/Utils/ServerUtil.cs diff --git a/src/Jackett/Utils/StringCipher.cs b/src/Jackett.Common/Utils/StringCipher.cs similarity index 100% rename from src/Jackett/Utils/StringCipher.cs rename to src/Jackett.Common/Utils/StringCipher.cs diff --git a/src/Jackett/Utils/StringUtil.cs b/src/Jackett.Common/Utils/StringUtil.cs similarity index 97% rename from src/Jackett/Utils/StringUtil.cs rename to src/Jackett.Common/Utils/StringUtil.cs index 7ffda6c99..720b12ef6 100644 --- a/src/Jackett/Utils/StringUtil.cs +++ b/src/Jackett.Common/Utils/StringUtil.cs @@ -12,6 +12,8 @@ using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Web; +using System.Net; +using Jacket.Common.Helpers; namespace Jackett.Utils { @@ -156,14 +158,14 @@ namespace Jackett.Utils { if (encoding == null) encoding = Encoding.UTF8; - return string.Join("&", collection.AllKeys.Select(a => a + "=" + HttpUtility.UrlEncode(collection[a], encoding))); + return string.Join("&", collection.AllKeys.Select(a => a + "=" + WebUtilityHelpers.UrlEncode(collection[a], encoding))); } public static string GetQueryString(this ICollection> collection, Encoding encoding = null) { if (encoding == null) encoding = Encoding.UTF8; - return string.Join("&", collection.Select(a => a.Key + "=" + HttpUtility.UrlEncode(a.Value, encoding))); + return string.Join("&", collection.Select(a => a.Key + "=" + WebUtilityHelpers.UrlEncode(a.Value, encoding))); } public static void Add(this ICollection> collection, string key, string value) diff --git a/src/Jackett/Utils/TorznabCapsUtil.cs b/src/Jackett.Common/Utils/TorznabCapsUtil.cs similarity index 100% rename from src/Jackett/Utils/TorznabCapsUtil.cs rename to src/Jackett.Common/Utils/TorznabCapsUtil.cs diff --git a/src/Jackett/Utils/TvCategoryParser.cs b/src/Jackett.Common/Utils/TvCategoryParser.cs similarity index 100% rename from src/Jackett/Utils/TvCategoryParser.cs rename to src/Jackett.Common/Utils/TvCategoryParser.cs diff --git a/src/Jackett.Console/Jackett.Console.csproj b/src/Jackett.Console/Jackett.Console.csproj index 53473972b..77e3948c0 100644 --- a/src/Jackett.Console/Jackett.Console.csproj +++ b/src/Jackett.Console/Jackett.Console.csproj @@ -74,6 +74,10 @@ {74420a79-cc16-442c-8b1e-7c1b913844f0} CurlSharp + + {6B854A1B-9A90-49C0-BC37-9A35C75BCA73} + Jacket.Common + {e636d5f8-68b4-4903-b4ed-ccfd9c9e899f} Jackett diff --git a/src/Jackett.Console/Program.cs b/src/Jackett.Console/Program.cs index 59976e8cb..a11a3ab98 100644 --- a/src/Jackett.Console/Program.cs +++ b/src/Jackett.Console/Program.cs @@ -15,6 +15,7 @@ using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; +using Jacket.Common; namespace JackettConsole { @@ -60,25 +61,25 @@ namespace JackettConsole /* ====== Options ===== */ // SSL Fix - Startup.DoSSLFix = options.SSLFix; + JackettStartup.DoSSLFix = options.SSLFix; // Use curl if (options.Client != null) - Startup.ClientOverride = options.Client.ToLowerInvariant(); + JackettStartup.ClientOverride = options.Client.ToLowerInvariant(); // Use Proxy if (options.ProxyConnection != null) { - Startup.ProxyConnection = options.ProxyConnection.ToLowerInvariant(); - Engine.Logger.Info("Proxy enabled. " + Startup.ProxyConnection); + JackettStartup.ProxyConnection = options.ProxyConnection.ToLowerInvariant(); + Engine.Logger.Info("Proxy enabled. " + JackettStartup.ProxyConnection); } // Logging if (options.Logging) - Startup.LogRequests = true; + JackettStartup.LogRequests = true; // Tracing if (options.Tracing) - Startup.TracingEnabled = true; + JackettStartup.TracingEnabled = true; // Log after the fact as using the logger will cause the options above to be used @@ -94,7 +95,7 @@ namespace JackettConsole Engine.Logger.Info("SSL ECC workaround has been disabled."); // Ignore SSL errors on Curl - Startup.IgnoreSslErrors = options.IgnoreSslErrors; + JackettStartup.IgnoreSslErrors = options.IgnoreSslErrors; if (options.IgnoreSslErrors == true) { Engine.Logger.Info("Jackett will ignore SSL certificate errors."); @@ -103,8 +104,8 @@ namespace JackettConsole // Choose Data Folder if (!string.IsNullOrWhiteSpace(options.DataFolder)) { - Startup.CustomDataFolder = options.DataFolder.Replace("\"", string.Empty).Replace("'", string.Empty).Replace(@"\\", @"\"); - Engine.Logger.Info("Jackett Data will be stored in: " + Startup.CustomDataFolder); + JackettStartup.CustomDataFolder = options.DataFolder.Replace("\"", string.Empty).Replace("'", string.Empty).Replace(@"\\", @"\"); + Engine.Logger.Info("Jackett Data will be stored in: " + JackettStartup.CustomDataFolder); } /* ====== Actions ===== */ @@ -171,10 +172,10 @@ namespace JackettConsole // Override listen public if (options.ListenPublic || options.ListenPrivate) { - if (Engine.Server.Config.AllowExternal != options.ListenPublic) + if (Engine.ServerConfig.AllowExternal != options.ListenPublic) { Engine.Logger.Info("Overriding external access to " + options.ListenPublic); - Engine.Server.Config.AllowExternal = options.ListenPublic; + Engine.ServerConfig.AllowExternal = options.ListenPublic; if (System.Environment.OSVersion.Platform != PlatformID.Unix) { if (ServerUtil.IsUserAdministrator()) @@ -189,17 +190,17 @@ namespace JackettConsole } } - Engine.Server.SaveConfig(); + Engine.SaveServerConfig(); } } // Override port if (options.Port != 0) { - if (Engine.Server.Config.Port != options.Port) + if (Engine.ServerConfig.Port != options.Port) { Engine.Logger.Info("Overriding port to " + options.Port); - Engine.Server.Config.Port = options.Port; + Engine.ServerConfig.Port = options.Port; if (System.Environment.OSVersion.Platform != PlatformID.Unix) { if (ServerUtil.IsUserAdministrator()) @@ -214,11 +215,11 @@ namespace JackettConsole } } - Engine.Server.SaveConfig(); + Engine.SaveServerConfig(); } } - Startup.NoRestart = options.NoRestart; + JackettStartup.NoRestart = options.NoRestart; } Engine.Server.Initalize(); diff --git a/src/Jackett.Service/Jackett.Service.csproj b/src/Jackett.Service/Jackett.Service.csproj index e59b38e4e..db8095b41 100644 --- a/src/Jackett.Service/Jackett.Service.csproj +++ b/src/Jackett.Service/Jackett.Service.csproj @@ -42,6 +42,7 @@ + @@ -65,6 +66,7 @@ + @@ -77,6 +79,10 @@ {74420a79-cc16-442c-8b1e-7c1b913844f0} CurlSharp + + {6B854A1B-9A90-49C0-BC37-9A35C75BCA73} + Jacket.Common + {e636d5f8-68b4-4903-b4ed-ccfd9c9e899f} Jackett diff --git a/src/Jackett/Services/ServiceConfigService.cs b/src/Jackett.Service/ServiceConfigService.cs similarity index 100% rename from src/Jackett/Services/ServiceConfigService.cs rename to src/Jackett.Service/ServiceConfigService.cs diff --git a/src/Jackett.Test/Jackett.Test.csproj b/src/Jackett.Test/Jackett.Test.csproj index dfb8b504e..b12b41026 100644 --- a/src/Jackett.Test/Jackett.Test.csproj +++ b/src/Jackett.Test/Jackett.Test.csproj @@ -21,7 +21,7 @@ - + @@ -33,4 +33,8 @@ + + + + diff --git a/src/Jackett.Test/Services/ProtectionServiceTests.cs b/src/Jackett.Test/Services/ProtectionServiceTests.cs index 00f9449d6..5975ff8d3 100644 --- a/src/Jackett.Test/Services/ProtectionServiceTests.cs +++ b/src/Jackett.Test/Services/ProtectionServiceTests.cs @@ -7,6 +7,7 @@ using System.Text; using System.Threading.Tasks; using Autofac; using Jackett.Services.Interfaces; +using Jackett.Models.Config; namespace Jackett.Test.Services { @@ -17,8 +18,8 @@ namespace Jackett.Test.Services [Test] public void Should_be_able_to_encrypt_and_decrypt() { - var ss = TestUtil.Container.Resolve(); - ss.Config.InstanceId = "12345678"; + var ss = TestUtil.Container.Resolve(); + ss.InstanceId = "12345678"; var ps = TestUtil.Container.Resolve(); var input = "test123"; var protectedInput = ps.Protect(input); diff --git a/src/Jackett.Test/TestUtil.cs b/src/Jackett.Test/TestUtil.cs index 14a771872..f6f847e97 100644 --- a/src/Jackett.Test/TestUtil.cs +++ b/src/Jackett.Test/TestUtil.cs @@ -22,7 +22,7 @@ namespace Jackett.Test { var builder = new ContainerBuilder(); builder.RegisterModule(); - builder.RegisterType().As().SingleInstance(); + builder.RegisterType().As().SingleInstance(); builder.RegisterInstance(LogManager.GetCurrentClassLogger()).SingleInstance(); builder.RegisterType().As().SingleInstance(); testContainer = builder.Build(); @@ -48,13 +48,13 @@ namespace Jackett.Test public static void RegisterByteCall(WebRequest r, Func f) { - var client = testContainer.Resolve() as TestWebClient; + var client = testContainer.Resolve() as TestWebClient; client.RegisterByteCall(r, f); } public static void RegisterStringCall(WebRequest r, Func f) { - var client = testContainer.Resolve() as TestWebClient; + var client = testContainer.Resolve() as TestWebClient; client.RegisterStringCall(r, f); } diff --git a/src/Jackett.Test/TestWebClient.cs b/src/Jackett.Test/TestWebClient.cs index 2cb94c229..4821dfdb2 100644 --- a/src/Jackett.Test/TestWebClient.cs +++ b/src/Jackett.Test/TestWebClient.cs @@ -7,18 +7,20 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Jackett.Services.Interfaces; +using Jackett.Models.Config; namespace Jackett.Test { - public class TestWebClient : IWebClient + public class TestWebClient : WebClient { private Dictionary> byteCallbacks = new Dictionary>(); private Dictionary> stringCallbacks = new Dictionary>(); - public TestWebClient(IProcessService p, Logger l, IConfigurationService c) + public TestWebClient(IProcessService p, Logger l, IConfigurationService c, ServerConfig sc) : base(p: p, l: l, - c: c) + c: c, + sc: sc) { } diff --git a/src/Jackett.Test/WebUtilityHelpersTests.cs b/src/Jackett.Test/WebUtilityHelpersTests.cs new file mode 100644 index 000000000..ff1055df4 --- /dev/null +++ b/src/Jackett.Test/WebUtilityHelpersTests.cs @@ -0,0 +1,80 @@ +using System; +using System.Net.Http; +using System.Text; +using System.Web; +using Jacket.Common.Helpers; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Jacket.Common.Tests +{ + [TestClass] + public class WebUtilityHelpersTests + { + private readonly Encoding[] _codePagesToTest; + private readonly string[] _stringsToTest; + + public WebUtilityHelpersTests() + { + _codePagesToTest = new Encoding[]{ + Encoding.UTF8, + Encoding.ASCII, + Encoding.GetEncoding("iso-8859-1"), + Encoding.GetEncoding("windows-1255"), + Encoding.GetEncoding("windows-1252"), + Encoding.GetEncoding("windows-1251") } + ; + + _stringsToTest = new string[] + { + "Test! אני לא יודע עברית, אבל אני מאמין שזה טקסט חוקי! $ # 2 אני תוהה אם אמוג'י יהיה נתמך 🐀.", + "Å[ÉfÉBÉìÉOÇÕìÔǵÇ≠ǻǢ", + "J͖ͥͨ̑͂̄̈́ḁ̹ͧͦ͡ͅc̲̗̮͍̻͓ͤk̳̥̖͗ͭ̾͌e̖̲̟̽ț̠͕͈͓͎̱t͕͕͓̹̹ͫͧ̆͑ͤ͝ ̼͓̟̣͔̇̒T̻̺̙̣̘͔̤̅͒̈̈͛̅e̥̗̍͟s̖̬̭͈̠t̫̩͙̯̩ͣ̏̕ ̸̰̬̄̀ͧ̀S̨̻̼̜̹̼͓̺ͨ̍ͦt͇̻̺̂́̄͌͗̕r̥͈̙͙̰͈̙͗̆̽̀i͉͔̖̻̹̗̣̍ͭ̒͗n̴̻͔̹̘̱̳͈͐ͦ̃̽͐̓̂g̴͚͙̲ͩ͌̆̉̀̾" + }; + + //https://docs.microsoft.com/en-us/dotnet/api/system.text.codepagesencodingprovider?view=netcore-2.0 +#if NETCOREAPP2_0 + if (Environment.OSVersion.Platform == PlatformID.Win32NT) + { + Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); + } +#endif + } + + + + [TestMethod] + public void WebUtilityHelpers_UrlEncode_CorrectlyEncodes() + { + foreach (var encoding in _codePagesToTest) + { + foreach (var testString in _stringsToTest) + { + //Check our implementation of Decode in .NET Standard Matches the .NET Framework Version + var NETString = HttpUtility.UrlEncode(testString, encoding); + var WebUtilityString = WebUtilityHelpers.UrlEncode(testString, encoding); + //Of note is that percent encoding gives lowercase values, where NET Native uses upper case this should be okay according to RFC3986 (https://tools.ietf.org/html/rfc3986#section-2.1) + var NETDecode = HttpUtility.UrlDecode(NETString); + var WebUtilityDecode = HttpUtility.UrlDecode(WebUtilityString); + + Assert.AreEqual(NETDecode, WebUtilityDecode, $"{testString} did not match the expected decoded string with {encoding.EncodingName})"); + } + } + } + + [TestMethod] + public void WebUtilityHelpers_UrlDecode_CorrectlyDecodes() + { + foreach (var encoding in _codePagesToTest) + { + foreach (var testString in _stringsToTest) + { + //Check our implementation of Decode in .NET Standard Matches the .NET Framework Version + var encodedString = HttpUtility.UrlEncode(testString, encoding); + var NETString = HttpUtility.UrlDecode(encodedString, encoding); + var WebUtilityString = WebUtilityHelpers.UrlDecode(encodedString, encoding); + Assert.AreEqual(NETString, WebUtilityString, $"{testString} did not match the expected decoded value after encoding with {encoding.EncodingName})"); + } + } + } + } +} diff --git a/src/Jackett.Tray/Jackett.Tray.csproj b/src/Jackett.Tray/Jackett.Tray.csproj index 381d5105f..be783facf 100644 --- a/src/Jackett.Tray/Jackett.Tray.csproj +++ b/src/Jackett.Tray/Jackett.Tray.csproj @@ -99,6 +99,10 @@ + + {6B854A1B-9A90-49C0-BC37-9A35C75BCA73} + Jacket.Common + {e636d5f8-68b4-4903-b4ed-ccfd9c9e899f} Jackett diff --git a/src/Jackett.Tray/Main.cs b/src/Jackett.Tray/Main.cs index 1d677fbbe..d04886595 100644 --- a/src/Jackett.Tray/Main.cs +++ b/src/Jackett.Tray/Main.cs @@ -54,7 +54,7 @@ namespace JackettTray void toolStripMenuItemWebUI_Click(object sender, EventArgs e) { - Process.Start("http://127.0.0.1:" + Engine.Server.Config.Port); + Process.Start("http://127.0.0.1:" + Engine.ServerConfig.Port); } void toolStripMenuItemShutdown_Click(object sender, EventArgs e) diff --git a/src/Jackett.Updater/Jackett.Updater.csproj b/src/Jackett.Updater/Jackett.Updater.csproj index 7178f72c4..39f371ee0 100644 --- a/src/Jackett.Updater/Jackett.Updater.csproj +++ b/src/Jackett.Updater/Jackett.Updater.csproj @@ -67,6 +67,14 @@ + + {6B854A1B-9A90-49C0-BC37-9A35C75BCA73} + Jacket.Common + + + {bf611f7b-4658-4cb8-aa9e-0736fadaa3ba} + Jackett.Service + {e636d5f8-68b4-4903-b4ed-ccfd9c9e899f} Jackett diff --git a/src/Jackett.sln b/src/Jackett.sln index 1c0b22166..3f345befd 100644 --- a/src/Jackett.sln +++ b/src/Jackett.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.27004.2005 +VisualStudioVersion = 15.0.27004.2006 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jackett", "Jackett\Jackett.csproj", "{E636D5F8-68B4-4903-B4ED-CCFD9C9E899F}" EndProject @@ -22,12 +22,22 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jackett.Tray", "Jackett.Tra EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jackett.Updater", "Jackett.Updater\Jackett.Updater.csproj", "{A61E311A-6F8B-4497-B5E4-2EA8994C7BD8}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jackett.Test", "Jackett.Test\Jackett.Test.csproj", "{FA22C904-9F5D-4D3C-9122-3E33652E7373}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Jackett.Test", "Jackett.Test\Jackett.Test.csproj", "{FA22C904-9F5D-4D3C-9122-3E33652E7373}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Vendor", "Vendor", "{7D7FA63C-3C2C-4B56-BD93-8CD28CF44E5D}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DateTimeRoutines", "DateTimeRoutines\DateTimeRoutines.csproj", "{C28A79EE-EF81-4EEE-A7FE-EB636423C935}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{2FA9B879-5882-4B39-8D34-9EBCB82B4F2B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Jacket.Common", "Jackett.Common\Jacket.Common.csproj", "{6B854A1B-9A90-49C0-BC37-9A35C75BCA73}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".NET", ".NET", "{FF8B9A1B-AE7E-4F14-9C37-DA861D034738}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".NET Core", ".NET Core", "{6A06EC9B-AF21-4DE8-9B50-BC7E3C2C78B9}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Executables", "Executables", "{AA50F785-12B8-4669-8D4F-EAFB49258E60}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -66,13 +76,27 @@ Global {C28A79EE-EF81-4EEE-A7FE-EB636423C935}.Debug|Any CPU.Build.0 = Debug|Any CPU {C28A79EE-EF81-4EEE-A7FE-EB636423C935}.Release|Any CPU.ActiveCfg = Release|Any CPU {C28A79EE-EF81-4EEE-A7FE-EB636423C935}.Release|Any CPU.Build.0 = Release|Any CPU + {6B854A1B-9A90-49C0-BC37-9A35C75BCA73}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6B854A1B-9A90-49C0-BC37-9A35C75BCA73}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6B854A1B-9A90-49C0-BC37-9A35C75BCA73}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6B854A1B-9A90-49C0-BC37-9A35C75BCA73}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution + {E636D5F8-68B4-4903-B4ED-CCFD9C9E899F} = {FF8B9A1B-AE7E-4F14-9C37-DA861D034738} {74420A79-CC16-442C-8B1E-7C1B913844F0} = {7D7FA63C-3C2C-4B56-BD93-8CD28CF44E5D} + {4E2A81DA-E235-4A88-AD20-38AABBFBF33C} = {FF8B9A1B-AE7E-4F14-9C37-DA861D034738} + {BF611F7B-4658-4CB8-AA9E-0736FADAA3BA} = {FF8B9A1B-AE7E-4F14-9C37-DA861D034738} + {FF9025B1-EC14-4AA9-8081-9F69C5E35B63} = {FF8B9A1B-AE7E-4F14-9C37-DA861D034738} + {A61E311A-6F8B-4497-B5E4-2EA8994C7BD8} = {FF8B9A1B-AE7E-4F14-9C37-DA861D034738} + {FA22C904-9F5D-4D3C-9122-3E33652E7373} = {FF8B9A1B-AE7E-4F14-9C37-DA861D034738} + {7D7FA63C-3C2C-4B56-BD93-8CD28CF44E5D} = {2FA9B879-5882-4B39-8D34-9EBCB82B4F2B} {C28A79EE-EF81-4EEE-A7FE-EB636423C935} = {7D7FA63C-3C2C-4B56-BD93-8CD28CF44E5D} + {6B854A1B-9A90-49C0-BC37-9A35C75BCA73} = {2FA9B879-5882-4B39-8D34-9EBCB82B4F2B} + {FF8B9A1B-AE7E-4F14-9C37-DA861D034738} = {AA50F785-12B8-4669-8D4F-EAFB49258E60} + {6A06EC9B-AF21-4DE8-9B50-BC7E3C2C78B9} = {AA50F785-12B8-4669-8D4F-EAFB49258E60} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {54BC4102-8B85-49C1-BA12-257D941D1B97} diff --git a/src/Jackett/AuthenticationException.cs b/src/Jackett/AuthenticationException.cs deleted file mode 100644 index e6a387a7d..000000000 --- a/src/Jackett/AuthenticationException.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Jackett -{ - class AuthenticationException : Exception - { - } -} diff --git a/src/Jackett/Controllers/BlackholeController.cs b/src/Jackett/Controllers/BlackholeController.cs index b5d551e5b..008738bf4 100644 --- a/src/Jackett/Controllers/BlackholeController.cs +++ b/src/Jackett/Controllers/BlackholeController.cs @@ -8,6 +8,7 @@ using System.Threading.Tasks; using System.Web; using System.Web.Http; using Jackett.Services.Interfaces; +using Jackett.Models.Config; namespace Jackett.Controllers { @@ -17,14 +18,15 @@ namespace Jackett.Controllers { private Logger logger; private IIndexerManagerService indexerService; - IServerService serverService; + private readonly ServerConfig serverConfig; IProtectionService protectionService; - public BlackholeController(IIndexerManagerService i, Logger l, IServerService s, IProtectionService ps) + public BlackholeController(IIndexerManagerService i, Logger l, ServerConfig config, IProtectionService ps) { logger = l; indexerService = i; - serverService = s; + serverConfig = config; + protectionService = ps; } @@ -42,7 +44,7 @@ namespace Jackett.Controllers throw new Exception("This indexer is not configured."); } - if (serverService.Config.APIKey != jackett_apikey) + if (serverConfig.APIKey != jackett_apikey) throw new Exception("Incorrect API key"); path = Encoding.UTF8.GetString(HttpServerUtility.UrlTokenDecode(path)); @@ -50,14 +52,14 @@ namespace Jackett.Controllers var remoteFile = new Uri(path, UriKind.RelativeOrAbsolute); var downloadBytes = await indexer.Download(remoteFile); - if (string.IsNullOrWhiteSpace(Engine.Server.Config.BlackholeDir)) + if (string.IsNullOrWhiteSpace(serverConfig.BlackholeDir)) { throw new Exception("Blackhole directory not set!"); } - if (!Directory.Exists(Engine.Server.Config.BlackholeDir)) + if (!Directory.Exists(serverConfig.BlackholeDir)) { - throw new Exception("Blackhole directory does not exist: " + Engine.Server.Config.BlackholeDir); + throw new Exception("Blackhole directory does not exist: " + serverConfig.BlackholeDir); } var fileName = DateTime.Now.Ticks.ToString() + "-" + StringUtil.MakeValidFileName(indexer.DisplayName, '_', false); @@ -66,7 +68,7 @@ namespace Jackett.Controllers else fileName += "-"+StringUtil.MakeValidFileName(file, '_', false); // call MakeValidFileName() again to avoid any possibility of path traversal attacks - File.WriteAllBytes(Path.Combine(Engine.Server.Config.BlackholeDir, fileName), downloadBytes); + File.WriteAllBytes(Path.Combine(serverConfig.BlackholeDir, fileName), downloadBytes); jsonReply["result"] = "success"; } catch (Exception ex) diff --git a/src/Jackett/Controllers/DownloadController.cs b/src/Jackett/Controllers/DownloadController.cs index dc0dc0cdd..bbe6443e6 100644 --- a/src/Jackett/Controllers/DownloadController.cs +++ b/src/Jackett/Controllers/DownloadController.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using System.Web; using System.Web.Http; using BencodeNET.Parsing; +using Jackett.Models.Config; using Jackett.Services.Interfaces; using Jackett.Utils; using NLog; @@ -17,16 +18,16 @@ namespace Jackett.Controllers [JackettAPINoCache] public class DownloadController : ApiController { + private ServerConfig config; private Logger logger; - private IIndexerManagerService indexerService; - private IServerService serverService; + private IIndexerManagerService indexerService; private IProtectionService protectionService; - public DownloadController(IIndexerManagerService i, Logger l, IServerService s, IProtectionService ps) + public DownloadController(IIndexerManagerService i, Logger l, IProtectionService ps, ServerConfig serverConfig) { + config = serverConfig; logger = l; indexerService = i; - serverService = s; protectionService = ps; } @@ -46,7 +47,7 @@ namespace Jackett.Controllers path = Encoding.UTF8.GetString(HttpServerUtility.UrlTokenDecode(path)); path = protectionService.UnProtect(path); - if (serverService.Config.APIKey != jackett_apikey) + if (config.APIKey != jackett_apikey) return new HttpResponseMessage(HttpStatusCode.Unauthorized); var target = new Uri(path, UriKind.RelativeOrAbsolute); diff --git a/src/Jackett/Controllers/IndexerApiController.cs b/src/Jackett/Controllers/IndexerApiController.cs index 1934b350b..d54e3cc37 100644 --- a/src/Jackett/Controllers/IndexerApiController.cs +++ b/src/Jackett/Controllers/IndexerApiController.cs @@ -158,7 +158,7 @@ namespace Jackett.Controllers.V20 var link = result.Link; var file = StringUtil.MakeValidFileName(result.Title, '_', false) + ".torrent"; result.Link = serverService.ConvertToProxyLink(link, serverUrl, result.TrackerId, "dl", file); - if (result.Link != null && result.Link.Scheme != "magnet" && !string.IsNullOrWhiteSpace(Engine.Server.Config.BlackholeDir)) + if (result.Link != null && result.Link.Scheme != "magnet" && !string.IsNullOrWhiteSpace(Engine.ServerConfig.BlackholeDir)) result.BlackholeLink = serverService.ConvertToProxyLink(link, serverUrl, result.TrackerId, "bh", file); } diff --git a/src/Jackett/Controllers/ResultsController.cs b/src/Jackett/Controllers/ResultsController.cs index 58df84c50..2afd4b249 100644 --- a/src/Jackett/Controllers/ResultsController.cs +++ b/src/Jackett/Controllers/ResultsController.cs @@ -23,7 +23,7 @@ namespace Jackett.Controllers.V20 { public override void OnAuthorization(HttpActionContext actionContext) { - var validApiKey = Engine.Server.Config.APIKey; + var validApiKey = Engine.ServerConfig.APIKey; var queryParams = actionContext.Request.GetQueryNameValuePairs(); var queryApiKey = queryParams.Where(x => x.Key == "apikey" || x.Key == "passkey").Select(x => x.Value).FirstOrDefault(); @@ -405,7 +405,7 @@ namespace Jackett.Controllers.V20 var link = result.Link; var file = StringUtil.MakeValidFileName(result.Title, '_', false) + ".torrent"; result.Link = serverService.ConvertToProxyLink(link, serverUrl, result.TrackerId, "dl", file); - if (result.Link != null && result.Link.Scheme != "magnet" && !string.IsNullOrWhiteSpace(Engine.Server.Config.BlackholeDir)) + if (result.Link != null && result.Link.Scheme != "magnet" && !string.IsNullOrWhiteSpace(Engine.ServerConfig.BlackholeDir)) result.BlackholeLink = serverService.ConvertToProxyLink(link, serverUrl, result.TrackerId, "bh", file); } diff --git a/src/Jackett/Controllers/ServerConfigurationController.cs b/src/Jackett/Controllers/ServerConfigurationController.cs index bf9d69db7..59aa411e7 100644 --- a/src/Jackett/Controllers/ServerConfigurationController.cs +++ b/src/Jackett/Controllers/ServerConfigurationController.cs @@ -4,7 +4,9 @@ using System.IO; using System.Linq; using System.Threading; using System.Web.Http; +using Jacket.Common; using Jackett.Models; +using Jackett.Models.Config; using Jackett.Services; using Jackett.Services.Interfaces; using Jackett.Utils; @@ -17,9 +19,20 @@ namespace Jackett.Controllers.V20 [JackettAPINoCache] public class ServerConfigurationController : ApiController { - public ServerConfigurationController(IConfigurationService c, IServerService s, IProcessService p, IIndexerManagerService i, ISecuityService ss, IUpdateService u, ILogCacheService lc, Logger l) + private readonly IConfigurationService configService; + private ServerConfig serverConfig; + private IServerService serverService; + private IProcessService processService; + private IIndexerManagerService indexerService; + private ISecuityService securityService; + private IUpdateService updater; + private ILogCacheService logCache; + private Logger logger; + + public ServerConfigurationController(IConfigurationService c, IServerService s, IProcessService p, IIndexerManagerService i, ISecuityService ss, IUpdateService u, ILogCacheService lc, Logger l, ServerConfig sc) { - config = c; + configService = c; + serverConfig = sc; serverService = s; processService = p; indexerService = i; @@ -32,14 +45,14 @@ namespace Jackett.Controllers.V20 [HttpPost] public void AdminPassword([FromBody]string password) { - var oldPassword = serverService.Config.AdminPassword; + var oldPassword = serverConfig.AdminPassword; if (string.IsNullOrEmpty(password)) password = string.Empty; if (oldPassword != password) { - serverService.Config.AdminPassword = securityService.HashPassword(password); - serverService.SaveConfig(); + serverConfig.AdminPassword = securityService.HashPassword(password); + configService.SaveConfig(serverConfig); } } @@ -53,7 +66,7 @@ namespace Jackett.Controllers.V20 public Models.DTO.ServerConfig Config() { - var dto = new Models.DTO.ServerConfig(serverService.notices, serverService.Config, config.GetVersion()); + var dto = new Models.DTO.ServerConfig(serverService.notices, serverConfig, configService.GetVersion()); return dto; } @@ -61,8 +74,8 @@ namespace Jackett.Controllers.V20 [HttpPost] public void UpdateConfig([FromBody]Models.DTO.ServerConfig config) { - var originalPort = Engine.Server.Config.Port; - var originalAllowExternal = Engine.Server.Config.AllowExternal; + var originalPort = serverConfig.Port; + var originalAllowExternal = serverConfig.AllowExternal; int port = config.port; bool external = config.external; string saveDir = config.blackholedir; @@ -79,39 +92,39 @@ namespace Jackett.Controllers.V20 string omdbApiKey = config.omdbkey; - Engine.Server.Config.UpdateDisabled = updateDisabled; - Engine.Server.Config.UpdatePrerelease = preRelease; - Engine.Server.Config.BasePathOverride = basePathOverride; - Startup.BasePath = Engine.Server.BasePath(); - Engine.Server.SaveConfig(); + serverConfig.UpdateDisabled = updateDisabled; + serverConfig.UpdatePrerelease = preRelease; + serverConfig.BasePathOverride = basePathOverride; + JackettStartup.BasePath = Engine.Server.BasePath(); + configService.SaveConfig(serverConfig); Engine.SetLogLevel(logging ? LogLevel.Debug : LogLevel.Info); - Startup.TracingEnabled = logging; + JackettStartup.TracingEnabled = logging; - if (omdbApiKey != Engine.Server.Config.OmdbApiKey) + if (omdbApiKey != serverConfig.OmdbApiKey) { - Engine.Server.Config.OmdbApiKey = omdbApiKey; - Engine.Server.SaveConfig(); + serverConfig.OmdbApiKey = omdbApiKey; + configService.SaveConfig(serverConfig); // HACK indexerService.InitAggregateIndexer(); } - if (config.proxy_url != Engine.Server.Config.ProxyUrl || - config.proxy_port != Engine.Server.Config.ProxyPort || - config.proxy_username != Engine.Server.Config.ProxyUsername || - config.proxy_password != Engine.Server.Config.ProxyPassword) + if (config.proxy_url != serverConfig.ProxyUrl || + config.proxy_port != serverConfig.ProxyPort || + config.proxy_username != serverConfig.ProxyUsername || + config.proxy_password != serverConfig.ProxyPassword) { if (config.proxy_port < 1 || config.proxy_port > 65535) throw new Exception("The port you have selected is invalid, it must be below 65535."); - Engine.Server.Config.ProxyUrl = config.proxy_url; - Engine.Server.Config.ProxyPort = config.proxy_port; - Engine.Server.Config.ProxyUsername = config.proxy_username; - Engine.Server.Config.ProxyPassword = config.proxy_password; - Engine.Server.SaveConfig(); + serverConfig.ProxyUrl = config.proxy_url; + serverConfig.ProxyPort = config.proxy_port; + serverConfig.ProxyUsername = config.proxy_username; + serverConfig.ProxyPassword = config.proxy_password; + configService.SaveConfig(serverConfig); } - if (port != Engine.Server.Config.Port || external != Engine.Server.Config.AllowExternal) + if (port != serverConfig.Port || external != serverConfig.AllowExternal) { if (ServerUtil.RestrictedPorts.Contains(port)) @@ -121,9 +134,9 @@ namespace Jackett.Controllers.V20 throw new Exception("The port you have selected is invalid, it must be below 65535."); // Save port to the config so it can be picked up by the if needed when running as admin below. - Engine.Server.Config.AllowExternal = external; - Engine.Server.Config.Port = port; - Engine.Server.SaveConfig(); + serverConfig.AllowExternal = external; + serverConfig.Port = port; + configService.SaveConfig(serverConfig); // On Windows change the url reservations if (System.Environment.OSVersion.Platform != PlatformID.Unix) @@ -136,9 +149,9 @@ namespace Jackett.Controllers.V20 } catch { - Engine.Server.Config.Port = originalPort; - Engine.Server.Config.AllowExternal = originalAllowExternal; - Engine.Server.SaveConfig(); + serverConfig.Port = originalPort; + serverConfig.AllowExternal = originalAllowExternal; + configService.SaveConfig(serverConfig); throw new Exception("Failed to acquire admin permissions to reserve the new port."); } @@ -159,7 +172,7 @@ namespace Jackett.Controllers.V20 })).Start(); } - if (saveDir != Engine.Server.Config.BlackholeDir) + if (saveDir != serverConfig.BlackholeDir) { if (!string.IsNullOrEmpty(saveDir)) { @@ -169,8 +182,8 @@ namespace Jackett.Controllers.V20 } } - Engine.Server.Config.BlackholeDir = saveDir; - Engine.Server.SaveConfig(); + serverConfig.BlackholeDir = saveDir; + configService.SaveConfig(serverConfig); } } @@ -180,13 +193,6 @@ namespace Jackett.Controllers.V20 return logCache.Logs; } - private IConfigurationService config; - private IServerService serverService; - private IProcessService processService; - private IIndexerManagerService indexerService; - private ISecuityService securityService; - private IUpdateService updater; - private ILogCacheService logCache; - private Logger logger; + } } diff --git a/src/Jackett/Controllers/UIController.cs b/src/Jackett/Controllers/UIController.cs index 99e61f959..8f53c512b 100644 --- a/src/Jackett/Controllers/UIController.cs +++ b/src/Jackett/Controllers/UIController.cs @@ -6,9 +6,11 @@ using System.Net.Http.Headers; using System.Threading.Tasks; using System.Web; using System.Web.Http; +using Jackett.Models.Config; using Jackett.Services; using Jackett.Services.Interfaces; using Jackett.Utils; +using MimeMapping; using NLog; namespace Jackett.Controllers @@ -18,11 +20,16 @@ namespace Jackett.Controllers [JackettAPINoCache] public class WebUIController : ApiController { - public WebUIController(IConfigurationService config, IServerService ss, ISecuityService s, Logger l) + private IConfigurationService config; + private ServerConfig serverConfig; + private ISecuityService securityService; + private Logger logger; + + public WebUIController(IConfigurationService config, ISecuityService ss, ServerConfig s, Logger l) { this.config = config; - serverService = ss; - securityService = s; + serverConfig = s; + securityService = ss; logger = l; } @@ -32,7 +39,7 @@ namespace Jackett.Controllers var mappedPath = Path.Combine(config.GetContentFolder(), path); var stream = new FileStream(mappedPath, FileMode.Open, FileAccess.Read, FileShare.Read); result.Content = new StreamContent(stream); - result.Content.Headers.ContentType = new MediaTypeHeaderValue(MimeMapping.GetMimeMapping(mappedPath)); + result.Content.Headers.ContentType = new MediaTypeHeaderValue(MimeUtility.GetMimeMapping(mappedPath)); return result; } @@ -69,7 +76,7 @@ namespace Jackett.Controllers { var formData = await Request.Content.ReadAsFormDataAsync(); - if (formData != null && securityService.HashPassword(formData["password"]) == serverService.Config.AdminPassword) + if (formData != null && securityService.HashPassword(formData["password"]) == serverConfig.AdminPassword) { var file = GetFile("index.html"); securityService.Login(file); @@ -82,9 +89,6 @@ namespace Jackett.Controllers } } - private IConfigurationService config; - private IServerService serverService; - private ISecuityService securityService; - private Logger logger; + } } diff --git a/src/Jackett/Curl.cs b/src/Jackett/Curl.cs deleted file mode 100644 index 7870ba7f2..000000000 --- a/src/Jackett/Curl.cs +++ /dev/null @@ -1,137 +0,0 @@ -using CurlSharp; -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Linq; -using System.Net.Http; -using System.Text; -using System.Threading.Tasks; - -namespace Jackett -{ - public class CurlHelper - { - private const string ChromeUserAgent = "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36"; - - public static CurlHelper Shared = new CurlHelper(); - - private BlockingCollection curlRequests; - - public bool IsSupported { get; private set; } - - private class CurlRequest - { - public TaskCompletionSource TaskCompletion { get; private set; } - - public string Url { get; private set; } - - public string Cookies { get; private set; } - - public string Referer { get; private set; } - - public HttpMethod Method { get; private set; } - - public string PostData { get; set; } - - public CurlRequest(HttpMethod method, string url, string cookies = null, string referer = null) - { - TaskCompletion = new TaskCompletionSource(); - Method = method; - Url = url; - Cookies = cookies; - Referer = referer; - } - } - - public async Task GetStringAsync(string url, string cookies = null, string referer = null) - { - var curlRequest = new CurlRequest(HttpMethod.Get, url, cookies, referer); - curlRequests.Add(curlRequest); - var result = await curlRequest.TaskCompletion.Task; - return result; - } - - public CurlHelper() - { - try - { - Curl.GlobalInit(CurlInitFlag.All); - IsSupported = true; - } - catch (Exception ex) - { - IsSupported = false; - } - Task.Run((Action)CurlServicer); - } - - private void CurlServicer() - { - curlRequests = new BlockingCollection(); - foreach (var curlRequest in curlRequests.GetConsumingEnumerable()) - { - PerformCurl(curlRequest); - } - } - - private void PerformCurl(CurlRequest curlRequest) - { - var headerBuffers = new List(); - var contentBuffers = new List(); - try - { - using (var easy = new CurlEasy()) - { - easy.Url = curlRequest.Url; - easy.BufferSize = 64 * 1024; - //easy.Encoding = "UTF8"; - easy.WriteFunction = (byte[] buf, int size, int nmemb, object data) => - { - contentBuffers.Add(buf); - return size * nmemb; - }; - easy.HeaderFunction = (byte[] buf, int size, int nmemb, object extraData) => - { - headerBuffers.Add(buf); - return size * nmemb; - }; - - if (!string.IsNullOrEmpty(curlRequest.Cookies)) - easy.Cookie = curlRequest.Cookies; - - if (curlRequest.Method == HttpMethod.Post) - { - easy.Post = true; - easy.PostFields = curlRequest.PostData; - easy.PostFieldSize = Encoding.UTF8.GetByteCount(curlRequest.PostData); - } - - easy.Perform(); - } - - var headerBytes = Combine(headerBuffers.ToArray()); - var headerString = Encoding.UTF8.GetString(headerBytes); - - var contentBytes = Combine(contentBuffers.ToArray()); - var result = Encoding.UTF8.GetString(contentBytes); - curlRequest.TaskCompletion.SetResult(result); - } - catch (Exception ex) - { - curlRequest.TaskCompletion.TrySetException(ex); - } - } - - public static byte[] Combine(params byte[][] arrays) - { - byte[] ret = new byte[arrays.Sum(x => x.Length)]; - int offset = 0; - foreach (byte[] data in arrays) - { - Buffer.BlockCopy(data, 0, ret, offset, data.Length); - offset += data.Length; - } - return ret; - } - } -} diff --git a/src/Jackett/Definitions/mononokebt.yml b/src/Jackett/Definitions/mononokebt.yml index 4ff7484ab..759bb8476 100644 --- a/src/Jackett/Definitions/mononokebt.yml +++ b/src/Jackett/Definitions/mononokebt.yml @@ -4,7 +4,7 @@ description: "Mononoke-BT is a FRENCH Private Torrent Tracker for ANIME" language: fr-fr type: private - encoding: ISO-8859-15 + encoding: iso-8859-15 links: - http://mononoke-bt.org/ diff --git a/src/Jackett/Engine.cs b/src/Jackett/Engine.cs index 96c9fb78d..63e794613 100644 --- a/src/Jackett/Engine.cs +++ b/src/Jackett/Engine.cs @@ -13,6 +13,8 @@ using System.Threading.Tasks; using System.Web.Http.Dependencies; using Autofac.Integration.WebApi; using Jackett.Services.Interfaces; +using Jacket.Common; +using Jackett.Models.Config; namespace Jackett { @@ -34,7 +36,7 @@ namespace Jackett // Register the container in itself to allow for late resolves var secondaryBuilder = new ContainerBuilder(); - secondaryBuilder.RegisterInstance(container).SingleInstance(); + secondaryBuilder.RegisterInstance(container).SingleInstance(); SetupLogging(secondaryBuilder); secondaryBuilder.Update(container); @@ -45,13 +47,6 @@ namespace Jackett return new AutofacWebApiDependencyResolver(container); } - public static bool IsWindows - { - get - { - return Environment.OSVersion.Platform == PlatformID.Win32NT; - } - } public static IConfigurationService ConfigService { @@ -93,6 +88,14 @@ namespace Jackett } } + public static ServerConfig ServerConfig + { + get + { + return container.Resolve(); + } + } + public static IRunTimeService RunTime { get @@ -120,7 +123,7 @@ namespace Jackett public static void SetupLogging(ContainerBuilder builder = null, string logfile = "log.txt") { - var logLevel = Startup.TracingEnabled ? LogLevel.Debug : LogLevel.Info; + var logLevel = JackettStartup.TracingEnabled ? LogLevel.Debug : LogLevel.Info; // Add custom date time format renderer as the default is too long ConfigurationItemFactory.Default.LayoutRenderers.RegisterDefinition("simpledatetime", typeof(SimpleDateTimeRenderer)); @@ -180,6 +183,11 @@ namespace Jackett LogManager.ReconfigExistingLoggers(); } + + public static void SaveServerConfig() + { + ConfigService.SaveConfig(ServerConfig); + } } diff --git a/src/Jackett/Jackett.csproj b/src/Jackett/Jackett.csproj index c3aeb1c52..22beaf62b 100644 --- a/src/Jackett/Jackett.csproj +++ b/src/Jackett/Jackett.csproj @@ -73,235 +73,32 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - True - True - TorznabCatType.tt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - True True Resources.resx - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + @@ -336,9 +133,6 @@ - - Always - PreserveNewest @@ -455,10 +249,6 @@ PreserveNewest - - TextTemplatingFileGenerator - TorznabCatType.generated.cs - @@ -482,24 +272,9 @@ - - 0.9.9 - 4.0.0 - - 6.1.1 - - - 2.2.22 - - - 0.4.0-alpha - - - 1.3.5-beta5 - 5.2.3 @@ -509,24 +284,11 @@ 3.1.0 - - 5.0.0-beta11 - - - 0.86.0 - - - 4.2.2 - - - {74420a79-cc16-442c-8b1e-7c1b913844f0} - CurlSharp - - - {c28a79ee-ef81-4eee-a7fe-eb636423c935} - DateTimeRoutines + + {6b854a1b-9a90-49c0-bc37-9a35c75bca73} + Jacket.Common diff --git a/src/Jackett/JackettModule.cs b/src/Jackett/JackettModule.cs index a14c9baac..882e85cad 100644 --- a/src/Jackett/JackettModule.cs +++ b/src/Jackett/JackettModule.cs @@ -11,6 +11,11 @@ using System.Reflection; using Jackett.Services; using Jackett.Indexers.Meta; using Jackett.Services.Interfaces; +using Jacket.Common; +using Jackett.Models.Config; +using System.IO; +using Newtonsoft.Json.Linq; +using Jackett.Utils; namespace Jackett { @@ -18,100 +23,114 @@ namespace Jackett { protected override void Load(ContainerBuilder builder) { - // Just register everything! - var thisAssembly = typeof(JackettModule).Assembly; - builder.RegisterAssemblyTypes(thisAssembly) - .Except() - .Except() - .Except() - .Except() - .Except() - .Except() - .Except() - .Except() - .Except() - .Except() - .Except() - .Except() - .Except() - .Except() - .AsImplementedInterfaces().SingleInstance(); - builder.RegisterApiControllers(thisAssembly).InstancePerRequest(); + // Just register everything! TODO: Something better and more explicit than scanning everything. + var assembliesToScan = new Assembly[] { typeof(JackettModule).Assembly, typeof(JackettStartup).Assembly }; + foreach (var assembly in assembliesToScan) + { + builder.RegisterAssemblyTypes(assembly) + .Except() + .Except() + .Except() + .Except() + .Except() + .Except() + .Except() + .Except() + .Except() + .Except() + .Except() + .Except() + .Except() + .Except() + .AsImplementedInterfaces().SingleInstance(); + } + builder.RegisterApiControllers(typeof(JackettModule).Assembly).InstancePerRequest(); + builder.Register(ctx => + { + return BuildServerConfig(ctx); + }).As().SingleInstance(); builder.RegisterType(); + // Register the best web client for the platform or the override - switch (Startup.ClientOverride) + switch (JackettStartup.ClientOverride) { case "httpclient": - builder.RegisterType().As(); + builder.RegisterType().As(); break; case "httpclient2": - builder.RegisterType().As(); + builder.RegisterType().As(); break; case "safecurl": - builder.RegisterType().As(); + builder.RegisterType().As(); break; case "libcurl": - builder.RegisterType().As(); + builder.RegisterType().As(); break; case "automatic": default: - if (System.Environment.OSVersion.Platform == PlatformID.Unix) + if (System.Environment.OSVersion.Platform != PlatformID.Unix) { - var usehttpclient = false; - try - { - Type monotype = Type.GetType("Mono.Runtime"); - if (monotype != null) - { - MethodInfo displayName = monotype.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static); - if (displayName != null) - { - var monoVersion = displayName.Invoke(null, null).ToString(); - var monoVersionO = new Version(monoVersion.Split(' ')[0]); - if ((monoVersionO.Major >= 4 && monoVersionO.Minor >= 8) || monoVersionO.Major >= 5) - { - // check if btls is supported - var monoSecurity = Assembly.Load("Mono.Security"); - Type monoTlsProviderFactory = monoSecurity.GetType("Mono.Security.Interface.MonoTlsProviderFactory"); - if (monoTlsProviderFactory != null) - { - MethodInfo isProviderSupported = monoTlsProviderFactory.GetMethod("IsProviderSupported"); - if (isProviderSupported != null) - { - var btlsSupported = (bool)isProviderSupported.Invoke(null, new string[] { "btls" }); - if (btlsSupported) - { - // initialize btls - MethodInfo initialize = monoTlsProviderFactory.GetMethod("Initialize", new[] { typeof(string) }); - if (initialize != null) - { - initialize.Invoke(null, new string[] { "btls" }); - usehttpclient = true; - } - } - } - } - } - } - } - } - catch (Exception e) - { - Console.Out.WriteLine("Error while deciding which HttpWebClient to use: " + e); - } - - if (usehttpclient) - builder.RegisterType().As(); - else - builder.RegisterType().As(); + builder.RegisterType().As(); + break; } + var usehttpclient = DetectMonoCompatabilityWithHttpClient(); + if (usehttpclient) + builder.RegisterType().As(); else - { - builder.RegisterType().As(); - } + builder.RegisterType().As(); break; } + InitAutomapper(); + + } + + private static ServerConfig BuildServerConfig(IComponentContext ctx) + { + var configService = ctx.Resolve(); + // Load config + var config = configService.GetConfig(); + if (config == null) + { + config = new ServerConfig(); + } + + if (string.IsNullOrWhiteSpace(config.APIKey)) + { + // Check for legacy key config + var apiKeyFile = Path.Combine(configService.GetAppDataFolder(), "api_key.txt"); + if (File.Exists(apiKeyFile)) + { + config.APIKey = File.ReadAllText(apiKeyFile); + } + + // Check for legacy settings + + var path = Path.Combine(configService.GetAppDataFolder(), "config.json"); ; + var jsonReply = new JObject(); + if (File.Exists(path)) + { + jsonReply = JObject.Parse(File.ReadAllText(path)); + config.Port = (int)jsonReply["port"]; + config.AllowExternal = (bool)jsonReply["public"]; + } + + if (string.IsNullOrWhiteSpace(config.APIKey)) + config.APIKey = StringUtil.GenerateRandom(32); + + configService.SaveConfig(config); + } + + if (string.IsNullOrWhiteSpace(config.InstanceId)) + { + config.InstanceId = StringUtil.GenerateRandom(64); + configService.SaveConfig(config); + } + return config; + } + + private static void InitAutomapper() + { Mapper.Initialize(cfg => { cfg.CreateMap().ForMember(x => x.Content, opt => opt.Ignore()).AfterMap((be, str) => @@ -145,5 +164,55 @@ namespace Jackett }); }); } + + private static bool DetectMonoCompatabilityWithHttpClient() + { + bool usehttpclient = false; + try + { + Type monotype = Type.GetType("Mono.Runtime"); + if (monotype != null) + { + MethodInfo displayName = monotype.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static); + if (displayName != null) + { + var monoVersion = displayName.Invoke(null, null).ToString(); + var monoVersionO = new Version(monoVersion.Split(' ')[0]); + if ((monoVersionO.Major >= 4 && monoVersionO.Minor >= 8) || monoVersionO.Major >= 5) + { + // check if btls is supported + var monoSecurity = Assembly.Load("Mono.Security"); + Type monoTlsProviderFactory = monoSecurity.GetType("Mono.Security.Interface.MonoTlsProviderFactory"); + if (monoTlsProviderFactory != null) + { + MethodInfo isProviderSupported = monoTlsProviderFactory.GetMethod("IsProviderSupported"); + if (isProviderSupported != null) + { + var btlsSupported = (bool)isProviderSupported.Invoke(null, new string[] { "btls" }); + if (btlsSupported) + { + // initialize btls + MethodInfo initialize = monoTlsProviderFactory.GetMethod("Initialize", new[] { typeof(string) }); + if (initialize != null) + { + initialize.Invoke(null, new string[] { "btls" }); + usehttpclient = true; + } + } + } + } + } + } + } + } + catch (Exception e) + { + Console.Out.WriteLine("Error while deciding which HttpWebClient to use: " + e); + } + + return usehttpclient; + } + + } } diff --git a/src/Jackett/Services/ProtectionService.cs b/src/Jackett/Services/ProtectionService.cs index b096a3dee..685fd0dc1 100644 --- a/src/Jackett/Services/ProtectionService.cs +++ b/src/Jackett/Services/ProtectionService.cs @@ -8,6 +8,7 @@ using System.Text; using System.Threading.Tasks; using Jackett.Utils; using Jackett.Services.Interfaces; +using Jackett.Models.Config; namespace Jackett.Services { @@ -17,16 +18,16 @@ namespace Jackett.Services DataProtectionScope PROTECTION_SCOPE = DataProtectionScope.LocalMachine; private const string JACKETT_KEY = "JACKETT_KEY"; const string APPLICATION_KEY = "Dvz66r3n8vhTGip2/quiw5ISyM37f7L2iOdupzdKmzkvXGhAgQiWK+6F+4qpxjPVNks1qO7LdWuVqRlzgLzeW8mChC6JnBMUS1Fin4N2nS9lh4XPuCZ1che75xO92Nk2vyXUo9KSFG1hvEszAuLfG2Mcg1r0sVyVXd2gQDU/TbY="; + private byte[] _instanceKey; - public byte[] InstanceKey { get; set; } - - public ProtectionService() + public ProtectionService(ServerConfig config) { if (System.Environment.OSVersion.Platform == PlatformID.Unix) { // We should not be running as root and will only have access to the local store. PROTECTION_SCOPE = DataProtectionScope.CurrentUser; } + _instanceKey = Encoding.UTF8.GetBytes(config.InstanceId); } public string Protect(string plainText) @@ -64,7 +65,7 @@ namespace Jackett.Services var plainBytes = Encoding.UTF8.GetBytes(plainText); var appKey = Convert.FromBase64String(APPLICATION_KEY); - var instanceKey = InstanceKey; + var instanceKey = _instanceKey; var entropy = new byte[appKey.Length + instanceKey.Length]; Buffer.BlockCopy(instanceKey, 0, entropy, 0, instanceKey.Length); Buffer.BlockCopy(appKey, 0, entropy, instanceKey.Length, appKey.Length); @@ -102,7 +103,7 @@ namespace Jackett.Services return string.Empty; var protectedBytes = Convert.FromBase64String(plainText); - var instanceKey = InstanceKey; + var instanceKey = _instanceKey; using (MemoryStream ms = new MemoryStream()) { diff --git a/src/Jackett/Services/SecuityService.cs b/src/Jackett/Services/SecuityService.cs index 419b3199f..fefe88ab1 100644 --- a/src/Jackett/Services/SecuityService.cs +++ b/src/Jackett/Services/SecuityService.cs @@ -6,6 +6,7 @@ using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; using System.Web; +using Jackett.Models.Config; using Jackett.Services.Interfaces; namespace Jackett.Services @@ -14,17 +15,17 @@ namespace Jackett.Services class SecuityService : ISecuityService { private const string COOKIENAME = "JACKETT"; - private IServerService serverService; + private ServerConfig _serverConfig; - public SecuityService(IServerService ss) + public SecuityService(ServerConfig sc) { - serverService = ss; + _serverConfig = sc; } public string HashPassword(string input) { // Append key as salt - input += serverService.Config.APIKey; + input += _serverConfig.APIKey; UnicodeEncoding UE = new UnicodeEncoding(); byte[] hashValue; @@ -44,7 +45,7 @@ namespace Jackett.Services public void Login(HttpResponseMessage response) { // Login - response.Headers.Add("Set-Cookie", COOKIENAME + "=" + serverService.Config.AdminPassword + "; path=/"); + response.Headers.Add("Set-Cookie", COOKIENAME + "=" + _serverConfig.AdminPassword + "; path=/"); } public void Logout(HttpResponseMessage response) @@ -55,7 +56,7 @@ namespace Jackett.Services public bool CheckAuthorised(HttpRequestMessage request) { - if (string.IsNullOrEmpty(Engine.Server.Config.AdminPassword)) + if (string.IsNullOrEmpty(_serverConfig.AdminPassword)) return true; try @@ -63,7 +64,7 @@ namespace Jackett.Services var cookie = request.Headers.GetCookies(COOKIENAME).FirstOrDefault(); if (cookie != null) { - return cookie[COOKIENAME].Value == serverService.Config.AdminPassword; + return cookie[COOKIENAME].Value == _serverConfig.AdminPassword; } } catch { } diff --git a/src/Jackett/Services/ServerService.cs b/src/Jackett/Services/ServerService.cs index 0be30bb64..b28a562cb 100644 --- a/src/Jackett/Services/ServerService.cs +++ b/src/Jackett/Services/ServerService.cs @@ -18,14 +18,13 @@ using System.Text; using System.Threading; using System.Web; using Jackett.Services.Interfaces; +using Jacket.Common; namespace Jackett.Services { public class ServerService : IServerService { - private ServerConfig config; - private IDisposable _server = null; private IIndexerManagerService indexerService; @@ -33,12 +32,13 @@ namespace Jackett.Services private ISerializeService serializeService; private IConfigurationService configService; private Logger logger; - private IWebClient client; + private Utils.Clients.WebClient client; private IUpdateService updater; private List _notices = new List(); - IProtectionService protectionService; + private ServerConfig config; + IProtectionService _protectionService; - public ServerService(IIndexerManagerService i, IProcessService p, ISerializeService s, IConfigurationService c, Logger l, IWebClient w, IUpdateService u, IProtectionService protectionService) + public ServerService(IIndexerManagerService i, IProcessService p, ISerializeService s, IConfigurationService c, Logger l, Utils.Clients.WebClient w, IUpdateService u, IProtectionService protectionService, ServerConfig serverConfig) { indexerService = i; processService = p; @@ -47,17 +47,9 @@ namespace Jackett.Services logger = l; client = w; updater = u; - this.protectionService = protectionService; - - LoadConfig(); - // "TEMPORARY" HACK - protectionService.InstanceKey = Encoding.UTF8.GetBytes(Config.InstanceId); - } - - public ServerConfig Config - { - get { return config; } - } + config = serverConfig; + _protectionService = protectionService; + } public List notices { @@ -72,7 +64,7 @@ namespace Jackett.Services if (link == null || (link.IsAbsoluteUri && link.Scheme == "magnet")) return link; - var encryptedLink = protectionService.Protect(link.ToString()); + var encryptedLink = _protectionService.Protect(link.ToString()); var encodedLink = HttpServerUtility.UrlTokenEncode(Encoding.UTF8.GetBytes(encryptedLink)); string urlEncodedFile = WebUtility.UrlEncode(file); var proxyLink = string.Format("{0}{1}/{2}/?jackett_apikey={3}&path={4}&file={5}", serverUrl, action, indexerId, config.APIKey, encodedLink, urlEncodedFile); @@ -96,54 +88,7 @@ namespace Jackett.Services } return path; } - - private void LoadConfig() - { - // Load config - config = configService.GetConfig(); - if (config == null) - { - config = new ServerConfig(); - } - - if (string.IsNullOrWhiteSpace(config.APIKey)) - { - // Check for legacy key config - var apiKeyFile = Path.Combine(configService.GetAppDataFolder(), "api_key.txt"); - if (File.Exists(apiKeyFile)) - { - config.APIKey = File.ReadAllText(apiKeyFile); - } - - // Check for legacy settings - - var path = Path.Combine(configService.GetAppDataFolder(), "config.json"); ; - var jsonReply = new JObject(); - if (File.Exists(path)) - { - jsonReply = JObject.Parse(File.ReadAllText(path)); - config.Port = (int)jsonReply["port"]; - config.AllowExternal = (bool)jsonReply["public"]; - } - - if (string.IsNullOrWhiteSpace(config.APIKey)) - config.APIKey = StringUtil.GenerateRandom(32); - - configService.SaveConfig(config); - } - - if (string.IsNullOrWhiteSpace(config.InstanceId)) - { - config.InstanceId = StringUtil.GenerateRandom(64); - configService.SaveConfig(config); - } - } - - public void SaveConfig() - { - configService.SaveConfig(config); - } - + public void Initalize() { logger.Info("Starting Jackett " + configService.GetVersion()); @@ -293,7 +238,7 @@ namespace Jackett.Services logger.Info("Starting web server at " + config.GetListenAddresses()[0]); var startOptions = new StartOptions(); config.GetListenAddresses().ToList().ForEach(u => startOptions.Urls.Add(u)); - Startup.BasePath = BasePath(); + JackettStartup.BasePath = BasePath(); try { _server = WebApp.Start(startOptions); diff --git a/src/Jackett/Startup.cs b/src/Jackett/Startup.cs index 0ecde6775..d136e6be5 100644 --- a/src/Jackett/Startup.cs +++ b/src/Jackett/Startup.cs @@ -13,11 +13,13 @@ using System.Net.Http; using System.Threading; using System.Web.Http.Filters; using Newtonsoft.Json.Linq; +using Jacket.Common; +using System.Text; [assembly: OwinStartup(typeof(Startup))] namespace Jackett { - class ApiExceptionHandler : System.Web.Http.Filters.IExceptionFilter + class ApiExceptionHandler : IExceptionFilter { public bool AllowMultiple { @@ -94,60 +96,6 @@ namespace Jackett public class Startup { - public static bool TracingEnabled - { - get; - set; - } - - public static bool LogRequests - { - get; - set; - } - - public static string ClientOverride - { - get; - set; - } - - public static string ProxyConnection - { - get; - set; - } - - public static bool? DoSSLFix - { - get; - set; - } - - public static bool? IgnoreSslErrors - { - get; - set; - } - - public static string CustomDataFolder - { - get; - set; - } - - public static string BasePath - { - get; - set; - } - - public static bool NoRestart - { - get; - set; - } - public void Configuration(IAppBuilder appBuilder) { // Configure Web API for self-host. @@ -177,13 +125,13 @@ namespace Jackett config.Filters.Add(new ApiExceptionHandler()); // Setup tracing if enabled - if (TracingEnabled) + if (JackettStartup.TracingEnabled) { config.EnableSystemDiagnosticsTracing(); config.Services.Replace(typeof(ITraceWriter), new WebAPIToNLogTracer()); } // Add request logging if enabled - if (LogRequests) + if (JackettStartup.LogRequests) config.MessageHandlers.Add(new WebAPIRequestLogger()); config.DependencyResolver = Engine.DependencyResolver(); @@ -253,4 +201,5 @@ namespace Jackett }); } } -} + +} \ No newline at end of file diff --git a/src/Jackett/Utils/JackettAuthorizedAttribute.cs b/src/Jackett/Utils/JackettAuthorizedAttribute.cs index ee9cd0a86..77f0b0769 100644 --- a/src/Jackett/Utils/JackettAuthorizedAttribute.cs +++ b/src/Jackett/Utils/JackettAuthorizedAttribute.cs @@ -12,7 +12,7 @@ namespace Jackett.Utils public override void OnAuthorization(HttpActionContext actionContext) { // Skip authorisation on blank passwords - if (string.IsNullOrEmpty(Engine.Server.Config.AdminPassword)) + if (string.IsNullOrEmpty(Engine.ServerConfig.AdminPassword)) { return; } diff --git a/src/Jackett/Utils/RedirectMiddleware.cs b/src/Jackett/Utils/RedirectMiddleware.cs index a0593bfef..6f2d1a01c 100644 --- a/src/Jackett/Utils/RedirectMiddleware.cs +++ b/src/Jackett/Utils/RedirectMiddleware.cs @@ -1,6 +1,7 @@ using Microsoft.Owin; using System; using System.Threading.Tasks; +using Jacket.Common; namespace Jackett.Utils { @@ -13,16 +14,16 @@ namespace Jackett.Utils public async override Task Invoke(IOwinContext context) { - if (context.Request.Path != null && context.Request.Path.HasValue && context.Request.Path.Value.StartsWith(Startup.BasePath, StringComparison.Ordinal)) + if (context.Request.Path != null && context.Request.Path.HasValue && context.Request.Path.Value.StartsWith(JackettStartup.BasePath, StringComparison.Ordinal)) { - context.Request.Path = new PathString(context.Request.Path.Value.Substring(Startup.BasePath.Length - 1)); + context.Request.Path = new PathString(context.Request.Path.Value.Substring(JackettStartup.BasePath.Length - 1)); } if (context.Request.Path == null || string.IsNullOrWhiteSpace(context.Request.Path.ToString()) || context.Request.Path.ToString() == "/") { // 301 is the status code of permanent redirect context.Response.StatusCode = 302; - var redir = Startup.BasePath + "UI/Dashboard"; + var redir = JackettStartup.BasePath + "UI/Dashboard"; Engine.Logger.Info("redirecting to " + redir); context.Response.Headers.Set("Location", redir); } diff --git a/src/Jackett/Utils/WebAPIToNLogTracer.cs b/src/Jackett/Utils/WebAPIToNLogTracer.cs index 2db729117..dd19d5a53 100644 --- a/src/Jackett/Utils/WebAPIToNLogTracer.cs +++ b/src/Jackett/Utils/WebAPIToNLogTracer.cs @@ -5,6 +5,7 @@ using System.Net.Http; using System.Text; using System.Threading.Tasks; using System.Web.Http.Tracing; +using Jacket.Common; namespace Jackett.Utils { @@ -13,7 +14,7 @@ namespace Jackett.Utils public void Trace(HttpRequestMessage request, string category, TraceLevel level, Action traceAction) { - if (Startup.TracingEnabled) + if (JackettStartup.TracingEnabled) { TraceRecord rec = new TraceRecord(request, category, level); traceAction(rec);