mirror of https://github.com/Jackett/Jackett
UI proxy settings (#2043)
This commit is contained in:
parent
7638d9bc39
commit
570ea5bb51
|
@ -66,6 +66,12 @@ function loadJackettSettings() {
|
|||
$(".api-key-text").text(data.api_key);
|
||||
$("#app-version").html(data.app_version);
|
||||
$("#jackett-port").val(data.port);
|
||||
|
||||
$("#jackett-proxy-url").val(data.proxy_url);
|
||||
$("#jackett-proxy-port").val(data.proxy_port);
|
||||
$("#jackett-proxy-username").val(data.proxy_username);
|
||||
$("#jackett-proxy-password").val(data.proxy_password);
|
||||
|
||||
$("#jackett-basepathoverride").val(data.basepathoverride);
|
||||
basePath = data.basepathoverride;
|
||||
if (basePath === null || basePath === undefined) {
|
||||
|
@ -1126,6 +1132,12 @@ function bindUIButtons() {
|
|||
var jackett_prerelease = $("#jackett-prerelease").is(':checked');
|
||||
var jackett_logging = $("#jackett-logging").is(':checked');
|
||||
var jackett_omdb_key = $("#jackett-omdbkey").val();
|
||||
|
||||
var jackett_proxy_url = $("#jackett-proxy-url").val();
|
||||
var jackett_proxy_port = $("#jackett-proxy-port").val();
|
||||
var jackett_proxy_username = $("#jackett-proxy-username").val();
|
||||
var jackett_proxy_password = $("#jackett-proxy-password").val();
|
||||
|
||||
var jsonObject = {
|
||||
port: jackett_port,
|
||||
external: jackett_external,
|
||||
|
@ -1134,7 +1146,11 @@ function bindUIButtons() {
|
|||
blackholedir: $("#jackett-savedir").val(),
|
||||
logging: jackett_logging,
|
||||
basepathoverride: jackett_basepathoverride,
|
||||
omdbkey: jackett_omdb_key
|
||||
omdbkey: jackett_omdb_key,
|
||||
proxy_url: jackett_proxy_url,
|
||||
proxy_port: jackett_proxy_port,
|
||||
proxy_username: jackett_proxy_username,
|
||||
proxy_password: jackett_proxy_password
|
||||
};
|
||||
api.updateServerConfig(jsonObject, function (data) {
|
||||
doNotify("Redirecting you to complete configuration update..", "success", "glyphicon glyphicon-ok");
|
||||
|
|
|
@ -122,6 +122,24 @@
|
|||
<span class="input-header">Manual download blackhole directory: </span>
|
||||
<input id="jackett-savedir" class="form-control input-right" type="text" value="" placeholder="c:\torrents\">
|
||||
</div>
|
||||
|
||||
<div class="input-area">
|
||||
<span class="input-header">Proxy url: </span>
|
||||
<input id="jackett-proxy-url" class="form-control input-right" type="text" value="" placeholder="">
|
||||
</div>
|
||||
<div class="input-area">
|
||||
<span class="input-header">Proxy port: </span>
|
||||
<input id="jackett-proxy-port" class="form-control input-right" type="text" value="" placeholder="">
|
||||
</div>
|
||||
<div class="input-area">
|
||||
<span class="input-header">Proxy username: </span>
|
||||
<input id="jackett-proxy-username" class="form-control input-right" type="text" value="" placeholder="">
|
||||
</div>
|
||||
<div class="input-area">
|
||||
<span class="input-header">Proxy password: </span>
|
||||
<input id="jackett-proxy-password" class="form-control input-right" type="text" value="" placeholder="">
|
||||
</div>
|
||||
|
||||
<div class="input-area">
|
||||
<span class="input-header">External access: </span>
|
||||
<input id="jackett-allowext" class="form-control input-right" type="checkbox" />
|
||||
|
|
|
@ -96,6 +96,21 @@ namespace Jackett.Controllers.V20
|
|||
indexerService.InitAggregateIndexer();
|
||||
}
|
||||
|
||||
if (config.proxy_url != Engine.Server.Config.ProxyUrl ||
|
||||
config.proxy_port != Engine.Server.Config.ProxyPort ||
|
||||
config.proxy_username != Engine.Server.Config.ProxyUsername ||
|
||||
config.proxy_password != Engine.Server.Config.ProxyPassword)
|
||||
{
|
||||
if (config.proxy_port < 1 || config.proxy_port > 65535)
|
||||
throw new Exception("The port you have selected is invalid, it must be below 65535.");
|
||||
|
||||
Engine.Server.Config.ProxyUrl = config.proxy_url;
|
||||
Engine.Server.Config.ProxyPort = config.proxy_port;
|
||||
Engine.Server.Config.ProxyUsername = config.proxy_username;
|
||||
Engine.Server.Config.ProxyPassword = config.proxy_password;
|
||||
Engine.Server.SaveConfig();
|
||||
}
|
||||
|
||||
if (port != Engine.Server.Config.Port || external != Engine.Server.Config.AllowExternal)
|
||||
{
|
||||
|
||||
|
|
|
@ -153,10 +153,10 @@ namespace Jackett
|
|||
easy.SetOpt(CurlOption.SslVerifyPeer, false);
|
||||
}
|
||||
|
||||
if (Startup.ProxyConnection != null)
|
||||
if (Engine.Server.Config.Proxy != null)
|
||||
{
|
||||
easy.SetOpt(CurlOption.HttpProxyTunnel, 1);
|
||||
easy.SetOpt(CurlOption.Proxy, Startup.ProxyConnection);
|
||||
easy.SetOpt(CurlOption.Proxy, Engine.Server.Config.Proxy);
|
||||
}
|
||||
|
||||
easy.Perform();
|
||||
|
|
|
@ -26,6 +26,31 @@ namespace Jackett.Models.Config
|
|||
public string BasePathOverride { get; set; }
|
||||
public string OmdbApiKey { get; set; }
|
||||
|
||||
public string ProxyUrl { get; set; }
|
||||
public int? ProxyPort { get; set; }
|
||||
public string ProxyUsername { get; set; }
|
||||
public string ProxyPassword { get; set; }
|
||||
|
||||
public string Proxy
|
||||
{
|
||||
get
|
||||
{
|
||||
var proxy = ProxyUrl;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(ProxyUsername) && !string.IsNullOrWhiteSpace(ProxyPassword))
|
||||
{
|
||||
proxy = $"{ProxyUsername}:{ProxyPassword}@{proxy}";
|
||||
}
|
||||
|
||||
if (ProxyPort.HasValue)
|
||||
{
|
||||
proxy = $"{proxy}:{ProxyPort}";
|
||||
}
|
||||
|
||||
return proxy;
|
||||
}
|
||||
}
|
||||
|
||||
public string[] GetListenAddresses(bool? external = null)
|
||||
{
|
||||
if (external == null)
|
||||
|
@ -38,7 +63,7 @@ namespace Jackett.Models.Config
|
|||
}
|
||||
else
|
||||
{
|
||||
return new string[] {
|
||||
return new string[] {
|
||||
"http://127.0.0.1:" + Port + "/",
|
||||
"http://localhost:" + Port + "/",
|
||||
};
|
||||
|
|
|
@ -18,6 +18,11 @@ namespace Jackett.Models.DTO
|
|||
public string omdbkey { get; set; }
|
||||
public string app_version { get; set; }
|
||||
|
||||
public string proxy_url { get; set; }
|
||||
public int? proxy_port { get; set; }
|
||||
public string proxy_username { get; set; }
|
||||
public string proxy_password { get; set; }
|
||||
|
||||
public ServerConfig()
|
||||
{
|
||||
notices = new string[0];
|
||||
|
@ -37,6 +42,11 @@ namespace Jackett.Models.DTO
|
|||
basepathoverride = config.BasePathOverride;
|
||||
omdbkey = config.OmdbApiKey;
|
||||
app_version = version;
|
||||
|
||||
proxy_url = config.ProxyUrl;
|
||||
proxy_port = config.ProxyPort;
|
||||
proxy_username = config.ProxyUsername;
|
||||
proxy_password = config.ProxyPassword;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace Jackett.Utils.Clients
|
|||
var hash = certificate.GetCertHashString();
|
||||
|
||||
ICollection<string> hosts;
|
||||
|
||||
|
||||
trustedCertificates.TryGetValue(hash, out hosts);
|
||||
if (hosts != null)
|
||||
{
|
||||
|
@ -82,9 +82,25 @@ namespace Jackett.Utils.Clients
|
|||
}
|
||||
var useProxy = false;
|
||||
WebProxy proxyServer = null;
|
||||
if (Startup.ProxyConnection != null)
|
||||
var proxyUrl = Engine.Server.Config.ProxyUrl;
|
||||
if (!string.IsNullOrWhiteSpace(proxyUrl))
|
||||
{
|
||||
proxyServer = new WebProxy(Startup.ProxyConnection, false);
|
||||
if (Engine.Server.Config.ProxyPort.HasValue)
|
||||
{
|
||||
proxyServer = new WebProxy(proxyUrl, Engine.Server.Config.ProxyPort.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
proxyServer = new WebProxy(proxyUrl);
|
||||
}
|
||||
var username = Engine.Server.Config.ProxyUsername;
|
||||
var password = Engine.Server.Config.ProxyPassword;
|
||||
if (!string.IsNullOrWhiteSpace(username) && !string.IsNullOrWhiteSpace(password))
|
||||
{
|
||||
var creds = new NetworkCredential(username, password);
|
||||
proxyServer.Credentials = creds;
|
||||
}
|
||||
proxyServer.BypassProxyOnLocal = false;
|
||||
useProxy = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,9 +37,25 @@ namespace Jackett.Utils.Clients
|
|||
cookies = new CookieContainer();
|
||||
var useProxy = false;
|
||||
WebProxy proxyServer = null;
|
||||
if (Startup.ProxyConnection != null)
|
||||
var proxyUrl = Engine.Server.Config.ProxyUrl;
|
||||
if (!string.IsNullOrWhiteSpace(proxyUrl))
|
||||
{
|
||||
proxyServer = new WebProxy(Startup.ProxyConnection, false);
|
||||
if (Engine.Server.Config.ProxyPort.HasValue)
|
||||
{
|
||||
proxyServer = new WebProxy(proxyUrl, Engine.Server.Config.ProxyPort.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
proxyServer = new WebProxy(proxyUrl);
|
||||
}
|
||||
var username = Engine.Server.Config.ProxyUsername;
|
||||
var password = Engine.Server.Config.ProxyPassword;
|
||||
if (!string.IsNullOrWhiteSpace(username) && !string.IsNullOrWhiteSpace(password))
|
||||
{
|
||||
var creds = new NetworkCredential(username, password);
|
||||
proxyServer.Credentials = creds;
|
||||
}
|
||||
proxyServer.BypassProxyOnLocal = false;
|
||||
useProxy = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,9 +31,9 @@ namespace Jackett.Utils.Clients
|
|||
override protected async Task<WebClientByteResult> Run(WebRequest request)
|
||||
{
|
||||
var args = new StringBuilder();
|
||||
if (Startup.ProxyConnection != null)
|
||||
if (Engine.Server.Config.Proxy != null)
|
||||
{
|
||||
args.AppendFormat("-x " + Startup.ProxyConnection + " ");
|
||||
args.AppendFormat("-x '" + Engine.Server.Config.Proxy + "' ");
|
||||
}
|
||||
|
||||
args.AppendFormat("--url \"{0}\" ", request.Url);
|
||||
|
|
Loading…
Reference in New Issue