Merge branch 'release/2.2'
This commit is contained in:
Коммит
2a731baaa3
|
@ -102,7 +102,11 @@ namespace Microsoft.AspNetCore.HostFiltering
|
|||
throw new InvalidOperationException("No allowed hosts were configured.");
|
||||
}
|
||||
|
||||
_logger.LogDebug("Allowed hosts: " + string.Join("; ", allowedHosts));
|
||||
if (_logger.IsEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.LogDebug("Allowed hosts: {Hosts}", string.Join("; ", allowedHosts));
|
||||
}
|
||||
|
||||
_allowedHosts = allowedHosts;
|
||||
return _allowedHosts;
|
||||
}
|
||||
|
@ -148,29 +152,26 @@ namespace Microsoft.AspNetCore.HostFiltering
|
|||
// Http/1.1 requires the header but the value may be empty.
|
||||
if (!_options.AllowEmptyHosts)
|
||||
{
|
||||
_logger.LogInformation($"{context.Request.Protocol} request rejected due to missing or empty host header.");
|
||||
_logger.LogInformation("{Protocol} request rejected due to missing or empty host header.", context.Request.Protocol);
|
||||
return false;
|
||||
}
|
||||
if (_logger.IsEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.LogDebug($"{context.Request.Protocol} request allowed with missing or empty host header.");
|
||||
}
|
||||
_logger.LogDebug("{Protocol} request allowed with missing or empty host header.", context.Request.Protocol);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_allowAnyNonEmptyHost == true)
|
||||
{
|
||||
_logger.LogTrace($"All hosts are allowed.");
|
||||
_logger.LogTrace("All hosts are allowed.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (HostString.MatchesAny(host, allowedHosts))
|
||||
{
|
||||
_logger.LogTrace($"The host '{host}' matches an allowed host.");
|
||||
_logger.LogTrace("The host '{Host}' matches an allowed host.", host);
|
||||
return true;
|
||||
}
|
||||
|
||||
_logger.LogInformation($"The host '{host}' does not match an allowed host.");
|
||||
_logger.LogInformation("The host '{Host}' does not match an allowed host.", host);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -233,7 +233,7 @@ namespace Microsoft.AspNetCore.HttpOverrides
|
|||
if (currentValues.RemoteIpAndPort != null && checkKnownIps && !CheckKnownAddress(currentValues.RemoteIpAndPort.Address))
|
||||
{
|
||||
// Stop at the first unknown remote IP, but still apply changes processed so far.
|
||||
_logger.LogDebug(1, $"Unknown proxy: {currentValues.RemoteIpAndPort}");
|
||||
_logger.LogDebug(1, "Unknown proxy: {RemoteIpAndPort}", currentValues.RemoteIpAndPort);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -248,12 +248,12 @@ namespace Microsoft.AspNetCore.HttpOverrides
|
|||
else if (!string.IsNullOrEmpty(set.IpAndPortText))
|
||||
{
|
||||
// Stop at the first unparsable IP, but still apply changes processed so far.
|
||||
_logger.LogDebug(1, $"Unparsable IP: {set.IpAndPortText}");
|
||||
_logger.LogDebug(1, "Unparsable IP: {IpAndPortText}", set.IpAndPortText);
|
||||
break;
|
||||
}
|
||||
else if (_options.RequireHeaderSymmetry)
|
||||
{
|
||||
_logger.LogWarning(2, $"Missing forwarded IPAddress.");
|
||||
_logger.LogWarning(2, "Missing forwarded IPAddress.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче