mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
Normalise Line endings (#1284)
* Add .gitattributes * Normalise line endings
This commit is contained in:
@@ -17,13 +17,13 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Net.Sockets;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Net.Sockets;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
@@ -37,9 +37,9 @@ namespace Jackett.Services
|
||||
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();
|
||||
List<string> notices { get; }
|
||||
Uri ConvertToProxyLink(Uri link, string serverUrl, string indexerId, string action = "dl", string file = "t.torrent");
|
||||
string BasePath();
|
||||
List<string> notices { get; }
|
||||
}
|
||||
|
||||
public class ServerService : IServerService
|
||||
@@ -73,16 +73,16 @@ namespace Jackett.Services
|
||||
public ServerConfig Config
|
||||
{
|
||||
get { return config; }
|
||||
}
|
||||
|
||||
public List<string> notices
|
||||
{
|
||||
get
|
||||
{
|
||||
return _notices;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public List<string> notices
|
||||
{
|
||||
get
|
||||
{
|
||||
return _notices;
|
||||
}
|
||||
}
|
||||
|
||||
public Uri ConvertToProxyLink(Uri link, string serverUrl, string indexerId, string action = "dl", string file = "t.torrent")
|
||||
{
|
||||
if (link == null || (link.IsAbsoluteUri && link.Scheme == "magnet"))
|
||||
@@ -94,19 +94,19 @@ namespace Jackett.Services
|
||||
return new Uri(proxyLink);
|
||||
}
|
||||
|
||||
public string BasePath()
|
||||
{
|
||||
if (config.BasePathOverride == null || config.BasePathOverride == "") {
|
||||
return "/";
|
||||
public string BasePath()
|
||||
{
|
||||
if (config.BasePathOverride == null || config.BasePathOverride == "") {
|
||||
return "/";
|
||||
}
|
||||
var path = config.BasePathOverride;
|
||||
if (!path.EndsWith("/"))
|
||||
{
|
||||
path = path + "/";
|
||||
if (!path.EndsWith("/"))
|
||||
{
|
||||
path = path + "/";
|
||||
}
|
||||
if (!path.StartsWith("/"))
|
||||
{
|
||||
path = "/" + path;
|
||||
if (!path.StartsWith("/"))
|
||||
{
|
||||
path = "/" + path;
|
||||
}
|
||||
return path;
|
||||
}
|
||||
@@ -161,131 +161,131 @@ namespace Jackett.Services
|
||||
public void Initalize()
|
||||
{
|
||||
logger.Info("Starting Jackett " + configService.GetVersion());
|
||||
try
|
||||
{
|
||||
var x = Environment.OSVersion;
|
||||
var runtimedir = RuntimeEnvironment.GetRuntimeDirectory();
|
||||
try
|
||||
{
|
||||
var x = Environment.OSVersion;
|
||||
var runtimedir = RuntimeEnvironment.GetRuntimeDirectory();
|
||||
logger.Info("Environment version: " + Environment.Version.ToString() + " (" + runtimedir + ")");
|
||||
logger.Info("OS version: " + Environment.OSVersion.ToString() + (Environment.Is64BitOperatingSystem ? " (64bit OS)" : "") + (Environment.Is64BitProcess ? " (64bit process)" : ""));
|
||||
|
||||
try
|
||||
{
|
||||
int workerThreads;
|
||||
int completionPortThreads;
|
||||
ThreadPool.GetMaxThreads(out workerThreads, out completionPortThreads);
|
||||
logger.Info("ThreadPool MaxThreads: " + workerThreads + " workerThreads, " + completionPortThreads + " completionPortThreads");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.Error("Error while getting MaxThreads details: " + e);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var issuefile = "/etc/issue";
|
||||
if (File.Exists(issuefile))
|
||||
{
|
||||
using (StreamReader reader = new StreamReader(issuefile))
|
||||
{
|
||||
string firstLine;
|
||||
firstLine = reader.ReadLine();
|
||||
if (firstLine != null)
|
||||
logger.Info("issue: " + firstLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.Error(e, "Error while reading the issue file");
|
||||
logger.Info("OS version: " + Environment.OSVersion.ToString() + (Environment.Is64BitOperatingSystem ? " (64bit OS)" : "") + (Environment.Is64BitProcess ? " (64bit process)" : ""));
|
||||
|
||||
try
|
||||
{
|
||||
int workerThreads;
|
||||
int completionPortThreads;
|
||||
ThreadPool.GetMaxThreads(out workerThreads, out completionPortThreads);
|
||||
logger.Info("ThreadPool MaxThreads: " + workerThreads + " workerThreads, " + completionPortThreads + " completionPortThreads");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.Error("Error while getting MaxThreads details: " + e);
|
||||
}
|
||||
|
||||
Type monotype = Type.GetType("Mono.Runtime");
|
||||
if (monotype != null)
|
||||
{
|
||||
MethodInfo displayName = monotype.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static);
|
||||
var monoVersion = "unknown";
|
||||
if (displayName != null)
|
||||
monoVersion = displayName.Invoke(null, null).ToString();
|
||||
logger.Info("mono version: " + monoVersion);
|
||||
|
||||
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/");
|
||||
Environment.Exit(2);
|
||||
}
|
||||
else if (monoVersionO.Major == 4 && monoVersionO.Minor == 2)
|
||||
{
|
||||
var notice = "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.";
|
||||
_notices.Add(notice);
|
||||
logger.Error(notice);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// Check for mono-devel
|
||||
// Is there any better way which doesn't involve a hard cashes?
|
||||
var mono_devel_file = Path.Combine(runtimedir, "mono-api-info.exe");
|
||||
if (!File.Exists(mono_devel_file))
|
||||
{
|
||||
var notice = "It looks like the mono-devel package is not installed, please make sure it's installed to avoid crashes.";
|
||||
_notices.Add(notice);
|
||||
logger.Error(notice);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
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)
|
||||
{
|
||||
var notice = "The ca-certificates-mono package is not installed, HTTPS trackers won't work. Please install it.";
|
||||
_notices.Add(notice);
|
||||
logger.Error(notice);
|
||||
}
|
||||
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
|
||||
{
|
||||
Encoding.GetEncoding("windows-1255");
|
||||
}
|
||||
catch (NotSupportedException e)
|
||||
{
|
||||
logger.Debug(e);
|
||||
logger.Error(e.Message + " Most likely the mono-locale-extras package is not installed.");
|
||||
Environment.Exit(2);
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
var issuefile = "/etc/issue";
|
||||
if (File.Exists(issuefile))
|
||||
{
|
||||
using (StreamReader reader = new StreamReader(issuefile))
|
||||
{
|
||||
string firstLine;
|
||||
firstLine = reader.ReadLine();
|
||||
if (firstLine != null)
|
||||
logger.Info("issue: " + firstLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.Error(e, "Error while reading the issue file");
|
||||
}
|
||||
|
||||
Type monotype = Type.GetType("Mono.Runtime");
|
||||
if (monotype != null)
|
||||
{
|
||||
MethodInfo displayName = monotype.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static);
|
||||
var monoVersion = "unknown";
|
||||
if (displayName != null)
|
||||
monoVersion = displayName.Invoke(null, null).ToString();
|
||||
logger.Info("mono version: " + monoVersion);
|
||||
|
||||
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/");
|
||||
Environment.Exit(2);
|
||||
}
|
||||
else if (monoVersionO.Major == 4 && monoVersionO.Minor == 2)
|
||||
{
|
||||
var notice = "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.";
|
||||
_notices.Add(notice);
|
||||
logger.Error(notice);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// Check for mono-devel
|
||||
// Is there any better way which doesn't involve a hard cashes?
|
||||
var mono_devel_file = Path.Combine(runtimedir, "mono-api-info.exe");
|
||||
if (!File.Exists(mono_devel_file))
|
||||
{
|
||||
var notice = "It looks like the mono-devel package is not installed, please make sure it's installed to avoid crashes.";
|
||||
_notices.Add(notice);
|
||||
logger.Error(notice);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
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)
|
||||
{
|
||||
var notice = "The ca-certificates-mono package is not installed, HTTPS trackers won't work. Please install it.";
|
||||
_notices.Add(notice);
|
||||
logger.Error(notice);
|
||||
}
|
||||
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
|
||||
{
|
||||
Encoding.GetEncoding("windows-1255");
|
||||
}
|
||||
catch (NotSupportedException e)
|
||||
{
|
||||
logger.Debug(e);
|
||||
logger.Error(e.Message + " Most likely the mono-locale-extras package is not installed.");
|
||||
Environment.Exit(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.Error("Error while getting environment details: " + e);
|
||||
{
|
||||
logger.Error("Error while getting environment details: " + e);
|
||||
}
|
||||
|
||||
CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US");
|
||||
// Load indexers
|
||||
indexerService.InitIndexers();
|
||||
foreach(string dir in configService.GetCardigannDefinitionsFolders())
|
||||
{
|
||||
indexerService.InitCardigannIndexers(dir);
|
||||
foreach(string dir in configService.GetCardigannDefinitionsFolders())
|
||||
{
|
||||
indexerService.InitCardigannIndexers(dir);
|
||||
}
|
||||
indexerService.SortIndexers();
|
||||
client.Init();
|
||||
@@ -299,24 +299,24 @@ namespace Jackett.Services
|
||||
var startOptions = new StartOptions();
|
||||
config.GetListenAddresses().ToList().ForEach(u => startOptions.Urls.Add(u));
|
||||
Startup.BasePath = BasePath();
|
||||
try
|
||||
{
|
||||
_server = WebApp.Start<Startup>(startOptions);
|
||||
try
|
||||
{
|
||||
_server = WebApp.Start<Startup>(startOptions);
|
||||
}
|
||||
catch (TargetInvocationException e)
|
||||
{
|
||||
var inner = e.InnerException;
|
||||
if (inner is SocketException && ((SocketException)inner).SocketErrorCode == SocketError.AddressAlreadyInUse) // Linux (mono)
|
||||
{
|
||||
logger.Error("Address already in use: Most likely Jackett is already running.");
|
||||
Environment.Exit(1);
|
||||
}
|
||||
else if (inner is HttpListenerException && ((HttpListenerException)inner).ErrorCode == 183) // Windows
|
||||
{
|
||||
logger.Error(inner.Message + " Most likely Jackett is already running.");
|
||||
Environment.Exit(1);
|
||||
}
|
||||
throw e;
|
||||
catch (TargetInvocationException e)
|
||||
{
|
||||
var inner = e.InnerException;
|
||||
if (inner is SocketException && ((SocketException)inner).SocketErrorCode == SocketError.AddressAlreadyInUse) // Linux (mono)
|
||||
{
|
||||
logger.Error("Address already in use: Most likely Jackett is already running.");
|
||||
Environment.Exit(1);
|
||||
}
|
||||
else if (inner is HttpListenerException && ((HttpListenerException)inner).ErrorCode == 183) // Windows
|
||||
{
|
||||
logger.Error(inner.Message + " Most likely Jackett is already running.");
|
||||
Environment.Exit(1);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
logger.Debug("Web server started");
|
||||
updater.StartUpdateChecker();
|
||||
|
Reference in New Issue
Block a user