Add banned tracker setting.
This commit is contained in:
parent
21dd80a061
commit
02a97f3170
3 changed files with 67 additions and 4 deletions
|
|
@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## [Unreleased
|
## [Unreleased
|
||||||
|
|
||||||
|
## [2.0.116] - 2025-08-04
|
||||||
|
### Added
|
||||||
|
- Added setting to ban certain trackers from being added. Will filter by the torrent source or announcement urls.
|
||||||
|
|
||||||
## [2.0.115] - 2025-07-28
|
## [2.0.115] - 2025-07-28
|
||||||
### Added
|
### Added
|
||||||
- Added setting to delay the finish action.
|
- Added setting to delay the finish action.
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,10 @@ Supports the following parameters:
|
||||||
[Description("The time in minutes to cache the tracker list. Set to 0 to disable caching.")]
|
[Description("The time in minutes to cache the tracker list. Set to 0 to disable caching.")]
|
||||||
public Int32 TrackerEnrichmentCacheExpiration { get; set; } = 60;
|
public Int32 TrackerEnrichmentCacheExpiration { get; set; } = 60;
|
||||||
|
|
||||||
|
[DisplayName("Banned Trackers")]
|
||||||
|
[Description("Torrents that come from these trackers will not be allowed, this is a failsafe if you are accidentally downloading from private trackers. Will compare by keyword. Define multiple trackers by separating them with a comma.")]
|
||||||
|
public String? BannedTrackers { get; set; } = null;
|
||||||
|
|
||||||
[DisplayName("Disable update notifications")]
|
[DisplayName("Disable update notifications")]
|
||||||
[Description("Ignore update notifications. You will still be notified if the version you are running has a security vulnerability.")]
|
[Description("Ignore update notifications. You will still be notified if the version you are running has a security vulnerability.")]
|
||||||
public Boolean DisableUpdateNotifications { get; set; } = false;
|
public Boolean DisableUpdateNotifications { get; set; } = false;
|
||||||
|
|
|
||||||
|
|
@ -122,6 +122,32 @@ public class Torrents(
|
||||||
throw new($"{ex.Message}, trying to parse {magnetLink}");
|
throw new($"{ex.Message}, trying to parse {magnetLink}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!String.IsNullOrWhiteSpace(Settings.Get.General.BannedTrackers))
|
||||||
|
{
|
||||||
|
var bannedTrackers = Settings.Get.General.BannedTrackers.Split(',');
|
||||||
|
|
||||||
|
foreach (var bannedTracker in bannedTrackers)
|
||||||
|
{
|
||||||
|
var bannedTrackerCompare = bannedTracker.Trim().ToLower();
|
||||||
|
|
||||||
|
if (String.IsNullOrWhiteSpace(bannedTrackerCompare))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (magnet.AnnounceUrls != null)
|
||||||
|
{
|
||||||
|
var bannedUrls = magnet.AnnounceUrls.Where(m => m.Trim().ToLower().Contains(bannedTrackerCompare)).ToList();
|
||||||
|
|
||||||
|
if (bannedUrls.Count > 0)
|
||||||
|
{
|
||||||
|
var bannedUrlsString = String.Join(", ", bannedUrls);
|
||||||
|
throw new($"Cannot add torrent, the torrent contains banned trackers: {bannedUrlsString}.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
torrent.RdStatus = TorrentStatus.Queued;
|
torrent.RdStatus = TorrentStatus.Queued;
|
||||||
torrent.RdName = magnet.Name;
|
torrent.RdName = magnet.Name;
|
||||||
|
|
||||||
|
|
@ -162,6 +188,37 @@ public class Torrents(
|
||||||
throw new($"{ex.Message}, trying to parse {fileAsBase64}");
|
throw new($"{ex.Message}, trying to parse {fileAsBase64}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!String.IsNullOrWhiteSpace(Settings.Get.General.BannedTrackers))
|
||||||
|
{
|
||||||
|
var bannedTrackers = Settings.Get.General.BannedTrackers.Split(',');
|
||||||
|
|
||||||
|
foreach (var bannedTracker in bannedTrackers)
|
||||||
|
{
|
||||||
|
var bannedTrackerCompare = bannedTracker.Trim().ToLower();
|
||||||
|
|
||||||
|
if (String.IsNullOrWhiteSpace(bannedTrackerCompare))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!String.IsNullOrWhiteSpace(monoTorrent.Source) && monoTorrent.Source.Contains(bannedTracker))
|
||||||
|
{
|
||||||
|
throw new($"Cannot add torrent, the torrent source '{monoTorrent.Source}' is a banned tracker.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (monoTorrent.AnnounceUrls != null)
|
||||||
|
{
|
||||||
|
var bannedUrls = monoTorrent.AnnounceUrls.SelectMany(m => m).Where(m => m.Trim().ToLower().Contains(bannedTrackerCompare)).ToList();
|
||||||
|
|
||||||
|
if (bannedUrls.Count > 0)
|
||||||
|
{
|
||||||
|
var bannedUrlsString = String.Join(", ", bannedUrls);
|
||||||
|
throw new($"Cannot add torrent, the torrent contains banned trackers: {bannedUrlsString}.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
torrent.RdStatus = TorrentStatus.Queued;
|
torrent.RdStatus = TorrentStatus.Queued;
|
||||||
torrent.RdName = monoTorrent.Name;
|
torrent.RdName = monoTorrent.Name;
|
||||||
|
|
||||||
|
|
@ -224,7 +281,7 @@ public class Torrents(
|
||||||
/// <param name="torrent">The torrent from the database to upload to the debrid provider</param>
|
/// <param name="torrent">The torrent from the database to upload to the debrid provider</param>
|
||||||
/// <returns>Updated torrent</returns>
|
/// <returns>Updated torrent</returns>
|
||||||
/// <exception cref="Exception">When RdId is not null or FileOrMagnet is null.</exception>
|
/// <exception cref="Exception">When RdId is not null or FileOrMagnet is null.</exception>
|
||||||
public async Task<Torrent> DequeueFromDebridQueue(Torrent torrent)
|
public async Task DequeueFromDebridQueue(Torrent torrent)
|
||||||
{
|
{
|
||||||
if (torrent.RdId != null)
|
if (torrent.RdId != null)
|
||||||
{
|
{
|
||||||
|
|
@ -249,8 +306,6 @@ public class Torrents(
|
||||||
await torrentData.UpdateRdId(torrent, id);
|
await torrentData.UpdateRdId(torrent, id);
|
||||||
|
|
||||||
await UpdateTorrentClientData(torrent);
|
await UpdateTorrentClientData(torrent);
|
||||||
|
|
||||||
return torrent;
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|
@ -465,7 +520,7 @@ public class Torrents(
|
||||||
|
|
||||||
Log($"Retrieving filename for", download, download.Torrent);
|
Log($"Retrieving filename for", download, download.Torrent);
|
||||||
|
|
||||||
var fileName = await TorrentClient.GetFileName(download!);
|
var fileName = await TorrentClient.GetFileName(download);
|
||||||
|
|
||||||
await downloads.UpdateFileName(downloadId, fileName);
|
await downloads.UpdateFileName(downloadId, fileName);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue