Add README and build scripts
This commit is contained in:
10
Program.cs
10
Program.cs
@@ -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";
|
||||
|
||||
2
run.bat
2
run.bat
@@ -12,10 +12,12 @@ if not exist "%EXE%" (
|
||||
set "UPSTREAM_PROXY=proxy.syktsu.ru:3128"
|
||||
set "UPSTREAM_USER=%USERNAME%"
|
||||
set "UPSTREAM_PASS="
|
||||
set "UPSTREAM_ALLOW_EMPTY_PASSWORD=0"
|
||||
|
||||
echo [run] UPSTREAM_PROXY=%UPSTREAM_PROXY%
|
||||
echo [run] UPSTREAM_USER=%UPSTREAM_USER%
|
||||
echo [run] UPSTREAM_PASS is empty
|
||||
echo [run] UPSTREAM_ALLOW_EMPTY_PASSWORD=%UPSTREAM_ALLOW_EMPTY_PASSWORD%
|
||||
echo [run] Starting proxy...
|
||||
|
||||
"%EXE%"
|
||||
|
||||
Reference in New Issue
Block a user