From f807e44a397b1d6d58be079d6c6e1f9e8e526e3e Mon Sep 17 00:00:00 2001 From: Lloyd Sparkes Date: Sun, 24 Apr 2016 17:01:01 +0100 Subject: [PATCH] Force to IPv4 --- .../Http/Dispatchers/ManagedHttpDispatcher.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/NzbDrone.Common/Http/Dispatchers/ManagedHttpDispatcher.cs b/src/NzbDrone.Common/Http/Dispatchers/ManagedHttpDispatcher.cs index 335da0898..a195e9185 100644 --- a/src/NzbDrone.Common/Http/Dispatchers/ManagedHttpDispatcher.cs +++ b/src/NzbDrone.Common/Http/Dispatchers/ManagedHttpDispatcher.cs @@ -32,13 +32,16 @@ namespace NzbDrone.Common.Http.Dispatchers if (request.Proxy != null && !request.Proxy.ShouldProxyBeBypassed(new Uri(request.Url.FullUri))) { - var proxyHost = request.Proxy.Host; - if(request.Proxy.Host == "localhost") - { - proxyHost = "127.0.0.1"; - } + var addresses = Dns.GetHostAddresses(request.Proxy.Host); - var addresses = Dns.GetHostAddresses(proxyHost); + if(addresses.Length > 1) + { + var ipv4Only = addresses.Where(a => a.AddressFamily == AddressFamily.InterNetwork); + if (ipv4Only.Any()) + { + addresses = ipv4Only.ToArray(); + } + } var socksUsername = request.Proxy.Username == null ? string.Empty : request.Proxy.Username; var socksPassword = request.Proxy.Password == null ? string.Empty : request.Proxy.Password;