mirror of
https://github.com/Jackett/Jackett
synced 2025-03-04 02:38:08 +00:00
Added port and public binding config options
This commit is contained in:
parent
68c3f6ed4e
commit
e2daa21914
3 changed files with 41 additions and 3 deletions
|
@ -88,6 +88,7 @@
|
|||
<Compile Include="CookieContainerExtensions.cs" />
|
||||
<Compile Include="DataUrl.cs" />
|
||||
<Compile Include="ExceptionWithConfigData.cs" />
|
||||
<Compile Include="HttpClientExtensions.cs" />
|
||||
<Compile Include="IndexerInterface.cs" />
|
||||
<Compile Include="IndexerManager.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.Targets;
|
||||
using System;
|
||||
|
@ -28,6 +30,8 @@ namespace Jackett
|
|||
|
||||
public static bool IsWindows { get { return Environment.OSVersion.Platform == PlatformID.Win32NT; } }
|
||||
|
||||
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
ExitEvent = new ManualResetEvent(false);
|
||||
|
@ -81,6 +85,8 @@ namespace Jackett
|
|||
LogManager.Configuration = logConfig;
|
||||
LoggerInstance = LogManager.GetCurrentClassLogger();
|
||||
|
||||
ReadSettingsFile();
|
||||
|
||||
var serverTask = Task.Run(async () =>
|
||||
{
|
||||
ServerInstance = new Server();
|
||||
|
@ -99,10 +105,32 @@ namespace Jackett
|
|||
|
||||
Console.WriteLine("Running in headless mode.");
|
||||
|
||||
|
||||
|
||||
Task.WaitAll(serverTask);
|
||||
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()
|
||||
{
|
||||
var startInfo = new ProcessStartInfo(Application.ExecutablePath.ToString()) { Verb = "runas" };
|
||||
|
|
|
@ -15,7 +15,9 @@ namespace Jackett
|
|||
{
|
||||
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;
|
||||
IndexerManager indexerManager;
|
||||
|
@ -55,7 +57,13 @@ namespace Jackett
|
|||
try
|
||||
{
|
||||
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();
|
||||
}
|
||||
catch (HttpListenerException ex)
|
||||
|
@ -88,6 +96,7 @@ namespace Jackett
|
|||
}
|
||||
|
||||
Program.LoggerInstance.Info("Server started on port " + Port);
|
||||
Program.LoggerInstance.Info("Accepting only requests from local system: " + (!ListenPublic));
|
||||
|
||||
while (true)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue