Fix too many Unauthorized access attempt warnings
This commit is contained in:
@@ -45,10 +45,15 @@ namespace UmlautAdaptarr.Services
|
|||||||
if (_options.ApiKey != null)
|
if (_options.ApiKey != null)
|
||||||
{
|
{
|
||||||
var headers = ParseHeaders(buffer, bytesRead);
|
var headers = ParseHeaders(buffer, bytesRead);
|
||||||
|
|
||||||
if (!headers.TryGetValue("Proxy-Authorization", out var proxyAuthorizationHeader) ||
|
if (!headers.TryGetValue("Proxy-Authorization", out var proxyAuthorizationHeader) ||
|
||||||
!ValidateApiKey(proxyAuthorizationHeader))
|
!ValidateApiKey(proxyAuthorizationHeader))
|
||||||
|
{
|
||||||
|
var isFirstRequest = !headers.ContainsKey("Proxy-Authorization");
|
||||||
|
if (!isFirstRequest)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Unauthorized access attempt.");
|
_logger.LogWarning("Unauthorized access attempt.");
|
||||||
|
}
|
||||||
await clientStream.WriteAsync(Encoding.ASCII.GetBytes("HTTP/1.1 407 Proxy Authentication Required\r\nProxy-Authenticate: Basic realm=\"Proxy\"\r\n\r\n"));
|
await clientStream.WriteAsync(Encoding.ASCII.GetBytes("HTTP/1.1 407 Proxy Authentication Required\r\nProxy-Authenticate: Basic realm=\"Proxy\"\r\n\r\n"));
|
||||||
clientSocket.Close();
|
clientSocket.Close();
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user