aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Network/API/Hubs/NetworkHub.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/slskd/Network/API/Hubs/NetworkHub.cs')
-rw-r--r--src/slskd/Network/API/Hubs/NetworkHub.cs17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/slskd/Network/API/Hubs/NetworkHub.cs b/src/slskd/Network/API/Hubs/NetworkHub.cs
index 298dd9ec..0ee80f9a 100644
--- a/src/slskd/Network/API/Hubs/NetworkHub.cs
+++ b/src/slskd/Network/API/Hubs/NetworkHub.cs
@@ -79,6 +79,7 @@ namespace slskd.Network
Log.Information("Agent connection {Id} authentication failed", Context.ConnectionId);
Network.TryDeregisterAgent(Context.ConnectionId, out var _); // just in case!
return false;
+ // todo: throw UnauthorizedAccessException()?
}
public Guid GetShareUploadToken()
@@ -97,12 +98,24 @@ namespace slskd.Network
public void NotifyUploadFailed(Guid id, Exception exception)
{
- Network.NotifyFileStreamException(id, exception);
+ if (Network.TryGetAgentRegistration(Context.ConnectionId, out var record))
+ {
+ Network.NotifyFileStreamException(id, exception);
+ }
+
+ Log.Warning("Agent connection {Id} attempted to report a failed upload, but is not registered.", Context.ConnectionId);
+ throw new UnauthorizedAccessException();
}
public void ReturnFileInfo(Guid id, bool exists, long length)
{
- Network.HandleFileInfoResponse(id, (exists, length));
+ if (Network.TryGetAgentRegistration(Context.ConnectionId, out var record))
+ {
+ Network.HandleFileInfoResponse(record.Agent.Name, id, (exists, length));
+ }
+
+ Log.Warning("Agent connection {Id} attempted to return file information, but is not registered.", Context.ConnectionId);
+ throw new UnauthorizedAccessException();
}
}
} \ No newline at end of file