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-port").val(data.proxy_port);
|
||||||
$("#jackett-proxy-username").val(data.proxy_username);
|
$("#jackett-proxy-username").val(data.proxy_username);
|
||||||
$("#jackett-proxy-password").val(data.proxy_password);
|
$("#jackett-proxy-password").val(data.proxy_password);
|
||||||
|
proxyWarning(data.proxy_type);
|
||||||
|
|
||||||
$("#jackett-basepathoverride").val(data.basepathoverride);
|
$("#jackett-basepathoverride").val(data.basepathoverride);
|
||||||
basePath = data.basepathoverride;
|
basePath = data.basepathoverride;
|
||||||
@@ -114,10 +115,9 @@ function loadJackettSettings() {
|
|||||||
$.each(data.notices, function (index, value) {
|
$.each(data.notices, function (index, value) {
|
||||||
console.log(value);
|
console.log(value);
|
||||||
doNotify(value, "danger", "glyphicon glyphicon-alert", false);
|
doNotify(value, "danger", "glyphicon glyphicon-alert", false);
|
||||||
})
|
});
|
||||||
|
|
||||||
reloadIndexers();
|
reloadIndexers();
|
||||||
proxyWarning(data.proxy_url);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1241,7 +1241,7 @@ function bindUIButtons() {
|
|||||||
doNotify("Redirecting you to complete configuration update..", "success", "glyphicon glyphicon-ok");
|
doNotify("Redirecting you to complete configuration update..", "success", "glyphicon glyphicon-ok");
|
||||||
window.setTimeout(function () {
|
window.setTimeout(function () {
|
||||||
window.location.reload(true);
|
window.location.reload(true);
|
||||||
}, 3000);
|
}, 5000);
|
||||||
}).fail(function (data) {
|
}).fail(function (data) {
|
||||||
if (data.responseJSON !== undefined && data.responseJSON.result == "error") {
|
if (data.responseJSON !== undefined && data.responseJSON.result == "error") {
|
||||||
doNotify("Error: " + data.responseJSON.error, "danger", "glyphicon glyphicon-alert");
|
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());
|
proxyWarning($(this).val());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function proxyWarning(input) {
|
function proxyWarning(input) {
|
||||||
if (input != null && input.trim() !== "") {
|
if (input != null && input.toString().trim() !== "-1") { // disabled = -1
|
||||||
$('#proxy-warning').show();
|
$('#proxy-warning').show();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -143,9 +143,10 @@
|
|||||||
<div class="input-area">
|
<div class="input-area">
|
||||||
<span class="input-header">Proxy type: </span>
|
<span class="input-header">Proxy type: </span>
|
||||||
<select id="jackett-proxy-type" class="form-control input-right">
|
<select id="jackett-proxy-type" class="form-control input-right">
|
||||||
<option value="0">http</option>
|
<option value="-1">Disabled</option>
|
||||||
<option value="1">socks4</option>
|
<option value="0">HTTP</option>
|
||||||
<option value="2">socks5</option>
|
<option value="1">SOCKS4</option>
|
||||||
|
<option value="2">SOCKS5</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div id="proxy-warning" hidden>
|
<div id="proxy-warning" hidden>
|
||||||
@@ -154,8 +155,8 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="input-area">
|
<div class="input-area">
|
||||||
<span class="input-header">Proxy url: </span>
|
<span class="input-header">Proxy URL: </span>
|
||||||
<input id="jackett-proxy-url" class="form-control input-right" type="text" value="" placeholder="Blank to disable">
|
<input id="jackett-proxy-url" class="form-control input-right" type="text" value="" placeholder="">
|
||||||
</div>
|
</div>
|
||||||
<div class="input-area">
|
<div class="input-area">
|
||||||
<span class="input-header">Proxy port: </span>
|
<span class="input-header">Proxy port: </span>
|
||||||
@@ -691,6 +692,6 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/javascript" src="../libs/api.js?changed=2017083001"></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>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@@ -2,8 +2,9 @@ namespace Jackett.Common.Models.Config
|
|||||||
{
|
{
|
||||||
public enum ProxyType
|
public enum ProxyType
|
||||||
{
|
{
|
||||||
|
Disabled = -1,
|
||||||
Http,
|
Http,
|
||||||
Socks4,
|
Socks4,
|
||||||
Socks5,
|
Socks5
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Jackett.Common.Models.Config
|
namespace Jackett.Common.Models.Config
|
||||||
@@ -17,6 +18,13 @@ namespace Jackett.Common.Models.Config
|
|||||||
RuntimeSettings = runtimeSettings;
|
RuntimeSettings = runtimeSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[OnDeserialized]
|
||||||
|
internal void OnDeserializedMethod(StreamingContext context)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(ProxyUrl))
|
||||||
|
ProxyType = ProxyType.Disabled;
|
||||||
|
}
|
||||||
|
|
||||||
public int Port { get; set; }
|
public int Port { get; set; }
|
||||||
public bool AllowExternal { get; set; }
|
public bool AllowExternal { get; set; }
|
||||||
public string APIKey { get; set; }
|
public string APIKey { get; set; }
|
||||||
@@ -36,8 +44,8 @@ namespace Jackett.Common.Models.Config
|
|||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public RuntimeSettings RuntimeSettings { get; set; }
|
public RuntimeSettings RuntimeSettings { get; set; }
|
||||||
|
|
||||||
public string ProxyUrl { get; set; }
|
|
||||||
public ProxyType ProxyType { get; set; }
|
public ProxyType ProxyType { get; set; }
|
||||||
|
public string ProxyUrl { get; set; }
|
||||||
public int? ProxyPort { get; set; }
|
public int? ProxyPort { get; set; }
|
||||||
public string ProxyUsername { get; set; }
|
public string ProxyUsername { get; set; }
|
||||||
public string ProxyPassword { get; set; }
|
public string ProxyPassword { get; set; }
|
||||||
@@ -49,34 +57,33 @@ namespace Jackett.Common.Models.Config
|
|||||||
? $"{ProxyUsername}:{ProxyPassword}"
|
? $"{ProxyUsername}:{ProxyPassword}"
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
public string GetProxyUrl(bool withCreds = false)
|
public string GetProxyUrl(bool withCreds = true)
|
||||||
{
|
{
|
||||||
var url = ProxyUrl;
|
var url = ProxyUrl;
|
||||||
if (string.IsNullOrWhiteSpace(url))
|
|
||||||
{
|
// if disabled
|
||||||
|
if (ProxyType == ProxyType.Disabled || string.IsNullOrWhiteSpace(url))
|
||||||
return null;
|
return null;
|
||||||
}
|
|
||||||
//remove protocol from url
|
// remove protocol from url
|
||||||
var index = url.IndexOf("://");
|
var index = url.IndexOf("://", StringComparison.Ordinal);
|
||||||
if (index > -1)
|
if (index > -1)
|
||||||
{
|
|
||||||
url = url.Substring(index + 3);
|
url = url.Substring(index + 3);
|
||||||
}
|
|
||||||
|
// add port
|
||||||
url = ProxyPort.HasValue ? $"{url}:{ProxyPort}" : url;
|
url = ProxyPort.HasValue ? $"{url}:{ProxyPort}" : url;
|
||||||
|
|
||||||
|
// add credentials
|
||||||
var authString = GetProxyAuthString();
|
var authString = GetProxyAuthString();
|
||||||
if (withCreds && authString != null)
|
if (withCreds && authString != null)
|
||||||
{
|
|
||||||
url = $"{authString}@{url}";
|
url = $"{authString}@{url}";
|
||||||
}
|
|
||||||
|
|
||||||
if (ProxyType != ProxyType.Http)
|
// add protocol
|
||||||
|
if (ProxyType == ProxyType.Socks4 || ProxyType == ProxyType.Socks5)
|
||||||
{
|
{
|
||||||
var protocol = (Enum.GetName(typeof(ProxyType), ProxyType) ?? "").ToLower();
|
var protocol = (Enum.GetName(typeof(ProxyType), ProxyType) ?? "").ToLower();
|
||||||
if (!string.IsNullOrEmpty(protocol))
|
if (!string.IsNullOrEmpty(protocol))
|
||||||
{
|
|
||||||
url = $"{protocol}://{url}";
|
url = $"{protocol}://{url}";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
@@ -37,45 +37,44 @@ namespace Jackett.Common.Utils.Clients
|
|||||||
if (webProxy is SocksWebProxy proxy)
|
if (webProxy is SocksWebProxy proxy)
|
||||||
proxy.Dispose();
|
proxy.Dispose();
|
||||||
webProxy = null;
|
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
|
public double requestDelay
|
||||||
{
|
{
|
||||||
|
@@ -122,8 +122,8 @@ namespace Jackett.Server.Controllers
|
|||||||
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 below 65535.");
|
||||||
|
|
||||||
|
serverConfig.ProxyType = string.IsNullOrWhiteSpace(config.proxy_url) ? ProxyType.Disabled : config.proxy_type;
|
||||||
serverConfig.ProxyUrl = config.proxy_url;
|
serverConfig.ProxyUrl = config.proxy_url;
|
||||||
serverConfig.ProxyType = config.proxy_type;
|
|
||||||
serverConfig.ProxyPort = config.proxy_port;
|
serverConfig.ProxyPort = config.proxy_port;
|
||||||
serverConfig.ProxyUsername = config.proxy_username;
|
serverConfig.ProxyUsername = config.proxy_username;
|
||||||
serverConfig.ProxyPassword = config.proxy_password;
|
serverConfig.ProxyPassword = config.proxy_password;
|
||||||
|
@@ -137,7 +137,7 @@ namespace Jackett.Server.Services
|
|||||||
|
|
||||||
logger.Info("App config/log directory: " + configService.GetAppDataFolder());
|
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");
|
var monotype = Type.GetType("Mono.Runtime");
|
||||||
if (monotype != null && !DotNetCoreUtil.IsRunningOnDotNetCore)
|
if (monotype != null && !DotNetCoreUtil.IsRunningOnDotNetCore)
|
||||||
|
Reference in New Issue
Block a user