Fixed: Indexer proxies not applying to requests

Fixes #1107
pull/1106/head
Qstick 2 years ago
parent bf2e057247
commit f97b35403d

@ -99,7 +99,7 @@ namespace NzbDrone.Common.Http.Dispatchers
AddRequestHeaders(requestMessage, request.Headers);
}
var httpClient = GetClient(request.Url);
var httpClient = GetClient(request.Url, request.ProxySettings);
var sw = new Stopwatch();
@ -154,9 +154,9 @@ namespace NzbDrone.Common.Http.Dispatchers
}
}
protected virtual System.Net.Http.HttpClient GetClient(HttpUri uri)
protected virtual System.Net.Http.HttpClient GetClient(HttpUri uri, HttpProxySettings requestProxy)
{
var proxySettings = _proxySettingsProvider.GetProxySettings(uri);
var proxySettings = requestProxy ?? _proxySettingsProvider.GetProxySettings(uri);
var key = proxySettings?.Key ?? NO_PROXY_KEY;

@ -6,6 +6,7 @@ using System.Net.Http;
using System.Text;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Http.Proxy;
namespace NzbDrone.Common.Http
{
@ -37,7 +38,7 @@ namespace NzbDrone.Common.Http
public HttpMethod Method { get; set; }
public HttpHeader Headers { get; set; }
public Encoding Encoding { get; set; }
public IWebProxy Proxy { get; set; }
public HttpProxySettings ProxySettings { get; set; }
public byte[] ContentData { get; set; }
public string ContentSummary { get; set; }
public ICredentials Credentials { get; set; }

@ -3,7 +3,9 @@ using NLog;
using NzbDrone.Common.Cloud;
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Http;
using NzbDrone.Common.Http.Proxy;
using NzbDrone.Core.Localization;
using NzbDrone.Core.Notifications.Prowl;
namespace NzbDrone.Core.IndexerProxies.Http
{
@ -18,14 +20,13 @@ namespace NzbDrone.Core.IndexerProxies.Http
public override HttpRequest PreRequest(HttpRequest request)
{
if (Settings.Username.IsNotNullOrWhiteSpace() && Settings.Password.IsNotNullOrWhiteSpace())
{
request.Proxy = new WebProxy(Settings.Host + ":" + Settings.Port, false, null, new NetworkCredential(Settings.Username, Settings.Password));
}
else
{
request.Proxy = new WebProxy(Settings.Host + ":" + Settings.Port, false, null);
}
request.ProxySettings = new HttpProxySettings(ProxyType.Http,
Settings.Host,
Settings.Port,
null,
false,
Settings.Username,
Settings.Password);
_logger.Debug("Applying HTTP(S) Proxy {0} to request {1}", Name, request.Url);

@ -4,6 +4,7 @@ using NLog;
using NzbDrone.Common.Cloud;
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Http;
using NzbDrone.Common.Http.Proxy;
using NzbDrone.Core.Localization;
namespace NzbDrone.Core.IndexerProxies.Socks4
@ -25,14 +26,13 @@ namespace NzbDrone.Core.IndexerProxies.Socks4
return null;
}
if (Settings.Username.IsNotNullOrWhiteSpace() && Settings.Password.IsNotNullOrWhiteSpace())
{
request.Proxy = new WebProxy(uri, false, null, new NetworkCredential(Settings.Username, Settings.Password));
}
else
{
request.Proxy = new WebProxy(uri);
}
request.ProxySettings = new HttpProxySettings(ProxyType.Socks4,
Settings.Host,
Settings.Port,
null,
false,
Settings.Username,
Settings.Password);
_logger.Debug("Applying Socks4 Proxy {0} to request {1}", Name, request.Url);

@ -4,6 +4,7 @@ using NLog;
using NzbDrone.Common.Cloud;
using NzbDrone.Common.Extensions;
using NzbDrone.Common.Http;
using NzbDrone.Common.Http.Proxy;
using NzbDrone.Core.Localization;
namespace NzbDrone.Core.IndexerProxies.Socks5
@ -26,14 +27,13 @@ namespace NzbDrone.Core.IndexerProxies.Socks5
return null;
}
if (Settings.Username.IsNotNullOrWhiteSpace() && Settings.Password.IsNotNullOrWhiteSpace())
{
request.Proxy = new WebProxy(uri, false, null, new NetworkCredential(Settings.Username, Settings.Password));
}
else
{
request.Proxy = new WebProxy(uri);
}
request.ProxySettings = new HttpProxySettings(ProxyType.Socks5,
Settings.Host,
Settings.Port,
null,
false,
Settings.Username,
Settings.Password);
_logger.Debug("Applying Socks5 Proxy {0} to request {1}", Name, request.Url);

Loading…
Cancel
Save