Skip to content

Commit

Permalink
Merge pull request #4 from nd1012/dev
Browse files Browse the repository at this point in the history
+ Updated references
  • Loading branch information
nd1012 authored Sep 21, 2024
2 parents fbdb3f1 + 53692cc commit b98efaf
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 63 deletions.
12 changes: 5 additions & 7 deletions src/wan24-AutoDiscover Shared/Models/DiscoveryConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,16 @@ namespace wan24.AutoDiscover.Models
/// <summary>
/// Discovery configuration
/// </summary>
public record class DiscoveryConfig : ValidatableRecordBase
/// <remarks>
/// Constructor
/// </remarks>
public record class DiscoveryConfig() : ValidatableRecordBase()
{
/// <summary>
/// Discovery configuration type
/// </summary>
protected Type? _DiscoveryType = null;

/// <summary>
/// Constructor
/// </summary>
public DiscoveryConfig() : base() { }

/// <summary>
/// Current configuration
/// </summary>
Expand All @@ -43,7 +41,7 @@ public DiscoveryConfig() : base() { }
public int PreForkResponses { get; init; } = 10;

/// <summary>
/// Dicovery configuration type name
/// Discovery configuration type name
/// </summary>
[StringLength(byte.MaxValue, MinimumLength = 1)]
public string? DiscoveryTypeName { get; init; }
Expand Down
12 changes: 5 additions & 7 deletions src/wan24-AutoDiscover Shared/Models/DomainConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ namespace wan24.AutoDiscover.Models
/// <summary>
/// Domain configuration
/// </summary>
public record class DomainConfig : ValidatableRecordBase
/// <remarks>
/// Constructor
/// </remarks>
public record class DomainConfig() : ValidatableRecordBase()
{
/// <summary>
/// Constructor
/// </summary>
public DomainConfig() : base() { }

/// <summary>
/// Registered domains (key is the served domain name)
/// </summary>
Expand All @@ -37,7 +35,7 @@ public DomainConfig() : base() { }
public Dictionary<string, string>? LoginNameMapping { get; set; }

/// <summary>
/// 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)
/// </summary>
public bool LoginNameMappingRequired { get; init; }

Expand Down
12 changes: 5 additions & 7 deletions src/wan24-AutoDiscover Shared/Models/EmailMapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ namespace wan24.AutoDiscover.Models
/// <summary>
/// Email mapping
/// </summary>
public record class EmailMapping : ValidatableRecordBase
/// <remarks>
/// Constructor
/// </remarks>
public record class EmailMapping() : ValidatableRecordBase()
{
/// <summary>
/// Constructor
/// </summary>
public EmailMapping() : base() { }

/// <summary>
/// Emailaddress
/// Email address
/// </summary>
[EmailAddress]
public required string Email { get; init; }
Expand Down
34 changes: 16 additions & 18 deletions src/wan24-AutoDiscover Shared/Models/Protocol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,53 +9,51 @@ namespace wan24.AutoDiscover.Models
/// <summary>
/// Protocol (POX)
/// </summary>
public record class Protocol : ValidatableRecordBase
/// <remarks>
/// Constructor
/// </remarks>
public record class Protocol() : ValidatableRecordBase()
{
/// <summary>
/// <c>Protocol</c> node name
/// </summary>
private const string PROTOCOL_NODE_NAME = "Protocol";
protected const string PROTOCOL_NODE_NAME = "Protocol";
/// <summary>
/// <c>Type</c> node name
/// </summary>
private const string TYPE_NODE_NAME = "Type";
protected const string TYPE_NODE_NAME = "Type";
/// <summary>
/// <c>Server</c> node name
/// </summary>
private const string SERVER_NODE_NAME = "Server";
protected const string SERVER_NODE_NAME = "Server";
/// <summary>
/// <c>Port</c> node name
/// </summary>
private const string PORT_NODE_NAME = "Port";
protected const string PORT_NODE_NAME = "Port";
/// <summary>
/// <c>LoginName</c> node name
/// </summary>
private const string LOGINNAME_NODE_NAME = "LoginName";
protected const string LOGINNAME_NODE_NAME = "LoginName";
/// <summary>
/// <c>SPA</c> node name
/// </summary>
private const string SPA_NODE_NAME = "SPA";
protected const string SPA_NODE_NAME = "SPA";
/// <summary>
/// <c>SSL</c> node name
/// </summary>
private const string SSL_NODE_NAME = "SSL";
protected const string SSL_NODE_NAME = "SSL";
/// <summary>
/// <c>AuthRequired</c> node name
/// </summary>
private const string AUTHREQUIRED_NODE_NAME = "AuthRequired";
protected const string AUTHREQUIRED_NODE_NAME = "AuthRequired";
/// <summary>
/// <c>ON</c>
/// </summary>
private const string ON = "on";
protected const string ON = "on";
/// <summary>
/// <c>OFF</c>
/// </summary>
private const string OFF = "off";

/// <summary>
/// Constructor
/// </summary>
public Protocol() : base() { }
protected const string OFF = "off";

/// <summary>
/// Login name getter delegate
Expand All @@ -71,7 +69,7 @@ public Protocol() : base() { }
/// <summary>
/// Server
/// </summary>
[RegularExpression(@"^[a-z|-|\.]{1,256}$")]
[Host]
public required string Server { get; init; }

/// <summary>
Expand All @@ -87,7 +85,7 @@ public Protocol() : base() { }
public IReadOnlyDictionary<string, string>? LoginNameMapping { get; init; }

/// <summary>
/// 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)
/// </summary>
public bool LoginNameMappingRequired { get; init; }

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/wan24-AutoDiscover Shared/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,6 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="VERSION" xml:space="preserve">
<value>1.2.0</value>
<value>1.3.0</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.2" />
<PackageReference Include="ObjectValidation" Version="2.6.0" Condition="'$(Configuration)' != 'Trunk'" />
<PackageReference Include="wan24-Core" Version="2.35.0" Condition="'$(Configuration)' != 'Trunk'" />
<PackageReference Include="ObjectValidation" Version="2.8.0" Condition="'$(Configuration)' != 'Trunk'" />
<PackageReference Include="wan24-Core" Version="2.38.0" Condition="'$(Configuration)' != 'Trunk'" />
<PackageReference Include="wan24-Core-Validation" Version="1.4.0" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 3 additions & 0 deletions src/wan24-AutoDiscover.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion src/wan24-AutoDiscover/Controllers/DiscoveryController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
10 changes: 4 additions & 6 deletions src/wan24-AutoDiscover/Services/CommandLineInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,14 @@ namespace wan24.AutoDiscover.Services
/// <summary>
/// CLI API
/// </summary>
/// <remarks>
/// Constructor
/// </remarks>
[CliApi("autodiscover")]
[DisplayText("wan24-AutoDiscover API")]
[Description("wan24-AutoDiscover CLI API methods")]
public sealed partial class CommandLineInterface
public sealed partial class CommandLineInterface()
{
/// <summary>
/// Constructor
/// </summary>
public CommandLineInterface() { }

/// <summary>
/// Create service information
/// </summary>
Expand Down
19 changes: 10 additions & 9 deletions src/wan24-AutoDiscover/Services/ExceptionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ namespace wan24.AutoDiscover.Services
/// <summary>
/// Exception handler
/// </summary>
public sealed class ExceptionHandler : IExceptionHandler
/// <remarks>
/// Constructor
/// </remarks>
public sealed class ExceptionHandler() : IExceptionHandler
{
/// <summary>
/// Internal server error code
Expand Down Expand Up @@ -35,23 +38,19 @@ public sealed class ExceptionHandler : IExceptionHandler
/// </summary>
private static readonly byte[] MaintenanceMessage = "Temporary Not Available".GetBytes();

/// <summary>
/// Constructor
/// </summary>
public ExceptionHandler() { }

/// <inheritdoc/>
public ValueTask<bool> TryHandleAsync(HttpContext httpContext, Exception exception, CancellationToken cancellationToken)
{
if (httpContext.Response.HasStarted) return ValueTask.FromResult(false);
CancellationTokenSource cts = httpContext.RequestServices.GetRequiredService<CancellationTokenSource>();
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)
{
Expand All @@ -64,14 +63,16 @@ public ValueTask<bool> 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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/wan24-AutoDiscover/latest-release.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.0
1.3.0
6 changes: 3 additions & 3 deletions src/wan24-AutoDiscover/wan24-AutoDiscover.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
</Target>

<ItemGroup>
<PackageReference Include="ObjectValidation" Version="2.6.0" Condition="'$(Configuration)' != 'Trunk'" />
<PackageReference Include="wan24-CLI" Version="1.5.0" Condition="'$(Configuration)' != 'Trunk'" />
<PackageReference Include="wan24-Core" Version="2.35.0" Condition="'$(Configuration)' != 'Trunk'" />
<PackageReference Include="ObjectValidation" Version="2.8.0" Condition="'$(Configuration)' != 'Trunk'" />
<PackageReference Include="wan24-CLI" Version="1.7.0" Condition="'$(Configuration)' != 'Trunk'" />
<PackageReference Include="wan24-Core" Version="2.38.0" Condition="'$(Configuration)' != 'Trunk'" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit b98efaf

Please sign in to comment.