diff --git a/src/Jackett.Common/CurlHelper.cs b/src/Jackett.Common/CurlHelper.cs index 56938b549..5c3551557 100644 --- a/src/Jackett.Common/CurlHelper.cs +++ b/src/Jackett.Common/CurlHelper.cs @@ -139,7 +139,7 @@ namespace Jackett } } - if (JackettStartup.DoSSLFix == true) + if (config.RuntimeSettings.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 @@ -148,7 +148,7 @@ namespace Jackett easy.ForbidReuse = true; } - if (JackettStartup.IgnoreSslErrors == true) + if (config.RuntimeSettings.IgnoreSslErrors == true) { easy.SetOpt(CurlOption.SslVerifyhost, false); easy.SetOpt(CurlOption.SslVerifyPeer, false); diff --git a/src/Jackett.Common/Engine.cs b/src/Jackett.Common/Engine.cs index e35cb3925..49ebab444 100644 --- a/src/Jackett.Common/Engine.cs +++ b/src/Jackett.Common/Engine.cs @@ -1,44 +1,91 @@ using Autofac; +using AutoMapper; +using Jackett.Common.Models.Config; +using Jackett.Common.Plumbing; +using Jackett.Models; +using Jackett.Models.Config; using Jackett.Services; +using Jackett.Services.Interfaces; +using Jackett.Utils.Clients; using NLog; using NLog.Config; using NLog.LayoutRenderers; using NLog.Targets; using System; -using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; -using System.Threading.Tasks; -using Jackett.Services.Interfaces; -using Jacket.Common; -using Jackett.Models.Config; -using System.Reflection; namespace Jackett { public class Engine { private static IContainer container = null; - - public static void BuildContainer(params Autofac.Module[] ApplicationSpecificModules) + private static bool _automapperInitialised = false; + + public static void BuildContainer(RuntimeSettings settings, params Autofac.Module[] ApplicationSpecificModules) { var builder = new ContainerBuilder(); - builder.RegisterModule(); - foreach(var module in ApplicationSpecificModules) + SetupLogging(settings, builder); + if (_automapperInitialised == false) + { + //Automapper only likes being initialized once per app domain. + //Since we can restart Jackett from the command line it's possible that we'll build the container more than once. (tests do this too) + InitAutomapper(); + _automapperInitialised = true; + } + + builder.RegisterModule(new JackettModule(settings)); + foreach (var module in ApplicationSpecificModules) { builder.RegisterModule(module); } - SetupLogging(builder); container = builder.Build(); } + private static void InitAutomapper() + { + Mapper.Initialize(cfg => + { + cfg.CreateMap().ForMember(x => x.Content, opt => opt.Ignore()).AfterMap((be, str) => + { + var encoding = be.Request.Encoding ?? Encoding.UTF8; + str.Content = encoding.GetString(be.Content); + }); + + cfg.CreateMap().ForMember(x => x.Content, opt => opt.Ignore()).AfterMap((str, be) => + { + if (!string.IsNullOrEmpty(str.Content)) + { + var encoding = str.Request.Encoding ?? Encoding.UTF8; + be.Content = encoding.GetBytes(str.Content); + } + }); + + cfg.CreateMap(); + cfg.CreateMap(); + cfg.CreateMap(); + + cfg.CreateMap().AfterMap((r, t) => + { + if (r.Category != null) + { + var CategoryDesc = string.Join(", ", r.Category.Select(x => TorznabCatType.GetCatDesc(x)).Where(x => !string.IsNullOrEmpty(x))); + t.CategoryDesc = CategoryDesc; + } + else + { + t.CategoryDesc = ""; + } + }); + }); + } + public static IContainer GetContainer() { return container; } - public static IConfigurationService ConfigService { get @@ -86,7 +133,7 @@ namespace Jackett return container.Resolve(); } } - + public static IRunTimeService RunTime { get @@ -111,10 +158,10 @@ namespace Jackett } } - - public static void SetupLogging(ContainerBuilder builder = null, string logfile = "log.txt") + private static void SetupLogging(RuntimeSettings settings, ContainerBuilder builder) { - var logLevel = JackettStartup.TracingEnabled ? LogLevel.Debug : LogLevel.Info; + var logFileName = settings.CustomLogFileName ?? "log.txt"; + var logLevel = settings.TracingEnabled ? LogLevel.Debug : LogLevel.Info; // Add custom date time format renderer as the default is too long ConfigurationItemFactory.Default.LayoutRenderers.RegisterDefinition("simpledatetime", typeof(SimpleDateTimeRenderer)); @@ -122,7 +169,7 @@ namespace Jackett var logFile = new FileTarget(); logConfig.AddTarget("file", logFile); logFile.Layout = "${longdate} ${level} ${message} ${exception:format=ToString}"; - logFile.FileName = Path.Combine(ConfigurationService.GetAppDataFolderStatic(), logfile); + logFile.FileName = Path.Combine(settings.DataFolder, logFileName); logFile.ArchiveFileName = "log.{#####}.txt"; logFile.ArchiveAboveSize = 500000; logFile.MaxArchiveFiles = 5; @@ -146,13 +193,12 @@ namespace Jackett LogManager.Configuration = logConfig; if (builder != null) { - builder.RegisterInstance(LogManager.GetCurrentClassLogger()).SingleInstance(); + builder.RegisterInstance(LogManager.GetCurrentClassLogger()).SingleInstance(); } } public static void SetLogLevel(LogLevel level) { - foreach (var rule in LogManager.Configuration.LoggingRules) { if (level == LogLevel.Debug) @@ -169,7 +215,6 @@ namespace Jackett rule.DisableLoggingForLevel(LogLevel.Debug); } } - } LogManager.ReconfigExistingLoggers(); @@ -181,7 +226,6 @@ namespace Jackett } } - [LayoutRenderer("simpledatetime")] public class SimpleDateTimeRenderer : LayoutRenderer { @@ -190,4 +234,4 @@ namespace Jackett builder.Append(DateTime.Now.ToString("MM-dd HH:mm:ss")); } } -} +} \ No newline at end of file diff --git a/src/Jackett.Common/Indexers/Rarbg.cs b/src/Jackett.Common/Indexers/Rarbg.cs index a10bd84bc..cea9bc4b0 100644 --- a/src/Jackett.Common/Indexers/Rarbg.cs +++ b/src/Jackett.Common/Indexers/Rarbg.cs @@ -13,6 +13,7 @@ using Jackett.Utils; using Jackett.Utils.Clients; using Newtonsoft.Json.Linq; using NLog; +using Jacket.Common.Utils; namespace Jackett.Indexers { @@ -130,7 +131,7 @@ namespace Jackett.Indexers var queryCollection = new NameValueCollection(); queryCollection.Add("token", token); queryCollection.Add("format", "json_extended"); - queryCollection.Add("app_id", "jackett_v" + JackettStartup.JackettVersion); + queryCollection.Add("app_id", "jackett_v" + EnvironmentUtil.JackettVersion); queryCollection.Add("limit", "100"); queryCollection.Add("ranked", "0"); diff --git a/src/Jackett.Common/Jackett.Common.csproj b/src/Jackett.Common/Jackett.Common.csproj index 9669a5c9e..fbb367573 100644 --- a/src/Jackett.Common/Jackett.Common.csproj +++ b/src/Jackett.Common/Jackett.Common.csproj @@ -115,14 +115,15 @@ - + - + + + - diff --git a/src/Jackett.Common/JackettStartup.cs b/src/Jackett.Common/JackettStartup.cs deleted file mode 100644 index 72622c8d7..000000000 --- a/src/Jackett.Common/JackettStartup.cs +++ /dev/null @@ -1,79 +0,0 @@ -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.Console/ConsoleOptions.cs b/src/Jackett.Common/Models/Config/ConsoleOptions.cs similarity index 67% rename from src/Jackett.Console/ConsoleOptions.cs rename to src/Jackett.Common/Models/Config/ConsoleOptions.cs index 09db353f6..8461911e0 100644 --- a/src/Jackett.Console/ConsoleOptions.cs +++ b/src/Jackett.Common/Models/Config/ConsoleOptions.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Jackett.Console +namespace Jackett.Common.Models.Config { public class ConsoleOptions { @@ -64,9 +64,47 @@ namespace Jackett.Console public string DataFolder { get; set; } [Option(HelpText = "Don't restart after update")] - public bool NoRestart { get; set; } + public bool NoRestart { get; set; } - [ParserState] - public IParserState LastParserState { get; set; } - } -} + + + public RuntimeSettings ToRunTimeSettings() + { + var options = this; + var runtimeSettings = new RuntimeSettings(); + // Logging + if (options.Logging) + runtimeSettings.LogRequests = true; + + // Tracing + if (options.Tracing) + runtimeSettings.TracingEnabled = true; + + if (options.ListenPublic && options.ListenPrivate) + { + Console.WriteLine("You can only use listen private OR listen publicly."); + Environment.Exit(1); + } + + // SSL Fix + runtimeSettings.DoSSLFix = options.SSLFix; + + // Use curl + if (options.Client != null) + runtimeSettings.ClientOverride = options.Client.ToLowerInvariant(); + + // Use Proxy + if (options.ProxyConnection != null) + { + runtimeSettings.ProxyConnection = options.ProxyConnection.ToLowerInvariant(); + } + // Ignore SSL errors on Curl + runtimeSettings.IgnoreSslErrors = options.IgnoreSslErrors; + runtimeSettings.NoRestart = options.NoRestart; + + return runtimeSettings; + + } + } + + } \ No newline at end of file diff --git a/src/Jackett.Common/Models/Config/RuntimeSettings.cs b/src/Jackett.Common/Models/Config/RuntimeSettings.cs new file mode 100644 index 000000000..e59e47104 --- /dev/null +++ b/src/Jackett.Common/Models/Config/RuntimeSettings.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; + +namespace Jackett.Common.Models.Config +{ + public class RuntimeSettings + { + public bool TracingEnabled { get; set; } + + public bool LogRequests { get; set; } + + public string ClientOverride { get; set; } + + public string ProxyConnection { get; set; } + + public bool? DoSSLFix { get; set; } + + public bool? IgnoreSslErrors { get; set; } + + public string CustomDataFolder { get; set; } + + public string BasePath { get; set; } + + public bool NoRestart { get; set; } + + public string CustomLogFileName { get; set; } + + + public string DataFolder + { + get + { + if (!string.IsNullOrWhiteSpace(this.CustomDataFolder)) + { + return this.CustomDataFolder; + } + + if (System.Environment.OSVersion.Platform == PlatformID.Unix) + { + return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Jackett"); + } + else + { + return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Jackett"); + } + } + } + } +} diff --git a/src/Jackett.Common/Models/Config/ServerConfig.cs b/src/Jackett.Common/Models/Config/ServerConfig.cs index 31ee9d08a..b49a9cd78 100644 --- a/src/Jackett.Common/Models/Config/ServerConfig.cs +++ b/src/Jackett.Common/Models/Config/ServerConfig.cs @@ -1,4 +1,5 @@ using Jackett.Common.Models.Config; +using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; @@ -10,10 +11,11 @@ namespace Jackett.Models.Config { public class ServerConfig { - public ServerConfig() + public ServerConfig(RuntimeSettings runtimeSettings) { Port = 9117; AllowExternal = System.Environment.OSVersion.Platform == PlatformID.Unix; + RuntimeSettings = runtimeSettings; } public int Port { get; set; } @@ -27,6 +29,13 @@ namespace Jackett.Models.Config public string BasePathOverride { get; set; } public string OmdbApiKey { get; set; } + /// + /// Ignore as we don't really want to be saving settings specified in the command line. + /// This is a bit of a hack, but in future it might not be all that bad to be able to override config values using settings that were provided at runtime. (and save them if required) + /// + [JsonIgnore] + public RuntimeSettings RuntimeSettings { get; set; } + public string ProxyUrl { get; set; } public ProxyType ProxyType { get; set; } public int? ProxyPort { get; set; } diff --git a/src/Jackett.Common/Models/DTO/ServerConfig.cs b/src/Jackett.Common/Models/DTO/ServerConfig.cs index 1f45a0beb..0c8fd04bd 100644 --- a/src/Jackett.Common/Models/DTO/ServerConfig.cs +++ b/src/Jackett.Common/Models/DTO/ServerConfig.cs @@ -3,6 +3,7 @@ using Jacket.Common; using Jackett.Services; using Jackett.Models.Config; using Jackett.Common.Models.Config; +using Jackett.Common.Plumbing; namespace Jackett.Models.DTO { @@ -42,7 +43,7 @@ namespace Jackett.Models.DTO updatedisabled = config.UpdateDisabled; prerelease = config.UpdatePrerelease; password = string.IsNullOrEmpty(config.AdminPassword) ? string.Empty : config.AdminPassword.Substring(0, 10); - logging = JackettStartup.TracingEnabled; + logging = config.RuntimeSettings.TracingEnabled; basepathoverride = config.BasePathOverride; omdbkey = config.OmdbApiKey; app_version = version; diff --git a/src/Jackett.Common/Plumbing/JackettModule.cs b/src/Jackett.Common/Plumbing/JackettModule.cs index 1a42de7ca..5ce552485 100644 --- a/src/Jackett.Common/Plumbing/JackettModule.cs +++ b/src/Jackett.Common/Plumbing/JackettModule.cs @@ -16,11 +16,19 @@ using System.IO; using Newtonsoft.Json.Linq; using Jackett.Utils; using System.Collections.Generic; +using Jackett.Common.Models.Config; -namespace Jackett +namespace Jackett.Common.Plumbing { public class JackettModule : Autofac.Module { + private RuntimeSettings _runtimeSettings; + + public JackettModule (RuntimeSettings runtimeSettings) + { + _runtimeSettings = runtimeSettings; + } + protected override void Load(ContainerBuilder builder) { // Just register everything! TODO: Something better and more explicit than scanning everything. @@ -40,16 +48,17 @@ namespace Jackett .Except() .Except() .AsImplementedInterfaces().SingleInstance(); - + + + builder.RegisterInstance(_runtimeSettings); builder.Register(ctx => { return BuildServerConfig(ctx); }).As().SingleInstance(); builder.RegisterType(); - - + // Register the best web client for the platform or the override - switch (JackettStartup.ClientOverride) + switch (_runtimeSettings.ClientOverride) { case "httpclient": builder.RegisterType().As(); @@ -77,18 +86,23 @@ namespace Jackett builder.RegisterType().As(); break; } - InitAutomapper(); } - private static ServerConfig BuildServerConfig(IComponentContext ctx) + private ServerConfig BuildServerConfig(IComponentContext ctx) { var configService = ctx.Resolve(); // Load config var config = configService.GetConfig(); if (config == null) { - config = new ServerConfig(); + config = new ServerConfig(_runtimeSettings); + } + else + { + //We don't load these out of the config files as it could get confusing to users who accidently save. + //In future we could flatten the serverconfig, and use command line parameters to override any configuration. + config.RuntimeSettings = _runtimeSettings; } if (string.IsNullOrWhiteSpace(config.APIKey)) @@ -125,43 +139,7 @@ namespace Jackett return config; } - private static void InitAutomapper() - { - Mapper.Initialize(cfg => - { - cfg.CreateMap().ForMember(x => x.Content, opt => opt.Ignore()).AfterMap((be, str) => - { - var encoding = be.Request.Encoding ?? Encoding.UTF8; - str.Content = encoding.GetString(be.Content); - }); - - cfg.CreateMap().ForMember(x => x.Content, opt => opt.Ignore()).AfterMap((str, be) => - { - if (!string.IsNullOrEmpty(str.Content)) - { - var encoding = str.Request.Encoding ?? Encoding.UTF8; - be.Content = encoding.GetBytes(str.Content); - } - }); - - cfg.CreateMap(); - cfg.CreateMap(); - cfg.CreateMap(); - - cfg.CreateMap().AfterMap((r, t) => - { - if (r.Category != null) - { - var CategoryDesc = string.Join(", ", r.Category.Select(x => TorznabCatType.GetCatDesc(x)).Where(x => !string.IsNullOrEmpty(x))); - t.CategoryDesc = CategoryDesc; - } - else - { - t.CategoryDesc = ""; - } - }); - }); - } + private static bool DetectMonoCompatabilityWithHttpClient() { diff --git a/src/Jackett.Common/Services/ConfigurationService.cs b/src/Jackett.Common/Services/ConfigurationService.cs index c09dec82d..177e27fe8 100644 --- a/src/Jackett.Common/Services/ConfigurationService.cs +++ b/src/Jackett.Common/Services/ConfigurationService.cs @@ -8,6 +8,9 @@ using System.Security.AccessControl; using System.Security.Principal; using Jackett.Services.Interfaces; using Jacket.Common; +using Jacket.Common.Utils; +using Jackett.Common.Models.Config; +using Jackett.Models.Config; namespace Jackett.Services { @@ -17,15 +20,22 @@ namespace Jackett.Services private ISerializeService serializeService; private Logger logger; private IProcessService processService; + private RuntimeSettings runtimeSettings; - public ConfigurationService(ISerializeService s, IProcessService p, Logger l) + public ConfigurationService(ISerializeService s, IProcessService p, Logger l, RuntimeSettings settings) { serializeService = s; logger = l; processService = p; + runtimeSettings = settings; CreateOrMigrateSettings(); } + public string GetAppDataFolder() + { + return runtimeSettings.DataFolder; + } + public void CreateOrMigrateSettings() { try @@ -213,31 +223,6 @@ namespace Jackett.Services } - public string GetAppDataFolder() - { - return GetAppDataFolderStatic(); - } - - /// - /// This is needed for the logger prior to ioc setup. - /// - /// - public static string GetAppDataFolderStatic() - { - if (!string.IsNullOrWhiteSpace(JackettStartup.CustomDataFolder)) - { - return JackettStartup.CustomDataFolder; - } - - if (System.Environment.OSVersion.Platform == PlatformID.Unix) - { - return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Jackett"); - } - else - { - return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Jackett"); - } - } public string GetIndexerConfigDir() { @@ -256,7 +241,7 @@ namespace Jackett.Services public string GetVersion() { - return JackettStartup.JackettVersion; + return EnvironmentUtil.JackettVersion; } } } diff --git a/src/Jackett.Common/Services/UpdateService.cs b/src/Jackett.Common/Services/UpdateService.cs index 3d82ec1e3..d57481b96 100644 --- a/src/Jackett.Common/Services/UpdateService.cs +++ b/src/Jackett.Common/Services/UpdateService.cs @@ -127,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, JackettStartup.NoRestart); + StartUpdate(updaterPath, installDir, isWindows, config.RuntimeSettings.NoRestart); } catch (Exception e) { diff --git a/src/Jackett.Common/Utils/Clients/HttpWebClient.cs b/src/Jackett.Common/Utils/Clients/HttpWebClient.cs index 482a4e374..50b53bf66 100644 --- a/src/Jackett.Common/Utils/Clients/HttpWebClient.cs +++ b/src/Jackett.Common/Utils/Clients/HttpWebClient.cs @@ -35,7 +35,7 @@ namespace Jackett.Utils.Clients { ServicePointManager.DefaultConnectionLimit = 1000; - if (JackettStartup.IgnoreSslErrors == true) + if (serverConfig.RuntimeSettings.IgnoreSslErrors == true) { logger.Info(string.Format("HttpWebClient: Disabling certificate validation")); ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => { return true; }; diff --git a/src/Jackett.Common/Utils/Clients/HttpWebClient2.cs b/src/Jackett.Common/Utils/Clients/HttpWebClient2.cs index 76c4cd418..92f64bf81 100644 --- a/src/Jackett.Common/Utils/Clients/HttpWebClient2.cs +++ b/src/Jackett.Common/Utils/Clients/HttpWebClient2.cs @@ -100,7 +100,7 @@ namespace Jackett.Utils.Clients override public void Init() { - if (JackettStartup.IgnoreSslErrors == true) + if (serverConfig.RuntimeSettings.IgnoreSslErrors == true) { logger.Info(string.Format("HttpWebClient2: Disabling certificate validation")); ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => { return true; }; diff --git a/src/Jackett.Common/Utils/Clients/UnixLibCurlWebClient.cs b/src/Jackett.Common/Utils/Clients/UnixLibCurlWebClient.cs index 2e174da0e..ded60935a 100644 --- a/src/Jackett.Common/Utils/Clients/UnixLibCurlWebClient.cs +++ b/src/Jackett.Common/Utils/Clients/UnixLibCurlWebClient.cs @@ -56,10 +56,10 @@ namespace Jackett.Utils.Clients var version = Curl.Version; logger.Info("LibCurl version " + version); - if (!JackettStartup.DoSSLFix.HasValue && version.IndexOf("NSS") > -1) + if (!serverConfig.RuntimeSettings.DoSSLFix.HasValue && version.IndexOf("NSS") > -1) { logger.Info("NSS Detected SSL ECC workaround enabled."); - JackettStartup.DoSSLFix = true; + serverConfig.RuntimeSettings.DoSSLFix = true; } } diff --git a/src/Jackett.Common/Utils/Clients/UnixSafeCurlWebClient.cs b/src/Jackett.Common/Utils/Clients/UnixSafeCurlWebClient.cs index 7ef9c8e4b..4d48fc89a 100644 --- a/src/Jackett.Common/Utils/Clients/UnixSafeCurlWebClient.cs +++ b/src/Jackett.Common/Utils/Clients/UnixSafeCurlWebClient.cs @@ -72,13 +72,13 @@ namespace Jackett.Utils.Clients var tempFile = Path.GetTempFileName(); args.AppendFormat("--output \"{0}\" ", tempFile); - if (JackettStartup.DoSSLFix == true) + if (serverConfig.RuntimeSettings.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 (JackettStartup.IgnoreSslErrors == true) + if (serverConfig.RuntimeSettings.IgnoreSslErrors == true) { args.Append("-k "); } @@ -98,7 +98,7 @@ namespace Jackett.Utils.Clients if (headSplit < 0) throw new Exception("Invalid response"); var headers = stdout.Substring(0, headSplit); - if (JackettStartup.ProxyConnection != null) + if (serverConfig.RuntimeSettings.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.Common/Utils/EnvironmentUtil.cs b/src/Jackett.Common/Utils/EnvironmentUtil.cs new file mode 100644 index 000000000..f8f2c609d --- /dev/null +++ b/src/Jackett.Common/Utils/EnvironmentUtil.cs @@ -0,0 +1,27 @@ +using System; +using System.Reflection; + +namespace Jacket.Common.Utils +{ + public static class EnvironmentUtil + { + + 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.Console/Jackett.Console.csproj b/src/Jackett.Console/Jackett.Console.csproj index e18259432..9fe7183e7 100644 --- a/src/Jackett.Console/Jackett.Console.csproj +++ b/src/Jackett.Console/Jackett.Console.csproj @@ -1,5 +1,5 @@  - + Debug @@ -12,10 +12,8 @@ v4.5.2 512 true - - - - true + PackageReference + win AnyCPU @@ -59,7 +57,6 @@ - @@ -86,11 +83,6 @@ - - - 1.9.71 - -