aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Network/API/Hubs/NetworkHub.cs
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2022-10-28 18:07:36 -0500
committerGitHub <noreply@github.com>2022-10-28 18:07:36 -0500
commit889e5ae95c68ccf24c5c3fa0a3ec2dac04d6adbf (patch)
tree9f6a6ba924799c1eaefc37e29f304af049091d83 /src/slskd/Network/API/Hubs/NetworkHub.cs
parent028af934a264a91c831eac3561c5e24833b6ee38 (diff)
parentfc7448e522145b08facec806c59993e724a00b83 (diff)
downloadslskd-889e5ae95c68ccf24c5c3fa0a3ec2dac04d6adbf.tar.gz
Merge pull request #712 from slskd/more-network
More Network improvements
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