aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Application.cs
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2026-04-24 09:44:44 -0500
committerJP Dillingham <jp@dillingham.me>2026-04-24 09:44:44 -0500
commit64fb4c12a013ed1b50ddcf57fb4bd16decb928f0 (patch)
tree3d647cf4f912fa6437e0d0030e99f577e6f0a2c7 /src/slskd/Application.cs
parent19fba8293b472939d74ed23232577cbfdf523586 (diff)
parentfc722e4a78aa5369fcd5ca0d8e88bd98d874a1d8 (diff)
downloadslskd-64fb4c12a013ed1b50ddcf57fb4bd16decb928f0.tar.gz
Merge remote-tracking branch 'origin/master' into retries
Diffstat (limited to 'src/slskd/Application.cs')
-rw-r--r--src/slskd/Application.cs62
1 files changed, 43 insertions, 19 deletions
diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs
index 5a81ae8f..e36a5539 100644
--- a/src/slskd/Application.cs
+++ b/src/slskd/Application.cs
@@ -1,18 +1,33 @@
-// <copyright file="Application.cs" company="slskd Team">
-// Copyright (c) slskd Team. All rights reserved.
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Affero General Public License as published
-// by the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU Affero General Public License for more details.
-//
-// You should have received a copy of the GNU Affero General Public License
-// along with this program. If not, see https://www.gnu.org/licenses/.
+// <copyright file="Application.cs" company="JP Dillingham">
+// ▄▄▄▄ ▄▄▄▄ ▄▄▄▄
+// ▄▄▄▄▄▄█ █▄▄▄▄▄█ █▄▄▄▄▄█ █
+// █__ --█ █__ --█ ◄█ - █
+// █▄▄▄▄▄█▄▄█▄▄▄▄▄█▄▄█▄▄█▄▄▄▄▄█
+// ┍━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ━━━━ ━ ━┉ ┉ ┉
+// │ Copyright (c) JP Dillingham.
+// │
+// │ This program is free software: you can redistribute it and/or modify
+// │ it under the terms of the GNU Affero General Public License as published
+// │ by the Free Software Foundation, version 3.
+// │
+// │ This program is distributed in the hope that it will be useful,
+// │ but WITHOUT ANY WARRANTY; without even the implied warranty of
+// │ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// │ GNU Affero General Public License for more details.
+// │
+// │ You should have received a copy of the GNU Affero General Public License
+// │ along with this program. If not, see https://www.gnu.org/licenses/.
+// │
+// │ This program is distributed with Additional Terms pursuant to Section 7
+// │ of the AGPLv3. See the LICENSE file in the root directory of this
+// │ project for the complete terms and conditions.
+// │
+// │ https://slskd.org
+// │
+// ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ╌ ╌╌╌╌ ╌
+// │ SPDX-FileCopyrightText: JP Dillingham
+// │ SPDX-License-Identifier: AGPL-3.0-only
+// ╰───────────────────────────────────────────╶──── ─ ─── ─ ── ──┈ ┈
// </copyright>
using Microsoft.Extensions.Options;
@@ -79,6 +94,7 @@ namespace slskd
/// <summary>
/// The name of the blacklisted user group.
/// </summary>
+ [Obsolete("use IsBlacklisted instead")]
public const string BlacklistedGroup = "blacklisted";
private static readonly string ApplicationShutdownTransferExceptionMessage = "Application shut down";
@@ -1365,6 +1381,12 @@ namespace slskd
private Task<int?> PlaceInQueueResolver(string username, IPEndPoint endpoint, string filename)
{
+ if (Users.IsBlacklisted(username, endpoint.Address))
+ {
+ Log.Information("Returned empty directory listing for blacklisted user {Username} ({IP})", username, endpoint.Address);
+ return Task.FromResult<int?>(null);
+ }
+
try
{
var place = Transfers.Uploads.Queue.EstimatePosition(username, filename);
@@ -1437,7 +1459,7 @@ namespace slskd
foreach (var (property, fqn, left, right) in diff)
{
- static bool HasAttribute<T>(PropertyInfo property) => property.CustomAttributes.Any(a => a.AttributeType == typeof(T));
+ static bool HasAttribute<T>(PropertyInfo property) => property?.CustomAttributes.Any(a => a.AttributeType == typeof(T)) ?? false;
var requiresRestart = HasAttribute<RequiresRestartAttribute>(property);
var requiresReconnect = HasAttribute<RequiresReconnectAttribute>(property);
@@ -1484,8 +1506,8 @@ namespace slskd
var slskDiff = PreviousOptions.Soulseek.DiffWith(newOptions.Soulseek);
// determine whether any global upload or download options changed
- var transfersUploadDiff = PreviousOptions.Transfers.DiffWith(newOptions.Transfers.Upload);
- var transfersDownloadDiff = PreviousOptions.Transfers.DiffWith(newOptions.Transfers.Download);
+ var transfersUploadDiff = PreviousOptions.Transfers.Upload.DiffWith(newOptions.Transfers.Upload);
+ var transfersDownloadDiff = PreviousOptions.Transfers.Download.DiffWith(newOptions.Transfers.Download);
if (slskDiff.Any() || transfersUploadDiff.Any() || transfersDownloadDiff.Any())
{
@@ -1636,7 +1658,9 @@ namespace slskd
var sw = new Stopwatch();
sw.Start();
- if (Users.IsBlacklisted(username))
+ // opportunistically try and avoid performing the search if we have a cached blacklisted value, otherwise
+ // hold off on computing it and filling the cache until we have the user's IP
+ if (Users.IsBlacklisted(username, bypassCache: false))
{
return null;
}