mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-21 14:03:29 -07:00
New: Newznab providers will be rejected if they are not valid addresses.
Tests added for checking DNS.
This commit is contained in:
parent
7e5445fa3a
commit
7a80c81ffb
3 changed files with 47 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using Ninject;
|
||||
using NLog;
|
||||
using NzbDrone.Core.Providers.Indexer;
|
||||
|
@ -56,7 +57,11 @@ namespace NzbDrone.Core.Providers
|
|||
var definitionsList = definitions.ToList();
|
||||
|
||||
//Cleanup the URL for each definition
|
||||
definitionsList.ForEach(p => p.Url = (new Uri(p.Url).ParentUriString()));
|
||||
foreach(var newznabDefinition in definitionsList)
|
||||
{
|
||||
CheckHostname(newznabDefinition.Url);
|
||||
newznabDefinition.Url = new Uri(newznabDefinition.Url).ParentUriString();
|
||||
}
|
||||
|
||||
_database.UpdateMany(definitionsList);
|
||||
}
|
||||
|
@ -99,5 +104,22 @@ namespace NzbDrone.Core.Providers
|
|||
{
|
||||
_database.Delete<NewznabDefinition>(id);
|
||||
}
|
||||
|
||||
public virtual void CheckHostname(string url)
|
||||
{
|
||||
try
|
||||
{
|
||||
var uri = new Uri(url);
|
||||
var hostname = uri.DnsSafeHost;
|
||||
|
||||
Dns.GetHostEntry(hostname);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error("Invalid address {0}, please correct the site URL.", url);
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue