Master-URL: ongeldige of placeholder-waarde wordt nooit opgeslagen of verstuurd (master slaat achtergrondchecks over, slave weigert met 400, poller meldt invalid_master_url); veilige diagnostiek bij een mislukte poll; releasenote Master__MasterUrl
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
namespace SlpModularCms.Core.Availability;
|
||||
|
||||
/// <summary>
|
||||
/// What counts as a usable master address. A slave stores whatever the master registers and later builds
|
||||
/// "{url}/api/v1/SlaveStatus" from it, so an unusable value (the "<public-url-...>" placeholder of the shipped
|
||||
/// appsettings, an empty string, a host without scheme) breaks every poll with an exception instead of a message.
|
||||
/// </summary>
|
||||
public static class MasterUrlRules
|
||||
{
|
||||
/// <summary>An absolute http or https URL with a host, without credentials, query or fragment.</summary>
|
||||
public static bool IsValid(string? value)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(value)) return false;
|
||||
if (!Uri.TryCreate(value.Trim(), UriKind.Absolute, out var uri)) return false;
|
||||
return (uri.Scheme == Uri.UriSchemeHttps || uri.Scheme == Uri.UriSchemeHttp)
|
||||
&& !string.IsNullOrEmpty(uri.Host)
|
||||
&& string.IsNullOrEmpty(uri.UserInfo)
|
||||
&& string.IsNullOrEmpty(uri.Query)
|
||||
&& string.IsNullOrEmpty(uri.Fragment);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user