Use a custom proxy server

pull/528/head
Koraniar 2020-04-30 09:30:31 -05:00
parent e8f9564275
commit 03fe39efeb
1 changed files with 9 additions and 1 deletions

View File

@ -36,6 +36,7 @@ namespace winsw
public readonly string? Password; public readonly string? Password;
public readonly bool UnsecureAuth; public readonly bool UnsecureAuth;
public readonly bool FailOnError; public readonly bool FailOnError;
public readonly string? ProxyServer;
public string ShortId => $"(download from {From})"; public string ShortId => $"(download from {From})";
@ -75,11 +76,13 @@ namespace winsw
AuthType auth = AuthType.none, AuthType auth = AuthType.none,
string? username = null, string? username = null,
string? password = null, string? password = null,
bool unsecureAuth = false) bool unsecureAuth = false,
string? proxyServer = null)
{ {
From = from; From = from;
To = to; To = to;
FailOnError = failOnError; FailOnError = failOnError;
ProxyServer = proxyServer;
Auth = auth; Auth = auth;
Username = username; Username = username;
Password = password; Password = password;
@ -98,6 +101,7 @@ namespace winsw
// All arguments below are optional // All arguments below are optional
FailOnError = XmlHelper.SingleAttribute(n, "failOnError", false); FailOnError = XmlHelper.SingleAttribute(n, "failOnError", false);
ProxyServer = XmlHelper.SingleAttribute<string>(n, "proxyServer", null);
Auth = XmlHelper.EnumAttribute(n, "auth", AuthType.none); Auth = XmlHelper.EnumAttribute(n, "auth", AuthType.none);
Username = XmlHelper.SingleAttribute<string>(n, "user", null); Username = XmlHelper.SingleAttribute<string>(n, "user", null);
@ -147,6 +151,10 @@ namespace winsw
#endif #endif
{ {
WebRequest request = WebRequest.Create(From); WebRequest request = WebRequest.Create(From);
if (!string.IsNullOrEmpty(ProxyServer))
{
request.Proxy = new WebProxy(ProxyServer);
}
switch (Auth) switch (Auth)
{ {