mirror of
https://github.com/Jackett/Jackett.git
synced 2025-09-17 17:34:09 +02:00
@@ -85,6 +85,7 @@ function loadJackettSettings() {
|
||||
$("#jackett-proxy-port").val(data.proxy_port);
|
||||
$("#jackett-proxy-username").val(data.proxy_username);
|
||||
$("#jackett-proxy-password").val(data.proxy_password);
|
||||
proxyWarning(data.proxy_type);
|
||||
|
||||
$("#jackett-basepathoverride").val(data.basepathoverride);
|
||||
basePath = data.basepathoverride;
|
||||
@@ -114,10 +115,9 @@ function loadJackettSettings() {
|
||||
$.each(data.notices, function (index, value) {
|
||||
console.log(value);
|
||||
doNotify(value, "danger", "glyphicon glyphicon-alert", false);
|
||||
})
|
||||
});
|
||||
|
||||
reloadIndexers();
|
||||
proxyWarning(data.proxy_url);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1241,7 +1241,7 @@ function bindUIButtons() {
|
||||
doNotify("Redirecting you to complete configuration update..", "success", "glyphicon glyphicon-ok");
|
||||
window.setTimeout(function () {
|
||||
window.location.reload(true);
|
||||
}, 3000);
|
||||
}, 5000);
|
||||
}).fail(function (data) {
|
||||
if (data.responseJSON !== undefined && data.responseJSON.result == "error") {
|
||||
doNotify("Error: " + data.responseJSON.error, "danger", "glyphicon glyphicon-alert");
|
||||
@@ -1284,13 +1284,13 @@ function bindUIButtons() {
|
||||
});
|
||||
});
|
||||
|
||||
$('#jackett-proxy-url').on('input', function () {
|
||||
$('#jackett-proxy-type').on('input', function () {
|
||||
proxyWarning($(this).val());
|
||||
});
|
||||
}
|
||||
|
||||
function proxyWarning(input) {
|
||||
if (input != null && input.trim() !== "") {
|
||||
if (input != null && input.toString().trim() !== "-1") { // disabled = -1
|
||||
$('#proxy-warning').show();
|
||||
}
|
||||
else
|
||||
|
@@ -143,9 +143,10 @@
|
||||
<div class="input-area">
|
||||
<span class="input-header">Proxy type: </span>
|
||||
<select id="jackett-proxy-type" class="form-control input-right">
|
||||
<option value="0">http</option>
|
||||
<option value="1">socks4</option>
|
||||
<option value="2">socks5</option>
|
||||
<option value="-1">Disabled</option>
|
||||
<option value="0">HTTP</option>
|
||||
<option value="1">SOCKS4</option>
|
||||
<option value="2">SOCKS5</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="proxy-warning" hidden>
|
||||
@@ -154,8 +155,8 @@
|
||||
</span>
|
||||
</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="Blank to disable">
|
||||
<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>
|
||||
@@ -691,6 +692,6 @@
|
||||
</script>
|
||||
|
||||
<script type="text/javascript" src="../libs/api.js?changed=2017083001"></script>
|
||||
<script type="text/javascript" src="../custom.js?changed=20200410"></script>
|
||||
<script type="text/javascript" src="../custom.js?changed=20200926"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@@ -2,8 +2,9 @@ namespace Jackett.Common.Models.Config
|
||||
{
|
||||
public enum ProxyType
|
||||
{
|
||||
Disabled = -1,
|
||||
Http,
|
||||
Socks4,
|
||||
Socks5,
|
||||
Socks5
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Jackett.Common.Models.Config
|
||||
@@ -17,6 +18,13 @@ namespace Jackett.Common.Models.Config
|
||||
RuntimeSettings = runtimeSettings;
|
||||
}
|
||||
|
||||
[OnDeserialized]
|
||||
internal void OnDeserializedMethod(StreamingContext context)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(ProxyUrl))
|
||||
ProxyType = ProxyType.Disabled;
|
||||
}
|
||||
|
||||
public int Port { get; set; }
|
||||
public bool AllowExternal { get; set; }
|
||||
public string APIKey { get; set; }
|
||||
@@ -30,14 +38,14 @@ namespace Jackett.Common.Models.Config
|
||||
public string OmdbApiUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Ignore as we don't really want to be saving settings specified in the command line.
|
||||
/// Ignore as we don't really want to be saving settings specified in the command line.
|
||||
/// This is a bit of a hack, but in future it might not be all that bad to be able to override config values using settings that were provided at runtime. (and save them if required)
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public RuntimeSettings RuntimeSettings { get; set; }
|
||||
|
||||
public string ProxyUrl { get; set; }
|
||||
public ProxyType ProxyType { get; set; }
|
||||
public string ProxyUrl { get; set; }
|
||||
public int? ProxyPort { get; set; }
|
||||
public string ProxyUsername { get; set; }
|
||||
public string ProxyPassword { get; set; }
|
||||
@@ -49,34 +57,33 @@ namespace Jackett.Common.Models.Config
|
||||
? $"{ProxyUsername}:{ProxyPassword}"
|
||||
: null;
|
||||
|
||||
public string GetProxyUrl(bool withCreds = false)
|
||||
public string GetProxyUrl(bool withCreds = true)
|
||||
{
|
||||
var url = ProxyUrl;
|
||||
if (string.IsNullOrWhiteSpace(url))
|
||||
{
|
||||
|
||||
// if disabled
|
||||
if (ProxyType == ProxyType.Disabled || string.IsNullOrWhiteSpace(url))
|
||||
return null;
|
||||
}
|
||||
//remove protocol from url
|
||||
var index = url.IndexOf("://");
|
||||
|
||||
// remove protocol from url
|
||||
var index = url.IndexOf("://", StringComparison.Ordinal);
|
||||
if (index > -1)
|
||||
{
|
||||
url = url.Substring(index + 3);
|
||||
}
|
||||
|
||||
// add port
|
||||
url = ProxyPort.HasValue ? $"{url}:{ProxyPort}" : url;
|
||||
|
||||
// add credentials
|
||||
var authString = GetProxyAuthString();
|
||||
if (withCreds && authString != null)
|
||||
{
|
||||
url = $"{authString}@{url}";
|
||||
}
|
||||
|
||||
if (ProxyType != ProxyType.Http)
|
||||
// add protocol
|
||||
if (ProxyType == ProxyType.Socks4 || ProxyType == ProxyType.Socks5)
|
||||
{
|
||||
var protocol = (Enum.GetName(typeof(ProxyType), ProxyType) ?? "").ToLower();
|
||||
if (!string.IsNullOrEmpty(protocol))
|
||||
{
|
||||
url = $"{protocol}://{url}";
|
||||
}
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
@@ -37,45 +37,44 @@ namespace Jackett.Common.Utils.Clients
|
||||
if (webProxy is SocksWebProxy proxy)
|
||||
proxy.Dispose();
|
||||
webProxy = null;
|
||||
webProxyUrl = serverConfig.GetProxyUrl();
|
||||
if (!string.IsNullOrWhiteSpace(webProxyUrl))
|
||||
{
|
||||
if (serverConfig.ProxyType != ProxyType.Http)
|
||||
{
|
||||
var addresses = Dns.GetHostAddressesAsync(serverConfig.ProxyUrl).Result;
|
||||
var socksConfig = new ProxyConfig
|
||||
{
|
||||
SocksAddress = addresses.FirstOrDefault(),
|
||||
Username = serverConfig.ProxyUsername,
|
||||
Password = serverConfig.ProxyPassword,
|
||||
Version = serverConfig.ProxyType == ProxyType.Socks4 ?
|
||||
ProxyConfig.SocksVersion.Four :
|
||||
ProxyConfig.SocksVersion.Five
|
||||
};
|
||||
if (serverConfig.ProxyPort.HasValue)
|
||||
{
|
||||
socksConfig.SocksPort = serverConfig.ProxyPort.Value;
|
||||
}
|
||||
webProxy = new SocksWebProxy(socksConfig, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
NetworkCredential creds = null;
|
||||
if (!serverConfig.ProxyIsAnonymous)
|
||||
{
|
||||
var username = serverConfig.ProxyUsername;
|
||||
var password = serverConfig.ProxyPassword;
|
||||
creds = new NetworkCredential(username, password);
|
||||
}
|
||||
webProxy = new WebProxy(webProxyUrl)
|
||||
{
|
||||
BypassProxyOnLocal = false,
|
||||
Credentials = creds
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
webProxyUrl = serverConfig.GetProxyUrl();
|
||||
if (serverConfig.ProxyType == ProxyType.Disabled || string.IsNullOrWhiteSpace(webProxyUrl))
|
||||
return;
|
||||
if (serverConfig.ProxyType == ProxyType.Http)
|
||||
{
|
||||
NetworkCredential creds = null;
|
||||
if (!serverConfig.ProxyIsAnonymous)
|
||||
{
|
||||
var username = serverConfig.ProxyUsername;
|
||||
var password = serverConfig.ProxyPassword;
|
||||
creds = new NetworkCredential(username, password);
|
||||
}
|
||||
webProxy = new WebProxy(serverConfig.GetProxyUrl(false)) // proxy URL without credentials
|
||||
{
|
||||
BypassProxyOnLocal = false,
|
||||
Credentials = creds
|
||||
};
|
||||
}
|
||||
else if (serverConfig.ProxyType == ProxyType.Socks4 || serverConfig.ProxyType == ProxyType.Socks5)
|
||||
{
|
||||
var addresses = Dns.GetHostAddressesAsync(serverConfig.ProxyUrl).Result;
|
||||
var socksConfig = new ProxyConfig
|
||||
{
|
||||
SocksAddress = addresses.FirstOrDefault(),
|
||||
Username = serverConfig.ProxyUsername,
|
||||
Password = serverConfig.ProxyPassword,
|
||||
Version = serverConfig.ProxyType == ProxyType.Socks4 ?
|
||||
ProxyConfig.SocksVersion.Four :
|
||||
ProxyConfig.SocksVersion.Five
|
||||
};
|
||||
if (serverConfig.ProxyPort.HasValue)
|
||||
socksConfig.SocksPort = serverConfig.ProxyPort.Value;
|
||||
webProxy = new SocksWebProxy(socksConfig, false);
|
||||
}
|
||||
else
|
||||
throw new Exception($"Proxy type '{serverConfig.ProxyType}' is not implemented!");
|
||||
}
|
||||
|
||||
public double requestDelay
|
||||
{
|
||||
|
@@ -122,8 +122,8 @@ namespace Jackett.Server.Controllers
|
||||
if (config.proxy_port < 1 || config.proxy_port > 65535)
|
||||
throw new Exception("The port you have selected is invalid, it must be below 65535.");
|
||||
|
||||
serverConfig.ProxyType = string.IsNullOrWhiteSpace(config.proxy_url) ? ProxyType.Disabled : config.proxy_type;
|
||||
serverConfig.ProxyUrl = config.proxy_url;
|
||||
serverConfig.ProxyType = config.proxy_type;
|
||||
serverConfig.ProxyPort = config.proxy_port;
|
||||
serverConfig.ProxyUsername = config.proxy_username;
|
||||
serverConfig.ProxyPassword = config.proxy_password;
|
||||
|
@@ -137,7 +137,7 @@ namespace Jackett.Server.Services
|
||||
|
||||
logger.Info("App config/log directory: " + configService.GetAppDataFolder());
|
||||
|
||||
logger.Info("Using Proxy: " + (string.IsNullOrEmpty(config.ProxyUrl) ? "No" : config.ProxyType.ToString()));
|
||||
logger.Info($"Using proxy: {config.ProxyType}");
|
||||
|
||||
var monotype = Type.GetType("Mono.Runtime");
|
||||
if (monotype != null && !DotNetCoreUtil.IsRunningOnDotNetCore)
|
||||
|
Reference in New Issue
Block a user