Skip to content

Commit d2a3963

Browse files
PCJonesakuntsch
andauthored
Merge Develop in master (#57)
* Merge master in develop (#55) * Fix reachable and IP leak test (#44) * Fix reachable check Fixes failing reachable checks when Basic Authentication is enabled in Sonarr, Radarr, etc. * Add option to disable IP leak test * Revert "Fix reachable and IP leak test (#44)" (#46) This reverts commit 3f5d7bb. * Release 0.6.1 (#48) * Fix typo * Fix typos * Fix typos * Fix typo * Clarify error message * Fix reachable and ipleak test (#47) * Fix reachable check Fixes failing reachable checks when Basic Authentication is enabled in Sonarr, Radarr, etc. * Add option to disable IP leak test --------- Co-authored-by: Jonas F <github@pcjones.de> * Add IpLeakTest environment variable to docker compose --------- Co-authored-by: akuntsch <github@akuntsch.de> * Create Dockerfile.arm64 --------- Co-authored-by: akuntsch <github@akuntsch.de> * Add configurable cache duration * Make proxy port configurable * Make proxy port configurable * Add API Key auth * Add default settings to appsettings * Fix too many Unauthorized access attempt warnings --------- Co-authored-by: akuntsch <github@akuntsch.de>
1 parent 9cdf195 commit d2a3963

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

UmlautAdaptarr/Services/HttpProxyService.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,15 @@ private async Task ProcessRequest(Socket clientSocket)
4545
if (_options.ApiKey != null)
4646
{
4747
var headers = ParseHeaders(buffer, bytesRead);
48+
4849
if (!headers.TryGetValue("Proxy-Authorization", out var proxyAuthorizationHeader) ||
4950
!ValidateApiKey(proxyAuthorizationHeader))
5051
{
51-
_logger.LogWarning("Unauthorized access attempt.");
52+
var isFirstRequest = !headers.ContainsKey("Proxy-Authorization");
53+
if (!isFirstRequest)
54+
{
55+
_logger.LogWarning("Unauthorized access attempt.");
56+
}
5257
await clientStream.WriteAsync(Encoding.ASCII.GetBytes("HTTP/1.1 407 Proxy Authentication Required\r\nProxy-Authenticate: Basic realm=\"Proxy\"\r\n\r\n"));
5358
clientSocket.Close();
5459
return;
@@ -66,6 +71,7 @@ private async Task ProcessRequest(Socket clientSocket)
6671
await HandleHttp(requestString, clientStream, clientSocket, buffer, bytesRead);
6772
}
6873
}
74+
6975
private bool ValidateApiKey(string proxyAuthorizationHeader)
7076
{
7177
// Expect the header to be in the format: "Basic <base64encodedApiKey>"

0 commit comments

Comments
 (0)