mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
Reserve all addresses for port
This commit is contained in:
@@ -54,6 +54,7 @@ namespace Jackett.Server
|
|||||||
public static void ProcessWindowsSpecificArgs(ConsoleOptions consoleOptions, IProcessService processService, ServerConfig serverConfig, Logger logger)
|
public static void ProcessWindowsSpecificArgs(ConsoleOptions consoleOptions, IProcessService processService, ServerConfig serverConfig, Logger logger)
|
||||||
{
|
{
|
||||||
IServiceConfigService serviceConfigService = new ServiceConfigService();
|
IServiceConfigService serviceConfigService = new ServiceConfigService();
|
||||||
|
IServerService serverService = new ServerService(null, processService, null, null, logger, null, null, null, serverConfig);
|
||||||
|
|
||||||
/* ====== Actions ===== */
|
/* ====== Actions ===== */
|
||||||
|
|
||||||
@@ -69,7 +70,7 @@ namespace Jackett.Server
|
|||||||
if (consoleOptions.Uninstall)
|
if (consoleOptions.Uninstall)
|
||||||
{
|
{
|
||||||
logger.Info("Initiating Jackett service uninstall");
|
logger.Info("Initiating Jackett service uninstall");
|
||||||
ReserveUrls(processService, serverConfig, logger, doInstall: false);
|
serverService.ReserveUrls(false);
|
||||||
serviceConfigService.Uninstall();
|
serviceConfigService.Uninstall();
|
||||||
Environment.Exit(1);
|
Environment.Exit(1);
|
||||||
}
|
}
|
||||||
@@ -100,13 +101,15 @@ namespace Jackett.Server
|
|||||||
if (consoleOptions.ReserveUrls)
|
if (consoleOptions.ReserveUrls)
|
||||||
{
|
{
|
||||||
logger.Info("Initiating ReserveUrls");
|
logger.Info("Initiating ReserveUrls");
|
||||||
ReserveUrls(processService, serverConfig, logger, doInstall: true);
|
serverService.ReserveUrls(true);
|
||||||
Environment.Exit(1);
|
Environment.Exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ProcessConsoleOverrides(ConsoleOptions consoleOptions, IProcessService processService, ServerConfig serverConfig, IConfigurationService configurationService, Logger logger)
|
public static void ProcessConsoleOverrides(ConsoleOptions consoleOptions, IProcessService processService, ServerConfig serverConfig, IConfigurationService configurationService, Logger logger)
|
||||||
{
|
{
|
||||||
|
IServerService serverService = new ServerService(null, processService, null, null, logger, null, null, null, serverConfig);
|
||||||
|
|
||||||
// Override port
|
// Override port
|
||||||
if (consoleOptions.Port != 0)
|
if (consoleOptions.Port != 0)
|
||||||
{
|
{
|
||||||
@@ -121,7 +124,7 @@ namespace Jackett.Server
|
|||||||
{
|
{
|
||||||
if (ServerUtil.IsUserAdministrator())
|
if (ServerUtil.IsUserAdministrator())
|
||||||
{
|
{
|
||||||
ReserveUrls(processService, serverConfig, logger, doInstall: true);
|
serverService.ReserveUrls(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -144,7 +147,7 @@ namespace Jackett.Server
|
|||||||
{
|
{
|
||||||
if (ServerUtil.IsUserAdministrator())
|
if (ServerUtil.IsUserAdministrator())
|
||||||
{
|
{
|
||||||
ReserveUrls(processService, serverConfig, logger, doInstall: true);
|
serverService.ReserveUrls(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -156,23 +159,5 @@ namespace Jackett.Server
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ReserveUrls(IProcessService processService, ServerConfig serverConfig, Logger logger, bool doInstall = true)
|
|
||||||
{
|
|
||||||
logger.Debug("Unreserving Urls");
|
|
||||||
serverConfig.GetListenAddresses(false).ToList().ForEach(u => RunNetSh(processService, string.Format("http delete urlacl {0}", u)));
|
|
||||||
serverConfig.GetListenAddresses(true).ToList().ForEach(u => RunNetSh(processService, string.Format("http delete urlacl {0}", u)));
|
|
||||||
if (doInstall)
|
|
||||||
{
|
|
||||||
logger.Debug("Reserving Urls");
|
|
||||||
serverConfig.GetListenAddresses(serverConfig.AllowExternal).ToList().ForEach(u => RunNetSh(processService, string.Format("http add urlacl {0} sddl=D:(A;;GX;;;S-1-1-0)", u)));
|
|
||||||
logger.Debug("Urls reserved");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void RunNetSh(IProcessService processService, string args)
|
|
||||||
{
|
|
||||||
processService.StartProcessAndLog("netsh.exe", args);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -279,7 +279,7 @@ namespace Jackett.Server.Services
|
|||||||
if (doInstall)
|
if (doInstall)
|
||||||
{
|
{
|
||||||
logger.Debug("Reserving Urls");
|
logger.Debug("Reserving Urls");
|
||||||
config.GetListenAddresses(config.AllowExternal).ToList().ForEach(u => RunNetSh(string.Format("http add urlacl {0} sddl=D:(A;;GX;;;S-1-1-0)", u)));
|
config.GetListenAddresses(true).ToList().ForEach(u => RunNetSh(string.Format("http add urlacl {0} sddl=D:(A;;GX;;;S-1-1-0)", u)));
|
||||||
logger.Debug("Urls reserved");
|
logger.Debug("Urls reserved");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user