mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
make HttpWebClient the default for mono >= 4.8
This commit is contained in:
@@ -10,10 +10,11 @@ using Jackett.Utils;
|
|||||||
using Jackett.Utils.Clients;
|
using Jackett.Utils.Clients;
|
||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
using Jackett.Models;
|
using Jackett.Models;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
namespace Jackett
|
namespace Jackett
|
||||||
{
|
{
|
||||||
public class JackettModule : Module
|
public class JackettModule : Autofac.Module
|
||||||
{
|
{
|
||||||
protected override void Load(ContainerBuilder builder)
|
protected override void Load(ContainerBuilder builder)
|
||||||
{
|
{
|
||||||
@@ -39,7 +40,32 @@ namespace Jackett
|
|||||||
default:
|
default:
|
||||||
if (System.Environment.OSVersion.Platform == PlatformID.Unix)
|
if (System.Environment.OSVersion.Platform == PlatformID.Unix)
|
||||||
{
|
{
|
||||||
builder.RegisterType<UnixLibCurlWebClient>().As<IWebClient>();
|
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)
|
||||||
|
{
|
||||||
|
usehttpclient = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.Out.WriteLine("Error while deciding which HttpWebClient to use: " + e);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (usehttpclient)
|
||||||
|
builder.RegisterType<HttpWebClient>().As<IWebClient>();
|
||||||
|
else
|
||||||
|
builder.RegisterType<UnixLibCurlWebClient>().As<IWebClient>();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -198,12 +198,14 @@ namespace Jackett.Services
|
|||||||
monoVersion = displayName.Invoke(null, null).ToString();
|
monoVersion = displayName.Invoke(null, null).ToString();
|
||||||
logger.Info("mono version: " + monoVersion);
|
logger.Info("mono version: " + monoVersion);
|
||||||
|
|
||||||
if (monoVersion.StartsWith("3."))
|
var monoVersionO = new Version(monoVersion.Split(' ')[0]);
|
||||||
|
|
||||||
|
if (monoVersionO.Major < 4)
|
||||||
{
|
{
|
||||||
logger.Error("Your mono version is to old (mono 3 is no longer supported). Please update to the latest version from http://www.mono-project.com/download/");
|
logger.Error("Your mono version is to old (mono 3 is no longer supported). Please update to the latest version from http://www.mono-project.com/download/");
|
||||||
Environment.Exit(2);
|
Environment.Exit(2);
|
||||||
}
|
}
|
||||||
else if (monoVersion.StartsWith("4.2."))
|
else if (monoVersionO.Major == 4 && monoVersionO.Minor == 2)
|
||||||
{
|
{
|
||||||
logger.Error("mono version 4.2.* is known to cause problems with Jackett. If you experience any problems please try updating to the latest mono version from http://www.mono-project.com/download/ first.");
|
logger.Error("mono version 4.2.* is known to cause problems with Jackett. If you experience any problems please try updating to the latest mono version from http://www.mono-project.com/download/ first.");
|
||||||
}
|
}
|
||||||
@@ -223,6 +225,28 @@ namespace Jackett.Services
|
|||||||
logger.Error(e, "Error while checking for mono-devel");
|
logger.Error(e, "Error while checking for mono-devel");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Check for ca-certificates-mono
|
||||||
|
var mono_cert_file = Path.Combine(runtimedir, "cert-sync.exe");
|
||||||
|
if (!File.Exists(mono_cert_file))
|
||||||
|
{
|
||||||
|
if (monoVersionO.Major >= 4 && monoVersionO.Minor >= 8)
|
||||||
|
{
|
||||||
|
logger.Error("The ca-certificates-mono package is not installed, HTTPS trackers won't work. Please install it.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logger.Info("The ca-certificates-mono package is not installed, it will become mandatory once mono >= 4.8 is used.");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
logger.Error(e, "Error while checking for ca-certificates-mono");
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Encoding.GetEncoding("windows-1255");
|
Encoding.GetEncoding("windows-1255");
|
||||||
|
Reference in New Issue
Block a user