aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Transfers/API
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2026-04-23 17:59:31 -0500
committerJP Dillingham <jp@dillingham.me>2026-04-23 17:59:31 -0500
commit2ac28fe1e35f17d12c6e1c2b09d4b7cb90c8d591 (patch)
tree98ad1585a57fb01c5506bb7962e7d292a9c987d9 /src/slskd/Transfers/API
parent5a47b87e6c03cd093ce07274479d5c1dcd7aa2b0 (diff)
downloadslskd-2ac28fe1e35f17d12c6e1c2b09d4b7cb90c8d591.tar.gz
don't try to download from blacklisted users
Diffstat (limited to 'src/slskd/Transfers/API')
-rw-r--r--src/slskd/Transfers/API/Controllers/TransfersController.cs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/slskd/Transfers/API/Controllers/TransfersController.cs b/src/slskd/Transfers/API/Controllers/TransfersController.cs
index 2ffd50d4..494ee722 100644
--- a/src/slskd/Transfers/API/Controllers/TransfersController.cs
+++ b/src/slskd/Transfers/API/Controllers/TransfersController.cs
@@ -44,6 +44,8 @@ namespace slskd.Transfers.API
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Serilog;
+ using slskd.Users;
+ using Soulseek;
/// <summary>
/// Transfers.
@@ -58,17 +60,21 @@ namespace slskd.Transfers.API
/// Initializes a new instance of the <see cref="TransfersController"/> class.
/// </summary>
/// <param name="optionsSnapshot"></param>
+ /// <param name="userService"></param>
/// <param name="transferService"></param>
public TransfersController(
ITransferService transferService,
+ IUserService userService,
IOptionsSnapshot<Options> optionsSnapshot)
{
Transfers = transferService;
+ Users = userService;
OptionsSnapshot = optionsSnapshot;
}
private static SemaphoreSlim DownloadRequestLimiter { get; } = new SemaphoreSlim(2, 2);
private ITransferService Transfers { get; }
+ private IUserService Users { get; }
private IOptionsSnapshot<Options> OptionsSnapshot { get; }
private ILogger Log { get; set; } = Serilog.Log.ForContext<TransfersController>();
@@ -253,6 +259,13 @@ namespace slskd.Transfers.API
try
{
+ var endpoint = await Users.GetIPEndPointAsync(username);
+
+ if (Users.IsBlacklisted(username, endpoint.Address))
+ {
+ throw new UserOfflineException($"User {username} appears to be offline");
+ }
+
var (enqueued, failed) = await Transfers.Downloads.EnqueueAsync(username, requests.Select(r => (r.Filename, r.Size)));
return StatusCode(201, new { Enqueued = enqueued, Failed = failed });
@@ -382,6 +395,11 @@ namespace slskd.Transfers.API
return Forbid();
}
+ if (Users.IsBlacklisted(username))
+ {
+ return NotFound();
+ }
+
if (!Guid.TryParse(id, out var guid))
{
return BadRequest();