mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-20 21:43:33 -07:00
Suggest adding IP to RPC whitelist for on failed Transmission auth
(cherry picked from commit f05e552e8e6dc02cd26444073ab9a678dcb36492)
This commit is contained in:
parent
35a46eca7b
commit
39f0e4d989
1 changed files with 19 additions and 16 deletions
|
@ -7,6 +7,7 @@ using System.Net;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Common.Cache;
|
using NzbDrone.Common.Cache;
|
||||||
|
using NzbDrone.Common.EnvironmentInfo;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Common.Http;
|
using NzbDrone.Common.Http;
|
||||||
using NzbDrone.Common.Serializer;
|
using NzbDrone.Common.Serializer;
|
||||||
|
@ -260,7 +261,7 @@ namespace NzbDrone.Core.Download.Clients.Transmission
|
||||||
|
|
||||||
private void AuthenticateClient(HttpRequestBuilder requestBuilder, TransmissionSettings settings, bool reauthenticate = false)
|
private void AuthenticateClient(HttpRequestBuilder requestBuilder, TransmissionSettings settings, bool reauthenticate = false)
|
||||||
{
|
{
|
||||||
var authKey = string.Format("{0}:{1}", requestBuilder.BaseUrl, settings.Password);
|
var authKey = $"{requestBuilder.BaseUrl}:{settings.Password}";
|
||||||
|
|
||||||
var sessionId = _authSessionIdCache.Find(authKey);
|
var sessionId = _authSessionIdCache.Find(authKey);
|
||||||
|
|
||||||
|
@ -272,23 +273,25 @@ namespace NzbDrone.Core.Download.Clients.Transmission
|
||||||
authLoginRequest.SuppressHttpError = true;
|
authLoginRequest.SuppressHttpError = true;
|
||||||
|
|
||||||
var response = _httpClient.Execute(authLoginRequest);
|
var response = _httpClient.Execute(authLoginRequest);
|
||||||
if (response.StatusCode == HttpStatusCode.MovedPermanently)
|
|
||||||
|
switch (response.StatusCode)
|
||||||
{
|
{
|
||||||
|
case HttpStatusCode.MovedPermanently:
|
||||||
var url = response.Headers.GetSingleValue("Location");
|
var url = response.Headers.GetSingleValue("Location");
|
||||||
|
|
||||||
throw new DownloadClientException("Remote site redirected to " + url);
|
throw new DownloadClientException("Remote site redirected to " + url);
|
||||||
}
|
case HttpStatusCode.Forbidden:
|
||||||
else if (response.StatusCode == HttpStatusCode.Conflict)
|
throw new DownloadClientException($"Failed to authenticate with Transmission. It may be necessary to add {BuildInfo.AppName}'s IP address to RPC whitelist.");
|
||||||
{
|
case HttpStatusCode.Conflict:
|
||||||
sessionId = response.Headers.GetSingleValue("X-Transmission-Session-Id");
|
sessionId = response.Headers.GetSingleValue("X-Transmission-Session-Id");
|
||||||
|
|
||||||
if (sessionId == null)
|
if (sessionId == null)
|
||||||
{
|
{
|
||||||
throw new DownloadClientException("Remote host did not return a Session Id.");
|
throw new DownloadClientException("Remote host did not return a Session Id.");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
break;
|
||||||
{
|
default:
|
||||||
throw new DownloadClientAuthenticationException("Failed to authenticate with Transmission.");
|
throw new DownloadClientAuthenticationException("Failed to authenticate with Transmission.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue