aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2024-01-27 18:52:53 -0600
committerJP Dillingham <jp@dillingham.me>2024-01-27 18:52:53 -0600
commit0d4395bb2d558f83924331a565cecf12dee3e691 (patch)
treebf6bed89ed965a31d58a643dd2b0cecbb27ff672 /src/slskd
parent75543ab667cd8e62c38a5d3530a6783b3408fc15 (diff)
downloadslskd-0d4395bb2d558f83924331a565cecf12dee3e691.tar.gz
check if user's IP is blacklisted prior to sending search results
Diffstat (limited to 'src/slskd')
-rw-r--r--src/slskd/Application.cs15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs
index 70d726ab..be6213f3 100644
--- a/src/slskd/Application.cs
+++ b/src/slskd/Application.cs
@@ -1318,8 +1318,7 @@ namespace slskd
if (Users.IsBlacklisted(username))
{
- Log.Information("Returned empty search response for blacklisted user {Username}", username);
- return new SearchResponse(username, token, hasFreeUploadSlot: false, uploadSpeed: 0, queueLength: int.MaxValue, fileList: Enumerable.Empty<Soulseek.File>());
+ return null;
}
if (CompiledSearchResponseFilters.Any(filter => filter.IsMatch(query.SearchText)))
@@ -1348,7 +1347,19 @@ namespace slskd
if (results.Any())
{
+ // fetch the user's IP address so that we can check whether it's blacklisted.
+ // it's unfortunate that we have to do this to get the IP, but we have to do it
+ // anyway to send the results, and the information is cached. whether we do it here
+ // or Soulseek.NET does it under the hood doesn't really matter.
+ var endpoint = await Client.GetUserEndPointAsync(username);
+
+ if (Users.IsBlacklisted(username, endpoint.Address))
+ {
+ return null;
+ }
+
// make sure our average speed (as reported by the server) is reasonably up to date
+ // we do this because we send the information along with the search response
await RefreshUserStatistics();
// note: the following uses cached user data to determine group, so if the user's data