1
0
mirror of https://github.com/Ylianst/MeshCentralRouter synced 2025-12-18 01:03:16 +00:00

Proxy related changes

Removed some duplicate proxy related code
Added manual http proxy settings with basic auth support
This commit is contained in:
jbfuzier
2021-10-19 18:43:00 +02:00
parent 20bb296dcb
commit cdb04cf032
11 changed files with 888 additions and 285 deletions

View File

@@ -78,6 +78,24 @@ namespace MeshCentralRouter
public static Uri GetProxy(Uri url)
{
// Manual http proxy with optional basic auth. Other auth type would be difficult to support as proxy authentication is done manually within the websocketclient
if(Settings.GetRegValue("Use_Manual_Http_proxy", false))
{
string proxyStr = "";
string proxyUserName = Settings.GetRegValue("Manual_Http_proxy_username", "");
string proxyPassword = Settings.GetRegValue("Manual_Http_proxy_password", "");
if (proxyUserName.Length > 0 && proxyPassword.Length > 0)
{
proxyStr = "http://" + proxyUserName + ":" + proxyPassword + "@" + Settings.GetRegValue("Manual_Http_proxy_host", "") + ":" + Settings.GetRegValue("Manual_Http_proxy_port", "");
}
else
{
proxyStr = "http://" + Settings.GetRegValue("Manual_Http_proxy_host", "") + ":" + Settings.GetRegValue("Manual_Http_proxy_port", "");
}
return new Uri(proxyStr);
}
// Check if we need to use a HTTP proxy (Auto-proxy way)
try
{
@@ -86,7 +104,10 @@ namespace MeshCentralRouter
if ((x != null) && (x.GetType() == typeof(string)))
{
string proxyStr = GetProxyForUrlUsingPac("http" + ((url.Port == 80) ? "" : "s") + "://" + url.Host + ":" + url.Port, x.ToString());
return new Uri("http://" + proxyStr);
if (proxyStr != null)
{
return new Uri("http://" + proxyStr);
}
}
}
catch (Exception) { }