diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Common/Authentication/PassthroughAuthentication.cs (renamed from src/slskd/API/Authentication/PassthroughAuthentication.cs) | 2 | ||||
| -rw-r--r-- | src/slskd/Common/Compute.cs | 8 | ||||
| -rw-r--r-- | src/slskd/Common/Cryptography/Pbkdf2.cs | 2 | ||||
| -rw-r--r-- | src/slskd/Common/Cryptography/X509.cs | 2 | ||||
| -rw-r--r-- | src/slskd/Common/Extensions.cs | 31 | ||||
| -rw-r--r-- | src/slskd/Common/Validation/Extensions.cs | 48 | ||||
| -rw-r--r-- | src/slskd/Common/Validation/X509CertificateAttribute.cs | 2 | ||||
| -rw-r--r-- | src/slskd/Program.cs | 2 | ||||
| -rw-r--r-- | src/slskd/Service/Application/API/Controllers/ApplicationController.cs (renamed from src/slskd/API/Controllers/ApplicationController.cs) | 2 | ||||
| -rw-r--r-- | src/slskd/Service/Application/API/Controllers/SessionController.cs (renamed from src/slskd/API/Controllers/SessionController.cs) | 4 | ||||
| -rw-r--r-- | src/slskd/Service/Application/API/DTO/LoginRequest.cs (renamed from src/slskd/API/DTO/LoginRequest.cs) | 2 | ||||
| -rw-r--r-- | src/slskd/Service/Application/API/DTO/TokenResponse.cs (renamed from src/slskd/API/DTO/TokenResponse.cs) | 2 | ||||
| -rw-r--r-- | src/slskd/Service/Application/Role.cs (renamed from src/slskd/Core/Security/Role.cs) | 2 | ||||
| -rw-r--r-- | src/slskd/Service/Exceptions/ApplicationShutdownException.cs (renamed from src/slskd/Core/Common/Exceptions/ApplicationShutdownException.cs) | 0 | ||||
| -rw-r--r-- | src/slskd/Service/Exceptions/SlskdException.cs (renamed from src/slskd/Core/Common/Exceptions/SlskdException.cs) | 0 | ||||
| -rw-r--r-- | src/slskd/Service/ISharedFileCache.cs (renamed from src/slskd/Core/ISharedFileCache.cs) | 2 | ||||
| -rw-r--r-- | src/slskd/Service/Messaging/API/Controllers/ConversationsController.cs (renamed from src/slskd/API/Controllers/ConversationsController.cs) | 4 | ||||
| -rw-r--r-- | src/slskd/Service/Messaging/API/Controllers/PublicChatController.cs (renamed from src/slskd/API/Controllers/PublicChatController.cs) | 2 | ||||
| -rw-r--r-- | src/slskd/Service/Messaging/API/Controllers/RoomsController.cs (renamed from src/slskd/API/Controllers/RoomsController.cs) | 4 | ||||
| -rw-r--r-- | src/slskd/Service/Messaging/API/DTO/PrivateMessageResponse.cs (renamed from src/slskd/API/DTO/PrivateMessageResponse.cs) | 4 | ||||
| -rw-r--r-- | src/slskd/Service/Messaging/API/DTO/RoomInfoResponse.cs (renamed from src/slskd/API/DTO/RoomInfoResponse.cs) | 2 | ||||
| -rw-r--r-- | src/slskd/Service/Messaging/API/DTO/RoomMessageResponse.cs (renamed from src/slskd/API/DTO/RoomMessageResponse.cs) | 4 | ||||
| -rw-r--r-- | src/slskd/Service/Messaging/API/DTO/RoomResponse.cs (renamed from src/slskd/API/DTO/RoomResponse.cs) | 4 | ||||
| -rw-r--r-- | src/slskd/Service/Messaging/API/DTO/UserDataResponse.cs | 85 | ||||
| -rw-r--r-- | src/slskd/Service/Messaging/ConversationTracker.cs (renamed from src/slskd/Core/Messaging/ConversationTracker.cs) | 0 | ||||
| -rw-r--r-- | src/slskd/Service/Messaging/Domain/PrivateMessage.cs (renamed from src/slskd/Core/Messaging/Domain/PrivateMessage.cs) | 0 | ||||
| -rw-r--r-- | src/slskd/Service/Messaging/Domain/Room.cs (renamed from src/slskd/Core/Messaging/Domain/Room.cs) | 0 | ||||
| -rw-r--r-- | src/slskd/Service/Messaging/Domain/RoomMessage.cs (renamed from src/slskd/Core/Messaging/Domain/RoomMessage.cs) | 0 | ||||
| -rw-r--r-- | src/slskd/Service/Messaging/IConversationTracker.cs (renamed from src/slskd/Core/Messaging/IConversationTracker.cs) | 0 | ||||
| -rw-r--r-- | src/slskd/Service/Messaging/IRoomTracker.cs (renamed from src/slskd/Core/Messaging/IRoomTracker.cs) | 0 | ||||
| -rw-r--r-- | src/slskd/Service/Messaging/RoomTracker.cs (renamed from src/slskd/Core/Messaging/RoomTracker.cs) | 0 | ||||
| -rw-r--r-- | src/slskd/Service/Peer/API/Controllers/PeersController.cs (renamed from src/slskd/API/Controllers/PeersController.cs) | 4 | ||||
| -rw-r--r-- | src/slskd/Service/Peer/API/DTO/UserDataResponse.cs (renamed from src/slskd/API/DTO/UserDataResponse.cs) | 2 | ||||
| -rw-r--r-- | src/slskd/Service/Peer/BrowseTracker.cs (renamed from src/slskd/Core/Peer/BrowseTracker.cs) | 0 | ||||
| -rw-r--r-- | src/slskd/Service/Peer/Domain/Info.cs (renamed from src/slskd/Core/Peer/Domain/Info.cs) | 0 | ||||
| -rw-r--r-- | src/slskd/Service/Peer/Domain/Status.cs (renamed from src/slskd/Core/Peer/Domain/Status.cs) | 0 | ||||
| -rw-r--r-- | src/slskd/Service/Peer/IBrowseTracker.cs (renamed from src/slskd/Core/Peer/IBrowseTracker.cs) | 0 | ||||
| -rw-r--r-- | src/slskd/Service/Peer/IPeerService.cs (renamed from src/slskd/Core/Peer/IPeerService.cs) | 0 | ||||
| -rw-r--r-- | src/slskd/Service/Peer/PeerDbContext.cs (renamed from src/slskd/Core/Peer/PeerDbContext.cs) | 0 | ||||
| -rw-r--r-- | src/slskd/Service/Peer/PeerService.cs (renamed from src/slskd/Core/Peer/PeerService.cs) | 0 | ||||
| -rw-r--r-- | src/slskd/Service/Search/API/Controllers/SearchesController.cs (renamed from src/slskd/API/Controllers/SearchesController.cs) | 4 | ||||
| -rw-r--r-- | src/slskd/Service/Search/API/DTO/SearchRequest.cs (renamed from src/slskd/API/DTO/SearchRequest.cs) | 2 | ||||
| -rw-r--r-- | src/slskd/Service/Search/Domain/File.cs (renamed from src/slskd/Core/Common/Domain/File.cs) | 2 | ||||
| -rw-r--r-- | src/slskd/Service/Search/Domain/Response.cs (renamed from src/slskd/Core/Search/Domain/Response.cs) | 0 | ||||
| -rw-r--r-- | src/slskd/Service/Search/Domain/Search.cs (renamed from src/slskd/Core/Search/Domain/Search.cs) | 0 | ||||
| -rw-r--r-- | src/slskd/Service/Search/Extensions.cs (renamed from src/slskd/Core/Search/Extensions.cs) | 0 | ||||
| -rw-r--r-- | src/slskd/Service/Search/ISearchService.cs (renamed from src/slskd/Core/Search/ISearchService.cs) | 0 | ||||
| -rw-r--r-- | src/slskd/Service/Search/SearchDbContext.cs (renamed from src/slskd/Core/Search/SearchDbContext.cs) | 0 | ||||
| -rw-r--r-- | src/slskd/Service/Search/SearchResponseCache.cs (renamed from src/slskd/Core/Search/SearchResponseCache.cs) | 0 | ||||
| -rw-r--r-- | src/slskd/Service/Search/SearchService.cs (renamed from src/slskd/Core/Search/SearchService.cs) | 0 | ||||
| -rw-r--r-- | src/slskd/Service/Server/API/Controllers/ServerController.cs (renamed from src/slskd/API/Controllers/ServerController.cs) | 3 | ||||
| -rw-r--r-- | src/slskd/Service/Server/API/DTO/ConnectRequest.cs (renamed from src/slskd/API/DTO/ConnectRequest.cs) | 2 | ||||
| -rw-r--r-- | src/slskd/Service/Service.cs (renamed from src/slskd/Core/Service.cs) | 1 | ||||
| -rw-r--r-- | src/slskd/Service/SharedFileCache.cs (renamed from src/slskd/Core/SharedFileCache.cs) | 2 | ||||
| -rw-r--r-- | src/slskd/Service/Transfer/API/Controllers/TransfersController.cs (renamed from src/slskd/API/Controllers/TransfersController.cs) | 6 | ||||
| -rw-r--r-- | src/slskd/Service/Transfer/API/DTO/QueueDownloadRequest.cs (renamed from src/slskd/API/DTO/QueueDownloadRequest.cs) | 2 | ||||
| -rw-r--r-- | src/slskd/Service/Transfer/API/DTO/Transfer.cs (renamed from src/slskd/API/DTO/Transfer.cs) | 4 | ||||
| -rw-r--r-- | src/slskd/Service/Transfer/ITransferTracker.cs (renamed from src/slskd/Core/Transfer/ITransferTracker.cs) | 4 | ||||
| -rw-r--r-- | src/slskd/Service/Transfer/TransferTracker.cs (renamed from src/slskd/Core/Transfer/TransferTracker.cs) | 38 | ||||
| -rw-r--r-- | src/slskd/Service/UserEndPointCache.cs (renamed from src/slskd/Common/UserEndPointCache.cs) | 0 | ||||
| -rw-r--r-- | src/slskd/Startup.cs | 3 |
61 files changed, 198 insertions, 101 deletions
diff --git a/src/slskd/API/Authentication/PassthroughAuthentication.cs b/src/slskd/Common/Authentication/PassthroughAuthentication.cs index 65bbb7db..5f186aea 100644 --- a/src/slskd/API/Authentication/PassthroughAuthentication.cs +++ b/src/slskd/Common/Authentication/PassthroughAuthentication.cs @@ -15,7 +15,7 @@ // along with this program. If not, see https://www.gnu.org/licenses/. // </copyright> -namespace slskd.API.Authentication +namespace slskd.Authentication { using System.Security.Principal; using System.Text.Encodings.Web; diff --git a/src/slskd/Common/Compute.cs b/src/slskd/Common/Compute.cs index 172de252..3d913d27 100644 --- a/src/slskd/Common/Compute.cs +++ b/src/slskd/Common/Compute.cs @@ -18,6 +18,8 @@ namespace slskd { using System; + using System.Security.Cryptography; + using System.Text; /// <summary> /// Computational functions. @@ -35,5 +37,11 @@ namespace slskd return (clampedDelay, jitter); } + + public static string Sha1Hash(string str) + { + using var sha1 = new SHA1Managed(); + return BitConverter.ToString(sha1.ComputeHash(Encoding.UTF8.GetBytes(str))).Replace("-", string.Empty); + } } }
\ No newline at end of file diff --git a/src/slskd/Common/Cryptography/Pbkdf2.cs b/src/slskd/Common/Cryptography/Pbkdf2.cs index f6509a73..3c3246d6 100644 --- a/src/slskd/Common/Cryptography/Pbkdf2.cs +++ b/src/slskd/Common/Cryptography/Pbkdf2.cs @@ -15,7 +15,7 @@ // along with this program. If not, see https://www.gnu.org/licenses/. // </copyright> -namespace slskd.Security +namespace slskd.Cryptography { using System.Security.Cryptography; using Microsoft.AspNetCore.Cryptography.KeyDerivation; diff --git a/src/slskd/Common/Cryptography/X509.cs b/src/slskd/Common/Cryptography/X509.cs index 95743cc0..6356d1e1 100644 --- a/src/slskd/Common/Cryptography/X509.cs +++ b/src/slskd/Common/Cryptography/X509.cs @@ -15,7 +15,7 @@ // along with this program. If not, see https://www.gnu.org/licenses/. // </copyright> -namespace slskd.Common.Cryptography +namespace slskd.Cryptography { using System; using System.Security.Cryptography; diff --git a/src/slskd/Common/Extensions.cs b/src/slskd/Common/Extensions.cs index 32cbf443..a7a89a71 100644 --- a/src/slskd/Common/Extensions.cs +++ b/src/slskd/Common/Extensions.cs @@ -55,17 +55,6 @@ namespace slskd } /// <summary> - /// Returns the SHA1 hash of the given string. - /// </summary> - /// <param name="str">The string to hash.</param> - /// <returns>The hash.</returns> - public static string Sha1(this string str) - { - using var sha1 = new SHA1Managed(); - return BitConverter.ToString(sha1.ComputeHash(Encoding.UTF8.GetBytes(str))).Replace("-", string.Empty); - } - - /// <summary> /// Formats byte to nearest size (KB, MB, etc.) /// </summary> /// <param name="value">The value to format.</param> @@ -148,25 +137,5 @@ namespace slskd { return path.Replace('\\', Path.DirectorySeparatorChar).Replace('/', Path.DirectorySeparatorChar); } - - /// <summary> - /// Validates options. - /// </summary> - /// <param name="options">The options instance to validate.</param> - /// <param name="result">The result of the validation, if invalid.</param> - /// <returns>A value indicating whether the instance is valid.</returns> - public static bool TryValidate(this Options options, out CompositeValidationResult result) - { - result = null; - var results = new List<ValidationResult>(); - - if (!Validator.TryValidateObject(options, new ValidationContext(options), results, true)) - { - result = new CompositeValidationResult("Invalid configuration", results); - return false; - } - - return true; - } } }
\ No newline at end of file diff --git a/src/slskd/Common/Validation/Extensions.cs b/src/slskd/Common/Validation/Extensions.cs new file mode 100644 index 00000000..b7e396a3 --- /dev/null +++ b/src/slskd/Common/Validation/Extensions.cs @@ -0,0 +1,48 @@ +// <copyright file="Extensions.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> + +namespace slskd.Validation +{ + using System.Collections.Generic; + using System.ComponentModel.DataAnnotations; + + /// <summary> + /// Extensions. + /// </summary> + public static class Extensions + { + /// <summary> + /// Validates options. + /// </summary> + /// <param name="options">The options instance to validate.</param> + /// <param name="result">The result of the validation, if invalid.</param> + /// <returns>A value indicating whether the instance is valid.</returns> + public static bool TryValidate(this Options options, out CompositeValidationResult result) + { + result = null; + var results = new List<ValidationResult>(); + + if (!Validator.TryValidateObject(options, new ValidationContext(options), results, true)) + { + result = new CompositeValidationResult("Invalid configuration", results); + return false; + } + + return true; + } + } +}
\ No newline at end of file diff --git a/src/slskd/Common/Validation/X509CertificateAttribute.cs b/src/slskd/Common/Validation/X509CertificateAttribute.cs index 1f0849f9..7a080882 100644 --- a/src/slskd/Common/Validation/X509CertificateAttribute.cs +++ b/src/slskd/Common/Validation/X509CertificateAttribute.cs @@ -18,7 +18,7 @@ namespace slskd.Validation { using System.ComponentModel.DataAnnotations; - using slskd.Common.Cryptography; + using slskd.Cryptography; using static slskd.Options.WebOptions.HttpsOptions; /// <summary> diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs index 42c3c508..78bf8b0e 100644 --- a/src/slskd/Program.cs +++ b/src/slskd/Program.cs @@ -36,8 +36,8 @@ namespace slskd using Serilog; using Serilog.Events; using Serilog.Sinks.Grafana.Loki; - using slskd.Common.Cryptography; using slskd.Configuration; + using slskd.Cryptography; using slskd.Validation; using Utility.CommandLine; using Utility.EnvironmentVariables; diff --git a/src/slskd/API/Controllers/ApplicationController.cs b/src/slskd/Service/Application/API/Controllers/ApplicationController.cs index 4b70b654..7fa59ff0 100644 --- a/src/slskd/API/Controllers/ApplicationController.cs +++ b/src/slskd/Service/Application/API/Controllers/ApplicationController.cs @@ -15,7 +15,7 @@ // along with this program. If not, see https://www.gnu.org/licenses/. // </copyright> -namespace slskd.API.Controllers +namespace slskd.Application.API { using System; using System.Diagnostics; diff --git a/src/slskd/API/Controllers/SessionController.cs b/src/slskd/Service/Application/API/Controllers/SessionController.cs index 2011aba3..b819dc57 100644 --- a/src/slskd/API/Controllers/SessionController.cs +++ b/src/slskd/Service/Application/API/Controllers/SessionController.cs @@ -15,7 +15,7 @@ // along with this program. If not, see https://www.gnu.org/licenses/. // </copyright> -namespace slskd.API.Controllers +namespace slskd.Application.API { using System; using System.Collections.Generic; @@ -24,8 +24,6 @@ namespace slskd.API.Controllers using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.IdentityModel.Tokens; - using slskd; - using slskd.API.DTO; /// <summary> /// Session. diff --git a/src/slskd/API/DTO/LoginRequest.cs b/src/slskd/Service/Application/API/DTO/LoginRequest.cs index 9f3ccf2e..2f1fb072 100644 --- a/src/slskd/API/DTO/LoginRequest.cs +++ b/src/slskd/Service/Application/API/DTO/LoginRequest.cs @@ -15,7 +15,7 @@ // along with this program. If not, see https://www.gnu.org/licenses/. // </copyright> -namespace slskd.API.DTO +namespace slskd.Application.API { public class LoginRequest { diff --git a/src/slskd/API/DTO/TokenResponse.cs b/src/slskd/Service/Application/API/DTO/TokenResponse.cs index c20e325c..2668d566 100644 --- a/src/slskd/API/DTO/TokenResponse.cs +++ b/src/slskd/Service/Application/API/DTO/TokenResponse.cs @@ -15,7 +15,7 @@ // along with this program. If not, see https://www.gnu.org/licenses/. // </copyright> -namespace slskd.API.DTO +namespace slskd.Application.API { using System; using System.IdentityModel.Tokens.Jwt; diff --git a/src/slskd/Core/Security/Role.cs b/src/slskd/Service/Application/Role.cs index 9c55a572..74ba7f81 100644 --- a/src/slskd/Core/Security/Role.cs +++ b/src/slskd/Service/Application/Role.cs @@ -15,7 +15,7 @@ // along with this program. If not, see https://www.gnu.org/licenses/. // </copyright> -namespace slskd +namespace slskd.Application { public enum Role { diff --git a/src/slskd/Core/Common/Exceptions/ApplicationShutdownException.cs b/src/slskd/Service/Exceptions/ApplicationShutdownException.cs index e30b5c79..e30b5c79 100644 --- a/src/slskd/Core/Common/Exceptions/ApplicationShutdownException.cs +++ b/src/slskd/Service/Exceptions/ApplicationShutdownException.cs diff --git a/src/slskd/Core/Common/Exceptions/SlskdException.cs b/src/slskd/Service/Exceptions/SlskdException.cs index 6b4cfc2a..6b4cfc2a 100644 --- a/src/slskd/Core/Common/Exceptions/SlskdException.cs +++ b/src/slskd/Service/Exceptions/SlskdException.cs diff --git a/src/slskd/Core/ISharedFileCache.cs b/src/slskd/Service/ISharedFileCache.cs index 960b906d..a7b8bf40 100644 --- a/src/slskd/Core/ISharedFileCache.cs +++ b/src/slskd/Service/ISharedFileCache.cs @@ -15,7 +15,7 @@ // along with this program. If not, see https://www.gnu.org/licenses/. // </copyright> -namespace slskd.Local +namespace slskd { using System; using System.Collections.Generic; diff --git a/src/slskd/API/Controllers/ConversationsController.cs b/src/slskd/Service/Messaging/API/Controllers/ConversationsController.cs index dafe5a71..2107ceb1 100644 --- a/src/slskd/API/Controllers/ConversationsController.cs +++ b/src/slskd/Service/Messaging/API/Controllers/ConversationsController.cs @@ -15,7 +15,7 @@ // along with this program. If not, see https://www.gnu.org/licenses/. // </copyright> -namespace slskd.API.Controllers +namespace slskd.Messaging.API { using System; using System.Collections.Generic; @@ -23,8 +23,6 @@ namespace slskd.API.Controllers using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; - using slskd.API.DTO; - using slskd.Messaging; using Soulseek; /// <summary> diff --git a/src/slskd/API/Controllers/PublicChatController.cs b/src/slskd/Service/Messaging/API/Controllers/PublicChatController.cs index 6bc54145..6868d3fb 100644 --- a/src/slskd/API/Controllers/PublicChatController.cs +++ b/src/slskd/Service/Messaging/API/Controllers/PublicChatController.cs @@ -15,7 +15,7 @@ // along with this program. If not, see https://www.gnu.org/licenses/. // </copyright> -namespace slskd.API.Controllers +namespace slskd.Messaging.API { using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; diff --git a/src/slskd/API/Controllers/RoomsController.cs b/src/slskd/Service/Messaging/API/Controllers/RoomsController.cs index d309555e..12789ef5 100644 --- a/src/slskd/API/Controllers/RoomsController.cs +++ b/src/slskd/Service/Messaging/API/Controllers/RoomsController.cs @@ -15,7 +15,7 @@ // along with this program. If not, see https://www.gnu.org/licenses/. // </copyright> -namespace slskd.API.Controllers +namespace slskd.Messaging.API { using System; using System.Collections.Generic; @@ -24,8 +24,6 @@ namespace slskd.API.Controllers using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; - using slskd.API.DTO; - using slskd.Messaging; using Soulseek; /// <summary> diff --git a/src/slskd/API/DTO/PrivateMessageResponse.cs b/src/slskd/Service/Messaging/API/DTO/PrivateMessageResponse.cs index 9794d762..a7e08d50 100644 --- a/src/slskd/API/DTO/PrivateMessageResponse.cs +++ b/src/slskd/Service/Messaging/API/DTO/PrivateMessageResponse.cs @@ -15,10 +15,10 @@ // along with this program. If not, see https://www.gnu.org/licenses/. // </copyright> -namespace slskd.API.DTO +namespace slskd.Messaging.API { - using slskd.Messaging; using System; + using slskd.Messaging; public class PrivateMessageResponse { diff --git a/src/slskd/API/DTO/RoomInfoResponse.cs b/src/slskd/Service/Messaging/API/DTO/RoomInfoResponse.cs index 6f135d56..46edbdc8 100644 --- a/src/slskd/API/DTO/RoomInfoResponse.cs +++ b/src/slskd/Service/Messaging/API/DTO/RoomInfoResponse.cs @@ -15,7 +15,7 @@ // along with this program. If not, see https://www.gnu.org/licenses/. // </copyright> -namespace slskd.API.DTO +namespace slskd.Messaging.API { using Soulseek; diff --git a/src/slskd/API/DTO/RoomMessageResponse.cs b/src/slskd/Service/Messaging/API/DTO/RoomMessageResponse.cs index 48a77f51..965c63a6 100644 --- a/src/slskd/API/DTO/RoomMessageResponse.cs +++ b/src/slskd/Service/Messaging/API/DTO/RoomMessageResponse.cs @@ -15,10 +15,10 @@ // along with this program. If not, see https://www.gnu.org/licenses/. // </copyright> -namespace slskd.API.DTO +namespace slskd.Messaging.API { - using slskd.Messaging; using System; + using slskd.Messaging; public class RoomMessageResponse { diff --git a/src/slskd/API/DTO/RoomResponse.cs b/src/slskd/Service/Messaging/API/DTO/RoomResponse.cs index 552cb7f5..cf7e1478 100644 --- a/src/slskd/API/DTO/RoomResponse.cs +++ b/src/slskd/Service/Messaging/API/DTO/RoomResponse.cs @@ -15,11 +15,11 @@ // along with this program. If not, see https://www.gnu.org/licenses/. // </copyright> -namespace slskd.API.DTO +namespace slskd.Messaging.API { - using slskd.Messaging; using System.Collections.Generic; using System.Linq; + using slskd.Messaging; public class RoomResponse { diff --git a/src/slskd/Service/Messaging/API/DTO/UserDataResponse.cs b/src/slskd/Service/Messaging/API/DTO/UserDataResponse.cs new file mode 100644 index 00000000..53b66c32 --- /dev/null +++ b/src/slskd/Service/Messaging/API/DTO/UserDataResponse.cs @@ -0,0 +1,85 @@ +// <copyright file="UserDataResponse.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> + +namespace slskd.Messaging.API +{ + using Soulseek; + + public class UserDataResponse + { + /// <summary> + /// The average upload speed of the user. + /// </summary> + public int AverageSpeed { get; set; } + + /// <summary> + /// The user's country code, if provided. + /// </summary> + public string CountryCode { get; set; } + + /// <summary> + /// The number of directories shared by the user. + /// </summary> + public int DirectoryCount { get; set; } + + /// <summary> + /// The number of active user downloads. + /// </summary> + public long DownloadCount { get; set; } + + /// <summary> + /// The number of files shared by the user. + /// </summary> + public int FileCount { get; set; } + + /// <summary> + /// A value indicating whether this user data belongs to the currently logged in user. + /// </summary> + public bool? Self { get; set; } + + /// <summary> + /// The number of the user's free download slots, if provided. + /// </summary> + public int? SlotsFree { get; set; } + + /// <summary> + /// The status of the user (0 = offline, 1 = away, 2 = online). + /// </summary> + public UserPresence Status { get; set; } + + /// <summary> + /// The username of the user. + /// </summary> + public string Username { get; set; } + + public static UserDataResponse FromUserData(UserData userData, bool self = false) + { + return new UserDataResponse() + { + AverageSpeed = userData.AverageSpeed, + CountryCode = userData.CountryCode, + DirectoryCount = userData.DirectoryCount, + DownloadCount = userData.DownloadCount, + FileCount = userData.FileCount, + SlotsFree = userData.SlotsFree, + Status = userData.Status, + Username = userData.Username, + Self = self ? self : (bool?)null, + }; + } + } +}
\ No newline at end of file diff --git a/src/slskd/Core/Messaging/ConversationTracker.cs b/src/slskd/Service/Messaging/ConversationTracker.cs index 27d678ca..27d678ca 100644 --- a/src/slskd/Core/Messaging/ConversationTracker.cs +++ b/src/slskd/Service/Messaging/ConversationTracker.cs diff --git a/src/slskd/Core/Messaging/Domain/PrivateMessage.cs b/src/slskd/Service/Messaging/Domain/PrivateMessage.cs index 236632aa..236632aa 100644 --- a/src/slskd/Core/Messaging/Domain/PrivateMessage.cs +++ b/src/slskd/Service/Messaging/Domain/PrivateMessage.cs diff --git a/src/slskd/Core/Messaging/Domain/Room.cs b/src/slskd/Service/Messaging/Domain/Room.cs index 459dea2c..459dea2c 100644 --- a/src/slskd/Core/Messaging/Domain/Room.cs +++ b/src/slskd/Service/Messaging/Domain/Room.cs diff --git a/src/slskd/Core/Messaging/Domain/RoomMessage.cs b/src/slskd/Service/Messaging/Domain/RoomMessage.cs index 7a06a192..7a06a192 100644 --- a/src/slskd/Core/Messaging/Domain/RoomMessage.cs +++ b/src/slskd/Service/Messaging/Domain/RoomMessage.cs diff --git a/src/slskd/Core/Messaging/IConversationTracker.cs b/src/slskd/Service/Messaging/IConversationTracker.cs index 8e7a90f4..8e7a90f4 100644 --- a/src/slskd/Core/Messaging/IConversationTracker.cs +++ b/src/slskd/Service/Messaging/IConversationTracker.cs diff --git a/src/slskd/Core/Messaging/IRoomTracker.cs b/src/slskd/Service/Messaging/IRoomTracker.cs index 225e5f69..225e5f69 100644 --- a/src/slskd/Core/Messaging/IRoomTracker.cs +++ b/src/slskd/Service/Messaging/IRoomTracker.cs diff --git a/src/slskd/Core/Messaging/RoomTracker.cs b/src/slskd/Service/Messaging/RoomTracker.cs index c586f401..c586f401 100644 --- a/src/slskd/Core/Messaging/RoomTracker.cs +++ b/src/slskd/Service/Messaging/RoomTracker.cs diff --git a/src/slskd/API/Controllers/PeersController.cs b/src/slskd/Service/Peer/API/Controllers/PeersController.cs index 81175984..94ce96dd 100644 --- a/src/slskd/API/Controllers/PeersController.cs +++ b/src/slskd/Service/Peer/API/Controllers/PeersController.cs @@ -15,7 +15,7 @@ // along with this program. If not, see https://www.gnu.org/licenses/. // </copyright> -namespace slskd.API.Controllers +namespace slskd.Peer.API { using System.Collections.Generic; using System.ComponentModel.DataAnnotations; @@ -23,7 +23,6 @@ namespace slskd.API.Controllers using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; - using slskd.Peer; using Soulseek; /// <summary> @@ -41,6 +40,7 @@ namespace slskd.API.Controllers /// </summary> /// <param name="client"></param> /// <param name="browseTracker"></param> + /// <param name="peerService"></param> public PeersController(ISoulseekClient client, IBrowseTracker browseTracker, IPeerService peerService) { Client = client; diff --git a/src/slskd/API/DTO/UserDataResponse.cs b/src/slskd/Service/Peer/API/DTO/UserDataResponse.cs index e854922e..024b1828 100644 --- a/src/slskd/API/DTO/UserDataResponse.cs +++ b/src/slskd/Service/Peer/API/DTO/UserDataResponse.cs @@ -15,7 +15,7 @@ // along with this program. If not, see https://www.gnu.org/licenses/. // </copyright> -namespace slskd.API.DTO +namespace slskd.Peer.API { using Soulseek; diff --git a/src/slskd/Core/Peer/BrowseTracker.cs b/src/slskd/Service/Peer/BrowseTracker.cs index 5fa6b14a..5fa6b14a 100644 --- a/src/slskd/Core/Peer/BrowseTracker.cs +++ b/src/slskd/Service/Peer/BrowseTracker.cs diff --git a/src/slskd/Core/Peer/Domain/Info.cs b/src/slskd/Service/Peer/Domain/Info.cs index b2d17c8a..b2d17c8a 100644 --- a/src/slskd/Core/Peer/Domain/Info.cs +++ b/src/slskd/Service/Peer/Domain/Info.cs diff --git a/src/slskd/Core/Peer/Domain/Status.cs b/src/slskd/Service/Peer/Domain/Status.cs index 4db4e859..4db4e859 100644 --- a/src/slskd/Core/Peer/Domain/Status.cs +++ b/src/slskd/Service/Peer/Domain/Status.cs diff --git a/src/slskd/Core/Peer/IBrowseTracker.cs b/src/slskd/Service/Peer/IBrowseTracker.cs index 606b8a45..606b8a45 100644 --- a/src/slskd/Core/Peer/IBrowseTracker.cs +++ b/src/slskd/Service/Peer/IBrowseTracker.cs diff --git a/src/slskd/Core/Peer/IPeerService.cs b/src/slskd/Service/Peer/IPeerService.cs index f49cf27b..f49cf27b 100644 --- a/src/slskd/Core/Peer/IPeerService.cs +++ b/src/slskd/Service/Peer/IPeerService.cs diff --git a/src/slskd/Core/Peer/PeerDbContext.cs b/src/slskd/Service/Peer/PeerDbContext.cs index ee5dfd04..ee5dfd04 100644 --- a/src/slskd/Core/Peer/PeerDbContext.cs +++ b/src/slskd/Service/Peer/PeerDbContext.cs diff --git a/src/slskd/Core/Peer/PeerService.cs b/src/slskd/Service/Peer/PeerService.cs index e0e03fa6..e0e03fa6 100644 --- a/src/slskd/Core/Peer/PeerService.cs +++ b/src/slskd/Service/Peer/PeerService.cs diff --git a/src/slskd/API/Controllers/SearchesController.cs b/src/slskd/Service/Search/API/Controllers/SearchesController.cs index 89095cb1..5f740044 100644 --- a/src/slskd/API/Controllers/SearchesController.cs +++ b/src/slskd/Service/Search/API/Controllers/SearchesController.cs @@ -15,15 +15,13 @@ // along with this program. If not, see https://www.gnu.org/licenses/. // </copyright> -namespace slskd.API.Controllers +namespace slskd.Search.API { using System; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; - using slskd.API.DTO; - using slskd.Search; using SearchQuery = Soulseek.SearchQuery; using SearchScope = Soulseek.SearchScope; diff --git a/src/slskd/API/DTO/SearchRequest.cs b/src/slskd/Service/Search/API/DTO/SearchRequest.cs index 147eb205..aad5a200 100644 --- a/src/slskd/API/DTO/SearchRequest.cs +++ b/src/slskd/Service/Search/API/DTO/SearchRequest.cs @@ -15,7 +15,7 @@ // along with this program. If not, see https://www.gnu.org/licenses/. // </copyright> -namespace slskd.API.DTO +namespace slskd.Search.API { using System; using Soulseek; diff --git a/src/slskd/Core/Common/Domain/File.cs b/src/slskd/Service/Search/Domain/File.cs index 079ec0f0..0a86eec3 100644 --- a/src/slskd/Core/Common/Domain/File.cs +++ b/src/slskd/Service/Search/Domain/File.cs @@ -15,7 +15,7 @@ // along with this program. If not, see https://www.gnu.org/licenses/. // </copyright> -namespace slskd +namespace slskd.Search { using SoulseekFile = Soulseek.File; diff --git a/src/slskd/Core/Search/Domain/Response.cs b/src/slskd/Service/Search/Domain/Response.cs index ea2e8993..ea2e8993 100644 --- a/src/slskd/Core/Search/Domain/Response.cs +++ b/src/slskd/Service/Search/Domain/Response.cs diff --git a/src/slskd/Core/Search/Domain/Search.cs b/src/slskd/Service/Search/Domain/Search.cs index b93c62cb..b93c62cb 100644 --- a/src/slskd/Core/Search/Domain/Search.cs +++ b/src/slskd/Service/Search/Domain/Search.cs diff --git a/src/slskd/Core/Search/Extensions.cs b/src/slskd/Service/Search/Extensions.cs index d52975d2..d52975d2 100644 --- a/src/slskd/Core/Search/Extensions.cs +++ b/src/slskd/Service/Search/Extensions.cs diff --git a/src/slskd/Core/Search/ISearchService.cs b/src/slskd/Service/Search/ISearchService.cs index d696617d..d696617d 100644 --- a/src/slskd/Core/Search/ISearchService.cs +++ b/src/slskd/Service/Search/ISearchService.cs diff --git a/src/slskd/Core/Search/SearchDbContext.cs b/src/slskd/Service/Search/SearchDbContext.cs index efb2fdd6..efb2fdd6 100644 --- a/src/slskd/Core/Search/SearchDbContext.cs +++ b/src/slskd/Service/Search/SearchDbContext.cs diff --git a/src/slskd/Core/Search/SearchResponseCache.cs b/src/slskd/Service/Search/SearchResponseCache.cs index c31a3a9b..c31a3a9b 100644 --- a/src/slskd/Core/Search/SearchResponseCache.cs +++ b/src/slskd/Service/Search/SearchResponseCache.cs diff --git a/src/slskd/Core/Search/SearchService.cs b/src/slskd/Service/Search/SearchService.cs index 84cfd756..84cfd756 100644 --- a/src/slskd/Core/Search/SearchService.cs +++ b/src/slskd/Service/Search/SearchService.cs diff --git a/src/slskd/API/Controllers/ServerController.cs b/src/slskd/Service/Server/API/Controllers/ServerController.cs index 5ec1ad93..66bc1ad6 100644 --- a/src/slskd/API/Controllers/ServerController.cs +++ b/src/slskd/Service/Server/API/Controllers/ServerController.cs @@ -15,12 +15,11 @@ // along with this program. If not, see https://www.gnu.org/licenses/. // </copyright> -namespace slskd.API.Controllers +namespace slskd.Server.API { using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; - using slskd.API.DTO; using Soulseek; /// <summary> diff --git a/src/slskd/API/DTO/ConnectRequest.cs b/src/slskd/Service/Server/API/DTO/ConnectRequest.cs index 155db2da..924052f3 100644 --- a/src/slskd/API/DTO/ConnectRequest.cs +++ b/src/slskd/Service/Server/API/DTO/ConnectRequest.cs @@ -15,7 +15,7 @@ // along with this program. If not, see https://www.gnu.org/licenses/. // </copyright> -namespace slskd.API.DTO +namespace slskd.Server.API { public class ConnectRequest { diff --git a/src/slskd/Core/Service.cs b/src/slskd/Service/Service.cs index 7a1e511f..246e7fc6 100644 --- a/src/slskd/Core/Service.cs +++ b/src/slskd/Service/Service.cs @@ -28,7 +28,6 @@ namespace slskd using Microsoft.Extensions.Options; using Serilog; using Serilog.Events; - using slskd.Local; using slskd.Messaging; using slskd.Peer; using slskd.Search; diff --git a/src/slskd/Core/SharedFileCache.cs b/src/slskd/Service/SharedFileCache.cs index fd6abaff..00496a47 100644 --- a/src/slskd/Core/SharedFileCache.cs +++ b/src/slskd/Service/SharedFileCache.cs @@ -15,7 +15,7 @@ // along with this program. If not, see https://www.gnu.org/licenses/. // </copyright> -namespace slskd.Local +namespace slskd { using System; using System.Collections.Generic; diff --git a/src/slskd/API/Controllers/TransfersController.cs b/src/slskd/Service/Transfer/API/Controllers/TransfersController.cs index 11c5dcad..f7274157 100644 --- a/src/slskd/API/Controllers/TransfersController.cs +++ b/src/slskd/Service/Transfer/API/Controllers/TransfersController.cs @@ -15,7 +15,7 @@ // along with this program. If not, see https://www.gnu.org/licenses/. // </copyright> -namespace slskd.API.Controllers +namespace slskd.Transfer.API { using System; using System.ComponentModel.DataAnnotations; @@ -25,8 +25,6 @@ namespace slskd.API.Controllers using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; - using slskd.API.DTO; - using slskd.Transfer; using Soulseek; /// <summary> @@ -203,7 +201,7 @@ namespace slskd.API.Controllers /// <response code="404">The specified download was not found.</response> [HttpGet("downloads/{username}/{id}")] [Authorize] - [ProducesResponseType(typeof(DTO.Transfer), 200)] + [ProducesResponseType(typeof(API.Transfer), 200)] [ProducesResponseType(404)] public async Task<IActionResult> GetPlaceInQueue([FromRoute, Required]string username, [FromRoute, Required]string id) { diff --git a/src/slskd/API/DTO/QueueDownloadRequest.cs b/src/slskd/Service/Transfer/API/DTO/QueueDownloadRequest.cs index a849fefa..2ec88007 100644 --- a/src/slskd/API/DTO/QueueDownloadRequest.cs +++ b/src/slskd/Service/Transfer/API/DTO/QueueDownloadRequest.cs @@ -15,7 +15,7 @@ // along with this program. If not, see https://www.gnu.org/licenses/. // </copyright> -namespace slskd.API.DTO +namespace slskd.Transfer.API { public class QueueDownloadRequest { diff --git a/src/slskd/API/DTO/Transfer.cs b/src/slskd/Service/Transfer/API/DTO/Transfer.cs index c3e4ac22..e182db1b 100644 --- a/src/slskd/API/DTO/Transfer.cs +++ b/src/slskd/Service/Transfer/API/DTO/Transfer.cs @@ -15,7 +15,7 @@ // along with this program. If not, see https://www.gnu.org/licenses/. // </copyright> -namespace slskd.API.DTO +namespace slskd.Transfer.API { using System; using System.Net; @@ -64,7 +64,7 @@ namespace slskd.API.DTO /// <summary> /// Gets the transfer id. /// </summary> - public string Id => Filename.Sha1(); + public string Id => Compute.Sha1Hash(Filename); /// <summary> /// Gets the ip endpoint of the remote transfer connection, if one has been established. diff --git a/src/slskd/Core/Transfer/ITransferTracker.cs b/src/slskd/Service/Transfer/ITransferTracker.cs index ebd20b90..0dd41129 100644 --- a/src/slskd/Core/Transfer/ITransferTracker.cs +++ b/src/slskd/Service/Transfer/ITransferTracker.cs @@ -29,7 +29,7 @@ namespace slskd.Transfer /// <summary> /// Tracked transfers. /// </summary> - ConcurrentDictionary<TransferDirection, ConcurrentDictionary<string, ConcurrentDictionary<string, (API.DTO.Transfer Transfer, CancellationTokenSource CancellationTokenSource)>>> Transfers { get; } + ConcurrentDictionary<TransferDirection, ConcurrentDictionary<string, ConcurrentDictionary<string, (API.Transfer Transfer, CancellationTokenSource CancellationTokenSource)>>> Transfers { get; } /// <summary> /// Adds or updates a tracked transfer. @@ -52,6 +52,6 @@ namespace slskd.Transfer /// <param name="id"></param> /// <param name="transfer"></param> /// <returns></returns> - bool TryGet(TransferDirection direction, string username, string id, out (API.DTO.Transfer Transfer, CancellationTokenSource CancellationTokenSource) transfer); + bool TryGet(TransferDirection direction, string username, string id, out (API.Transfer Transfer, CancellationTokenSource CancellationTokenSource) transfer); } }
\ No newline at end of file diff --git a/src/slskd/Core/Transfer/TransferTracker.cs b/src/slskd/Service/Transfer/TransferTracker.cs index 372a360e..bf0a0bdb 100644 --- a/src/slskd/Core/Transfer/TransferTracker.cs +++ b/src/slskd/Service/Transfer/TransferTracker.cs @@ -33,12 +33,12 @@ namespace slskd.Transfer /// <param name="directedTransfers"></param> /// <param name="username"></param> /// <returns></returns> - public static ConcurrentDictionary<string, (API.DTO.Transfer Transfer, CancellationTokenSource CancellationTokenSource)> FromUser( - this ConcurrentDictionary<string, ConcurrentDictionary<string, (API.DTO.Transfer Transfer, CancellationTokenSource CancellationTokenSource)>> directedTransfers, + public static ConcurrentDictionary<string, (API.Transfer Transfer, CancellationTokenSource CancellationTokenSource)> FromUser( + this ConcurrentDictionary<string, ConcurrentDictionary<string, (API.Transfer Transfer, CancellationTokenSource CancellationTokenSource)>> directedTransfers, string username) { directedTransfers.TryGetValue(username, out var transfers); - return transfers ?? new ConcurrentDictionary<string, (API.DTO.Transfer Transfer, CancellationTokenSource CancellationTokenSource)>(); + return transfers ?? new ConcurrentDictionary<string, (API.Transfer Transfer, CancellationTokenSource CancellationTokenSource)>(); } /// <summary> @@ -47,7 +47,7 @@ namespace slskd.Transfer /// <param name="directedTransfers"></param> /// <returns></returns> public static object ToMap( - this ConcurrentDictionary<string, ConcurrentDictionary<string, (API.DTO.Transfer Transfer, CancellationTokenSource CancellationTokenSource)>> directedTransfers) + this ConcurrentDictionary<string, ConcurrentDictionary<string, (API.Transfer Transfer, CancellationTokenSource CancellationTokenSource)>> directedTransfers) { return directedTransfers.Select(u => new { @@ -64,7 +64,7 @@ namespace slskd.Transfer /// <param name="userTransfers"></param> /// <returns></returns> public static object ToMap( - this ConcurrentDictionary<string, (API.DTO.Transfer Transfer, CancellationTokenSource CancellationTokenSource)> userTransfers) + this ConcurrentDictionary<string, (API.Transfer Transfer, CancellationTokenSource CancellationTokenSource)> userTransfers) { return userTransfers.Values .GroupBy(f => f.Transfer.Filename.DirectoryName()) @@ -77,12 +77,12 @@ namespace slskd.Transfer /// <param name="allTransfers"></param> /// <param name="direction"></param> /// <returns></returns> - public static ConcurrentDictionary<string, ConcurrentDictionary<string, (API.DTO.Transfer Transfer, CancellationTokenSource CancellationTokenSource)>> WithDirection( - this ConcurrentDictionary<TransferDirection, ConcurrentDictionary<string, ConcurrentDictionary<string, (API.DTO.Transfer Transfer, CancellationTokenSource CancellationTokenSource)>>> allTransfers, + public static ConcurrentDictionary<string, ConcurrentDictionary<string, (API.Transfer Transfer, CancellationTokenSource CancellationTokenSource)>> WithDirection( + this ConcurrentDictionary<TransferDirection, ConcurrentDictionary<string, ConcurrentDictionary<string, (API.Transfer Transfer, CancellationTokenSource CancellationTokenSource)>>> allTransfers, TransferDirection direction) { allTransfers.TryGetValue(direction, out var transfers); - return transfers ?? new ConcurrentDictionary<string, ConcurrentDictionary<string, (API.DTO.Transfer Transfer, CancellationTokenSource CancellationTokenSource)>>(); + return transfers ?? new ConcurrentDictionary<string, ConcurrentDictionary<string, (API.Transfer Transfer, CancellationTokenSource CancellationTokenSource)>>(); } /// <summary> @@ -91,8 +91,8 @@ namespace slskd.Transfer /// <param name="userTransfers"></param> /// <param name="id"></param> /// <returns></returns> - public static (API.DTO.Transfer Transfer, CancellationTokenSource CancellationTokenSource) WithId( - this ConcurrentDictionary<string, (API.DTO.Transfer Transfer, CancellationTokenSource CancellationTokenSource)> userTransfers, + public static (API.Transfer Transfer, CancellationTokenSource CancellationTokenSource) WithId( + this ConcurrentDictionary<string, (API.Transfer Transfer, CancellationTokenSource CancellationTokenSource)> userTransfers, string id) { userTransfers.TryGetValue(id, out var transfer); @@ -110,15 +110,15 @@ namespace slskd.Transfer /// </summary> public TransferTracker() { - Transfers.TryAdd(TransferDirection.Download, new ConcurrentDictionary<string, ConcurrentDictionary<string, (API.DTO.Transfer Transfer, CancellationTokenSource CancellationTokenSource)>>()); - Transfers.TryAdd(TransferDirection.Upload, new ConcurrentDictionary<string, ConcurrentDictionary<string, (API.DTO.Transfer Transfer, CancellationTokenSource CancellationTokenSource)>>()); + Transfers.TryAdd(TransferDirection.Download, new ConcurrentDictionary<string, ConcurrentDictionary<string, (API.Transfer Transfer, CancellationTokenSource CancellationTokenSource)>>()); + Transfers.TryAdd(TransferDirection.Upload, new ConcurrentDictionary<string, ConcurrentDictionary<string, (API.Transfer Transfer, CancellationTokenSource CancellationTokenSource)>>()); } /// <summary> /// Gets tracked transfers. /// </summary> - public ConcurrentDictionary<TransferDirection, ConcurrentDictionary<string, ConcurrentDictionary<string, (API.DTO.Transfer Transfer, CancellationTokenSource CancellationTokenSource)>>> Transfers { get; private set; } = - new ConcurrentDictionary<TransferDirection, ConcurrentDictionary<string, ConcurrentDictionary<string, (API.DTO.Transfer, CancellationTokenSource)>>>(); + public ConcurrentDictionary<TransferDirection, ConcurrentDictionary<string, ConcurrentDictionary<string, (API.Transfer Transfer, CancellationTokenSource CancellationTokenSource)>>> Transfers { get; private set; } = + new ConcurrentDictionary<TransferDirection, ConcurrentDictionary<string, ConcurrentDictionary<string, (API.Transfer, CancellationTokenSource)>>>(); /// <summary> /// Adds or updates a tracked transfer. @@ -131,7 +131,7 @@ namespace slskd.Transfer direction.AddOrUpdate(args.Transfer.Username, GetNewDictionaryForUser(args, cancellationTokenSource), (user, dict) => { - var transfer = API.DTO.Transfer.FromSoulseekTransfer(args.Transfer); + var transfer = API.Transfer.FromSoulseekTransfer(args.Transfer); dict.AddOrUpdate(transfer.Id, (transfer, cancellationTokenSource), (id, record) => (transfer, cancellationTokenSource)); return dict; }); @@ -145,7 +145,7 @@ namespace slskd.Transfer /// <param name="id"></param> /// <param name="transfer"></param> /// <returns></returns> - public bool TryGet(TransferDirection direction, string username, string id, out (API.DTO.Transfer Transfer, CancellationTokenSource CancellationTokenSource) transfer) + public bool TryGet(TransferDirection direction, string username, string id, out (API.Transfer Transfer, CancellationTokenSource CancellationTokenSource) transfer) { transfer = default; @@ -181,10 +181,10 @@ namespace slskd.Transfer } } - private ConcurrentDictionary<string, (API.DTO.Transfer Transfer, CancellationTokenSource CancellationTokenSource)> GetNewDictionaryForUser(TransferEventArgs args, CancellationTokenSource cancellationTokenSource) + private ConcurrentDictionary<string, (API.Transfer Transfer, CancellationTokenSource CancellationTokenSource)> GetNewDictionaryForUser(TransferEventArgs args, CancellationTokenSource cancellationTokenSource) { - var r = new ConcurrentDictionary<string, (API.DTO.Transfer Transfer, CancellationTokenSource CancellationTokenSource)>(); - var transfer = API.DTO.Transfer.FromSoulseekTransfer(args.Transfer); + var r = new ConcurrentDictionary<string, (API.Transfer Transfer, CancellationTokenSource CancellationTokenSource)>(); + var transfer = API.Transfer.FromSoulseekTransfer(args.Transfer); r.AddOrUpdate(transfer.Id, (transfer, cancellationTokenSource), (id, record) => (transfer, record.CancellationTokenSource)); return r; } diff --git a/src/slskd/Common/UserEndPointCache.cs b/src/slskd/Service/UserEndPointCache.cs index 29164cc4..29164cc4 100644 --- a/src/slskd/Common/UserEndPointCache.cs +++ b/src/slskd/Service/UserEndPointCache.cs diff --git a/src/slskd/Startup.cs b/src/slskd/Startup.cs index 0c8804f0..894c0e53 100644 --- a/src/slskd/Startup.cs +++ b/src/slskd/Startup.cs @@ -34,11 +34,10 @@ namespace slskd using Prometheus.SystemMetrics; using Serilog; using slskd.API.Authentication; - using slskd.Local; + using slskd.Cryptography; using slskd.Messaging; using slskd.Peer; using slskd.Search; - using slskd.Security; using slskd.Transfer; /// <summary> |
