Add README and build scripts

This commit is contained in:
2026-04-09 20:41:17 +03:00
parent bdfb37304a
commit af139955a4
2 changed files with 12 additions and 0 deletions

View File

@@ -16,6 +16,10 @@ class Program
static string PASS = "pass";
static readonly string UPSTREAM_USER = Environment.GetEnvironmentVariable("UPSTREAM_USER");
static readonly string UPSTREAM_PASS = Environment.GetEnvironmentVariable("UPSTREAM_PASS");
static readonly bool UPSTREAM_ALLOW_EMPTY_PASSWORD = string.Equals(
Environment.GetEnvironmentVariable("UPSTREAM_ALLOW_EMPTY_PASSWORD"),
"1",
StringComparison.OrdinalIgnoreCase);
static readonly string UPSTREAM_PROXY_AUTH_HEADER = BuildUpstreamProxyAuthHeader();
static long _connectionSeq;
@@ -363,6 +367,12 @@ class Program
if (string.IsNullOrWhiteSpace(UPSTREAM_USER))
return string.Empty;
if (string.IsNullOrEmpty(UPSTREAM_PASS) && !UPSTREAM_ALLOW_EMPTY_PASSWORD)
{
Log.Info("UPSTREAM_PASS is empty; upstream Basic auth header is disabled");
return string.Empty;
}
string pass = UPSTREAM_PASS ?? string.Empty;
string encoded = Convert.ToBase64String(Encoding.ASCII.GetBytes($"{UPSTREAM_USER}:{pass}"));
return $"Proxy-Authorization: Basic {encoded}\r\n";