mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
Added port and public binding config options
This commit is contained in:
@@ -88,6 +88,7 @@
|
|||||||
<Compile Include="CookieContainerExtensions.cs" />
|
<Compile Include="CookieContainerExtensions.cs" />
|
||||||
<Compile Include="DataUrl.cs" />
|
<Compile Include="DataUrl.cs" />
|
||||||
<Compile Include="ExceptionWithConfigData.cs" />
|
<Compile Include="ExceptionWithConfigData.cs" />
|
||||||
|
<Compile Include="HttpClientExtensions.cs" />
|
||||||
<Compile Include="IndexerInterface.cs" />
|
<Compile Include="IndexerInterface.cs" />
|
||||||
<Compile Include="IndexerManager.cs" />
|
<Compile Include="IndexerManager.cs" />
|
||||||
<Compile Include="Indexers\BitHdtv.cs" />
|
<Compile Include="Indexers\BitHdtv.cs" />
|
||||||
|
@@ -1,4 +1,6 @@
|
|||||||
using NLog;
|
using Jackett.Indexers;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using NLog;
|
||||||
using NLog.Config;
|
using NLog.Config;
|
||||||
using NLog.Targets;
|
using NLog.Targets;
|
||||||
using System;
|
using System;
|
||||||
@@ -28,6 +30,8 @@ namespace Jackett
|
|||||||
|
|
||||||
public static bool IsWindows { get { return Environment.OSVersion.Platform == PlatformID.Win32NT; } }
|
public static bool IsWindows { get { return Environment.OSVersion.Platform == PlatformID.Win32NT; } }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
ExitEvent = new ManualResetEvent(false);
|
ExitEvent = new ManualResetEvent(false);
|
||||||
@@ -81,6 +85,8 @@ namespace Jackett
|
|||||||
LogManager.Configuration = logConfig;
|
LogManager.Configuration = logConfig;
|
||||||
LoggerInstance = LogManager.GetCurrentClassLogger();
|
LoggerInstance = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
|
ReadSettingsFile();
|
||||||
|
|
||||||
var serverTask = Task.Run(async () =>
|
var serverTask = Task.Run(async () =>
|
||||||
{
|
{
|
||||||
ServerInstance = new Server();
|
ServerInstance = new Server();
|
||||||
@@ -99,10 +105,32 @@ namespace Jackett
|
|||||||
|
|
||||||
Console.WriteLine("Running in headless mode.");
|
Console.WriteLine("Running in headless mode.");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Task.WaitAll(serverTask);
|
Task.WaitAll(serverTask);
|
||||||
Console.WriteLine("Server thread exit");
|
Console.WriteLine("Server thread exit");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ReadSettingsFile()
|
||||||
|
{
|
||||||
|
var path = Path.Combine(AppConfigDirectory, "config.json");
|
||||||
|
if (!File.Exists(path))
|
||||||
|
{
|
||||||
|
JObject f = new JObject();
|
||||||
|
f.Add("port", Server.DefaultPort);
|
||||||
|
f.Add("public", true);
|
||||||
|
File.WriteAllText(path, f.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
var configJson = JObject.Parse(File.ReadAllText(path));
|
||||||
|
int port = (int)configJson.GetValue("port");
|
||||||
|
Server.Port = port;
|
||||||
|
|
||||||
|
Server.ListenPublic = (bool)configJson.GetValue("public");
|
||||||
|
|
||||||
|
Console.WriteLine("Config file path: " + path);
|
||||||
|
}
|
||||||
|
|
||||||
static public void RestartAsAdmin()
|
static public void RestartAsAdmin()
|
||||||
{
|
{
|
||||||
var startInfo = new ProcessStartInfo(Application.ExecutablePath.ToString()) { Verb = "runas" };
|
var startInfo = new ProcessStartInfo(Application.ExecutablePath.ToString()) { Verb = "runas" };
|
||||||
|
@@ -15,7 +15,9 @@ namespace Jackett
|
|||||||
{
|
{
|
||||||
public class Server
|
public class Server
|
||||||
{
|
{
|
||||||
public const int Port = 9117;
|
public const int DefaultPort = 9117;
|
||||||
|
public static int Port = DefaultPort;
|
||||||
|
public static bool ListenPublic = true;
|
||||||
|
|
||||||
HttpListener listener;
|
HttpListener listener;
|
||||||
IndexerManager indexerManager;
|
IndexerManager indexerManager;
|
||||||
@@ -55,7 +57,13 @@ namespace Jackett
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
listener = new HttpListener();
|
listener = new HttpListener();
|
||||||
listener.Prefixes.Add("http://*:9117/");
|
listener.Prefixes.Add(string.Format("http://127.0.0.1:{0}/", Port));
|
||||||
|
listener.Prefixes.Add(string.Format("http://localhost:{0}/", Port));
|
||||||
|
if (ListenPublic)
|
||||||
|
{
|
||||||
|
listener.Prefixes.Add(string.Format("http://*:{0}/", Port));
|
||||||
|
}
|
||||||
|
|
||||||
listener.Start();
|
listener.Start();
|
||||||
}
|
}
|
||||||
catch (HttpListenerException ex)
|
catch (HttpListenerException ex)
|
||||||
@@ -88,6 +96,7 @@ namespace Jackett
|
|||||||
}
|
}
|
||||||
|
|
||||||
Program.LoggerInstance.Info("Server started on port " + Port);
|
Program.LoggerInstance.Info("Server started on port " + Port);
|
||||||
|
Program.LoggerInstance.Info("Accepting only requests from local system: " + (!ListenPublic));
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user