mirror of https://github.com/Jackett/Jackett
server: use ApiController for server configuration model validation
Fixes #15643
This commit is contained in:
parent
962c9d1c95
commit
0da89a4183
|
@ -13,6 +13,7 @@ using NLog;
|
||||||
|
|
||||||
namespace Jackett.Server.Controllers
|
namespace Jackett.Server.Controllers
|
||||||
{
|
{
|
||||||
|
[ApiController]
|
||||||
[Route("api/v2.0/server/[action]")]
|
[Route("api/v2.0/server/[action]")]
|
||||||
[ResponseCache(Location = ResponseCacheLocation.None, NoStore = true)]
|
[ResponseCache(Location = ResponseCacheLocation.None, NoStore = true)]
|
||||||
public class ServerConfigurationController : Controller
|
public class ServerConfigurationController : Controller
|
||||||
|
@ -170,7 +171,9 @@ namespace Jackett.Server.Controllers
|
||||||
config.proxy_password != serverConfig.ProxyPassword)
|
config.proxy_password != serverConfig.ProxyPassword)
|
||||||
{
|
{
|
||||||
if (config.proxy_port < 1 || config.proxy_port > 65535)
|
if (config.proxy_port < 1 || config.proxy_port > 65535)
|
||||||
throw new Exception("The port you have selected is invalid, it must be below 65535.");
|
{
|
||||||
|
throw new Exception("The port you have selected is invalid, it must be between 1 and 65535.");
|
||||||
|
}
|
||||||
|
|
||||||
serverConfig.ProxyType = string.IsNullOrWhiteSpace(config.proxy_url) ? ProxyType.Disabled : config.proxy_type;
|
serverConfig.ProxyType = string.IsNullOrWhiteSpace(config.proxy_url) ? ProxyType.Disabled : config.proxy_type;
|
||||||
serverConfig.ProxyUrl = config.proxy_url;
|
serverConfig.ProxyUrl = config.proxy_url;
|
||||||
|
@ -187,10 +190,14 @@ namespace Jackett.Server.Controllers
|
||||||
if (port != serverConfig.Port || external != serverConfig.AllowExternal || local_bind_address != serverConfig.LocalBindAddress)
|
if (port != serverConfig.Port || external != serverConfig.AllowExternal || local_bind_address != serverConfig.LocalBindAddress)
|
||||||
{
|
{
|
||||||
if (ServerUtil.RestrictedPorts.Contains(port))
|
if (ServerUtil.RestrictedPorts.Contains(port))
|
||||||
|
{
|
||||||
throw new Exception("The port you have selected is restricted, try a different one.");
|
throw new Exception("The port you have selected is restricted, try a different one.");
|
||||||
|
}
|
||||||
|
|
||||||
if (port < 1 || port > 65535)
|
if (port < 1 || port > 65535)
|
||||||
throw new Exception("The port you have selected is invalid, it must be below 65535.");
|
{
|
||||||
|
throw new Exception("The port you have selected is invalid, it must be between 1 and 65535.");
|
||||||
|
}
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(local_bind_address))
|
if (string.IsNullOrWhiteSpace(local_bind_address))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue