aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Relay
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2026-10-25 16:23:07 -0500
committerGitHub <noreply@github.com>2026-10-25 16:23:07 -0500
commit2b827344d11e7490b323defa898264cadbdb6089 (patch)
tree57fedb94861bb4116a8aed9cc7fecb5e87aa06ff /src/slskd/Relay
parenta4cce04d38544ad6d4c1506b9facb32407a79509 (diff)
parentbe81b3b85b21d502feaf4918a0da92f445f7c2ab (diff)
downloadslskd-2b827344d11e7490b323defa898264cadbdb6089.tar.gz
Merge pull request #1911 from slskd/auth
Refine access levels on a number of endpoints, number of small tweaks and adjustments
Diffstat (limited to 'src/slskd/Relay')
-rw-r--r--src/slskd/Relay/API/Hubs/RelayHub.cs3
-rw-r--r--src/slskd/Relay/RelayClient.cs15
2 files changed, 15 insertions, 3 deletions
diff --git a/src/slskd/Relay/API/Hubs/RelayHub.cs b/src/slskd/Relay/API/Hubs/RelayHub.cs
index 8430164c..e839cd1a 100644
--- a/src/slskd/Relay/API/Hubs/RelayHub.cs
+++ b/src/slskd/Relay/API/Hubs/RelayHub.cs
@@ -85,7 +85,7 @@ namespace slskd.Relay
/// <summary>
/// The relay SignalR hub.
/// </summary>
- [Authorize]
+ [Authorize(Policy = AuthPolicy.Any)]
public class RelayHub : Hub<IRelayHub>
{
/// <summary>
@@ -120,6 +120,7 @@ namespace slskd.Relay
{
Log.Debug("Agent connection {Id} from {IP} aborted; Relay is not enabled, or is not in Controller mode", Context.ConnectionId, GetRemoteIPAddress());
Context.Abort();
+ return;
}
var token = Relay.GenerateAuthenticationChallengeToken(Context.ConnectionId);
diff --git a/src/slskd/Relay/RelayClient.cs b/src/slskd/Relay/RelayClient.cs
index fef16573..cbcde3c4 100644
--- a/src/slskd/Relay/RelayClient.cs
+++ b/src/slskd/Relay/RelayClient.cs
@@ -148,7 +148,15 @@ namespace slskd.Relay
// the controller will send an authentication challenge immediately after connection
// wait for the auth handler to log in before proceeding with the initial share upload
- await LoggedInTaskCompletionSource.Task;
+ try
+ {
+ await LoggedInTaskCompletionSource.Task;
+ }
+ catch (Exception)
+ {
+ await StopAsync(cancellationToken);
+ throw;
+ }
Log.Information("Uploading shares...");
@@ -366,6 +374,7 @@ namespace slskd.Relay
catch (Exception ex)
{
Log.Error(ex, "Failed to handle authentication challenge: {Message}", ex.Message);
+ LoggedInTaskCompletionSource.TrySetException(ex);
}
}
@@ -375,6 +384,7 @@ namespace slskd.Relay
{
Log.Warning("Suspicious attempt to request file info containing unsafe path segments (one or more of path traversal characters '.' and '..'). Requested file: {filename}", filename);
await HubConnection.InvokeAsync(nameof(RelayHub.ReturnFileInfo), id, false, 0);
+ return;
}
Log.Information("Relay controller requested file info for {Filename} with ID {Id}", filename, id);
@@ -399,7 +409,8 @@ namespace slskd.Relay
if (FileSafety.ContainsTraversalSegments(filename))
{
Log.Warning("Suspicious attempt to request a file upload containing unsafe path segments (one or more of path traversal characters '.' and '..'). Requested file: {filename}", filename);
- await HubConnection.InvokeAsync(nameof(RelayHub.NotifyFileUploadFailed), token);
+ await HubConnection.InvokeAsync(nameof(RelayHub.NotifyFileUploadFailed), token, "Requested filename contains unsafe path segments");
+ return;
}
_ = Task.Run(async () =>