From 3306af2414cefa8271191f8803921a9c3f066a7f Mon Sep 17 00:00:00 2001 From: nd Date: Sun, 25 Aug 2024 12:32:29 +0700 Subject: [PATCH 1/2] Update + Updated references --- .../Models/DiscoveryConfig.cs | 12 +++---- .../Models/DomainConfig.cs | 12 +++---- .../Models/EmailMapping.cs | 12 +++---- .../Models/Protocol.cs | 34 +++++++++---------- .../wan24-AutoDiscover Shared.csproj | 3 +- .../Controllers/DiscoveryController.cs | 4 ++- .../Services/CommandLineInterface.cs | 10 +++--- .../Services/ExceptionHandler.cs | 19 ++++++----- src/wan24-AutoDiscover/latest-release.txt | 2 +- .../wan24-AutoDiscover.csproj | 2 +- 10 files changed, 52 insertions(+), 58 deletions(-) diff --git a/src/wan24-AutoDiscover Shared/Models/DiscoveryConfig.cs b/src/wan24-AutoDiscover Shared/Models/DiscoveryConfig.cs index edf23f2..1e822b9 100644 --- a/src/wan24-AutoDiscover Shared/Models/DiscoveryConfig.cs +++ b/src/wan24-AutoDiscover Shared/Models/DiscoveryConfig.cs @@ -13,18 +13,16 @@ namespace wan24.AutoDiscover.Models /// /// Discovery configuration /// - public record class DiscoveryConfig : ValidatableRecordBase + /// + /// Constructor + /// + public record class DiscoveryConfig() : ValidatableRecordBase() { /// /// Discovery configuration type /// protected Type? _DiscoveryType = null; - /// - /// Constructor - /// - public DiscoveryConfig() : base() { } - /// /// Current configuration /// @@ -43,7 +41,7 @@ public DiscoveryConfig() : base() { } public int PreForkResponses { get; init; } = 10; /// - /// Dicovery configuration type name + /// Discovery configuration type name /// [StringLength(byte.MaxValue, MinimumLength = 1)] public string? DiscoveryTypeName { get; init; } diff --git a/src/wan24-AutoDiscover Shared/Models/DomainConfig.cs b/src/wan24-AutoDiscover Shared/Models/DomainConfig.cs index 4c4be5a..79528d0 100644 --- a/src/wan24-AutoDiscover Shared/Models/DomainConfig.cs +++ b/src/wan24-AutoDiscover Shared/Models/DomainConfig.cs @@ -6,13 +6,11 @@ namespace wan24.AutoDiscover.Models /// /// Domain configuration /// - public record class DomainConfig : ValidatableRecordBase + /// + /// Constructor + /// + public record class DomainConfig() : ValidatableRecordBase() { - /// - /// Constructor - /// - public DomainConfig() : base() { } - /// /// Registered domains (key is the served domain name) /// @@ -37,7 +35,7 @@ public DomainConfig() : base() { } public Dictionary? LoginNameMapping { get; set; } /// - /// If a successfule login name mapping is required (if no mapping was possible, the email address will be used as login name) + /// If a successful login name mapping is required (if no mapping was possible, the email address will be used as login name) /// public bool LoginNameMappingRequired { get; init; } diff --git a/src/wan24-AutoDiscover Shared/Models/EmailMapping.cs b/src/wan24-AutoDiscover Shared/Models/EmailMapping.cs index d685439..6b68f98 100644 --- a/src/wan24-AutoDiscover Shared/Models/EmailMapping.cs +++ b/src/wan24-AutoDiscover Shared/Models/EmailMapping.cs @@ -6,15 +6,13 @@ namespace wan24.AutoDiscover.Models /// /// Email mapping /// - public record class EmailMapping : ValidatableRecordBase + /// + /// Constructor + /// + public record class EmailMapping() : ValidatableRecordBase() { /// - /// Constructor - /// - public EmailMapping() : base() { } - - /// - /// Emailaddress + /// Email address /// [EmailAddress] public required string Email { get; init; } diff --git a/src/wan24-AutoDiscover Shared/Models/Protocol.cs b/src/wan24-AutoDiscover Shared/Models/Protocol.cs index 91e55f0..a89af37 100644 --- a/src/wan24-AutoDiscover Shared/Models/Protocol.cs +++ b/src/wan24-AutoDiscover Shared/Models/Protocol.cs @@ -9,53 +9,51 @@ namespace wan24.AutoDiscover.Models /// /// Protocol (POX) /// - public record class Protocol : ValidatableRecordBase + /// + /// Constructor + /// + public record class Protocol() : ValidatableRecordBase() { /// /// Protocol node name /// - private const string PROTOCOL_NODE_NAME = "Protocol"; + protected const string PROTOCOL_NODE_NAME = "Protocol"; /// /// Type node name /// - private const string TYPE_NODE_NAME = "Type"; + protected const string TYPE_NODE_NAME = "Type"; /// /// Server node name /// - private const string SERVER_NODE_NAME = "Server"; + protected const string SERVER_NODE_NAME = "Server"; /// /// Port node name /// - private const string PORT_NODE_NAME = "Port"; + protected const string PORT_NODE_NAME = "Port"; /// /// LoginName node name /// - private const string LOGINNAME_NODE_NAME = "LoginName"; + protected const string LOGINNAME_NODE_NAME = "LoginName"; /// /// SPA node name /// - private const string SPA_NODE_NAME = "SPA"; + protected const string SPA_NODE_NAME = "SPA"; /// /// SSL node name /// - private const string SSL_NODE_NAME = "SSL"; + protected const string SSL_NODE_NAME = "SSL"; /// /// AuthRequired node name /// - private const string AUTHREQUIRED_NODE_NAME = "AuthRequired"; + protected const string AUTHREQUIRED_NODE_NAME = "AuthRequired"; /// /// ON /// - private const string ON = "on"; + protected const string ON = "on"; /// /// OFF /// - private const string OFF = "off"; - - /// - /// Constructor - /// - public Protocol() : base() { } + protected const string OFF = "off"; /// /// Login name getter delegate @@ -71,7 +69,7 @@ public Protocol() : base() { } /// /// Server /// - [RegularExpression(@"^[a-z|-|\.]{1,256}$")] + [Host] public required string Server { get; init; } /// @@ -87,7 +85,7 @@ public Protocol() : base() { } public IReadOnlyDictionary? LoginNameMapping { get; init; } /// - /// If a successfule login name mapping is required (if no mapping was possible, the email address will be used as login name) + /// If a successful login name mapping is required (if no mapping was possible, the email address will be used as login name) /// public bool LoginNameMappingRequired { get; init; } diff --git a/src/wan24-AutoDiscover Shared/wan24-AutoDiscover Shared.csproj b/src/wan24-AutoDiscover Shared/wan24-AutoDiscover Shared.csproj index 18ab763..2fdc141 100644 --- a/src/wan24-AutoDiscover Shared/wan24-AutoDiscover Shared.csproj +++ b/src/wan24-AutoDiscover Shared/wan24-AutoDiscover Shared.csproj @@ -12,8 +12,9 @@ - + + diff --git a/src/wan24-AutoDiscover/Controllers/DiscoveryController.cs b/src/wan24-AutoDiscover/Controllers/DiscoveryController.cs index 8187373..ab0fa19 100644 --- a/src/wan24-AutoDiscover/Controllers/DiscoveryController.cs +++ b/src/wan24-AutoDiscover/Controllers/DiscoveryController.cs @@ -143,7 +143,9 @@ private void RespondBadRequest(byte[] message) Logging.WriteTrace($"Invalid POX request from {HttpContext.Connection.RemoteIpAddress}:{HttpContext.Connection.RemotePort}: \"{message.ToUtf8String()}\""); HttpContext.Response.StatusCode = BAD_REQUEST_STATUS_CODE; HttpContext.Response.ContentType = ExceptionHandler.TEXT_MIME_TYPE; - HttpContext.Response.Body = new MemoryStream(message); + MemoryStream body = new(message); + HttpContext.Response.RegisterForDispose(body); + HttpContext.Response.Body = body; } } } diff --git a/src/wan24-AutoDiscover/Services/CommandLineInterface.cs b/src/wan24-AutoDiscover/Services/CommandLineInterface.cs index 0e78633..6b8dba2 100644 --- a/src/wan24-AutoDiscover/Services/CommandLineInterface.cs +++ b/src/wan24-AutoDiscover/Services/CommandLineInterface.cs @@ -8,16 +8,14 @@ namespace wan24.AutoDiscover.Services /// /// CLI API /// + /// + /// Constructor + /// [CliApi("autodiscover")] [DisplayText("wan24-AutoDiscover API")] [Description("wan24-AutoDiscover CLI API methods")] - public sealed partial class CommandLineInterface + public sealed partial class CommandLineInterface() { - /// - /// Constructor - /// - public CommandLineInterface() { } - /// /// Create service information /// diff --git a/src/wan24-AutoDiscover/Services/ExceptionHandler.cs b/src/wan24-AutoDiscover/Services/ExceptionHandler.cs index 9f6e037..9bde90c 100644 --- a/src/wan24-AutoDiscover/Services/ExceptionHandler.cs +++ b/src/wan24-AutoDiscover/Services/ExceptionHandler.cs @@ -7,7 +7,10 @@ namespace wan24.AutoDiscover.Services /// /// Exception handler /// - public sealed class ExceptionHandler : IExceptionHandler + /// + /// Constructor + /// + public sealed class ExceptionHandler() : IExceptionHandler { /// /// Internal server error code @@ -35,23 +38,19 @@ public sealed class ExceptionHandler : IExceptionHandler /// private static readonly byte[] MaintenanceMessage = "Temporary Not Available".GetBytes(); - /// - /// Constructor - /// - public ExceptionHandler() { } - /// public ValueTask TryHandleAsync(HttpContext httpContext, Exception exception, CancellationToken cancellationToken) { if (httpContext.Response.HasStarted) return ValueTask.FromResult(false); CancellationTokenSource cts = httpContext.RequestServices.GetRequiredService(); httpContext.Response.ContentType = TEXT_MIME_TYPE; + MemoryStream body; if (exception is BadHttpRequestException badRequest) { if (Logging.Trace) Logging.WriteTrace($"http handling bad request exception for {httpContext.Connection.RemoteIpAddress}:{httpContext.Connection.RemotePort} request to \"{httpContext.Request.Method} {httpContext.Request.Path}\": {exception}"); httpContext.Response.StatusCode = badRequest.StatusCode; - httpContext.Response.Body = new MemoryStream(badRequest.Message is null? BadRequestMessage : badRequest.Message.GetBytes()); + body = new MemoryStream(badRequest.Message is null? BadRequestMessage : badRequest.Message.GetBytes()); } else if (exception is OperationCanceledException) { @@ -64,14 +63,16 @@ public ValueTask TryHandleAsync(HttpContext httpContext, Exception excepti Logging.WriteWarning($"http handling operation canceled exception for {httpContext.Connection.RemoteIpAddress}:{httpContext.Connection.RemotePort} request to \"{httpContext.Request.Method} {httpContext.Request.Path}\": {exception}"); } httpContext.Response.StatusCode = MAINTENANCE_STATUS_CODE; - httpContext.Response.Body = new MemoryStream(MaintenanceMessage); + body = new MemoryStream(MaintenanceMessage); } else { Logging.WriteError($"http handling exception for {httpContext.Connection.RemoteIpAddress}:{httpContext.Connection.RemotePort} request to \"{httpContext.Request.Method} {httpContext.Request.Path}\": {exception}"); httpContext.Response.StatusCode = INTERNAL_SERVER_ERROR_STATUS_CODE; - httpContext.Response.Body = new MemoryStream(InternalServerErrorMessage); + body = new MemoryStream(InternalServerErrorMessage); } + httpContext.Response.RegisterForDispose(body); + httpContext.Response.Body = body; return ValueTask.FromResult(true); } } diff --git a/src/wan24-AutoDiscover/latest-release.txt b/src/wan24-AutoDiscover/latest-release.txt index 867e524..589268e 100644 --- a/src/wan24-AutoDiscover/latest-release.txt +++ b/src/wan24-AutoDiscover/latest-release.txt @@ -1 +1 @@ -1.2.0 \ No newline at end of file +1.3.0 \ No newline at end of file diff --git a/src/wan24-AutoDiscover/wan24-AutoDiscover.csproj b/src/wan24-AutoDiscover/wan24-AutoDiscover.csproj index df70dfc..cb2cddb 100644 --- a/src/wan24-AutoDiscover/wan24-AutoDiscover.csproj +++ b/src/wan24-AutoDiscover/wan24-AutoDiscover.csproj @@ -19,7 +19,7 @@ - + From 53692ccb7ea00b5d6cb803c5aee05c06723bce82 Mon Sep 17 00:00:00 2001 From: nd Date: Sat, 21 Sep 2024 12:56:30 +0700 Subject: [PATCH 2/2] Update + Updated references --- .../Properties/Resources.Designer.cs | 2 +- src/wan24-AutoDiscover Shared/Properties/Resources.resx | 2 +- .../wan24-AutoDiscover Shared.csproj | 6 +++--- src/wan24-AutoDiscover.sln | 3 +++ src/wan24-AutoDiscover/wan24-AutoDiscover.csproj | 6 +++--- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/wan24-AutoDiscover Shared/Properties/Resources.Designer.cs b/src/wan24-AutoDiscover Shared/Properties/Resources.Designer.cs index ef3ae9b..ef0e138 100644 --- a/src/wan24-AutoDiscover Shared/Properties/Resources.Designer.cs +++ b/src/wan24-AutoDiscover Shared/Properties/Resources.Designer.cs @@ -61,7 +61,7 @@ internal Resources() { } /// - /// Sucht eine lokalisierte Zeichenfolge, die 1.2.0 ähnelt. + /// Sucht eine lokalisierte Zeichenfolge, die 1.3.0 ähnelt. /// internal static string VERSION { get { diff --git a/src/wan24-AutoDiscover Shared/Properties/Resources.resx b/src/wan24-AutoDiscover Shared/Properties/Resources.resx index 2fc996f..f7440de 100644 --- a/src/wan24-AutoDiscover Shared/Properties/Resources.resx +++ b/src/wan24-AutoDiscover Shared/Properties/Resources.resx @@ -118,6 +118,6 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - 1.2.0 + 1.3.0 \ No newline at end of file diff --git a/src/wan24-AutoDiscover Shared/wan24-AutoDiscover Shared.csproj b/src/wan24-AutoDiscover Shared/wan24-AutoDiscover Shared.csproj index 2fdc141..0d7817a 100644 --- a/src/wan24-AutoDiscover Shared/wan24-AutoDiscover Shared.csproj +++ b/src/wan24-AutoDiscover Shared/wan24-AutoDiscover Shared.csproj @@ -12,9 +12,9 @@ - - - + + + diff --git a/src/wan24-AutoDiscover.sln b/src/wan24-AutoDiscover.sln index 3fde75d..3b897b9 100644 --- a/src/wan24-AutoDiscover.sln +++ b/src/wan24-AutoDiscover.sln @@ -58,4 +58,7 @@ Global GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {EA8C3992-DDF7-4778-9ED7-670279F08583} EndGlobalSection + GlobalSection(SharedMSBuildProjectFiles) = preSolution + ..\..\wan24-Core\src\Others\wan24-Core-Shared\src\wan24-Core-Shared\wan24-Core-Shared.projitems*{08e6e5d6-4b4a-46db-9bd0-e649abf456d0}*SharedItemsImports = 5 + EndGlobalSection EndGlobal diff --git a/src/wan24-AutoDiscover/wan24-AutoDiscover.csproj b/src/wan24-AutoDiscover/wan24-AutoDiscover.csproj index cb2cddb..173d883 100644 --- a/src/wan24-AutoDiscover/wan24-AutoDiscover.csproj +++ b/src/wan24-AutoDiscover/wan24-AutoDiscover.csproj @@ -19,9 +19,9 @@ - - - + + +