diff --git a/CryptoExchange.Net/Interfaces/IRequest.cs b/CryptoExchange.Net/Interfaces/IRequest.cs
index 6e3b712..457a42d 100644
--- a/CryptoExchange.Net/Interfaces/IRequest.cs
+++ b/CryptoExchange.Net/Interfaces/IRequest.cs
@@ -11,7 +11,7 @@ namespace CryptoExchange.Net.Interfaces
WebHeaderCollection Headers { get; set; }
string Method { get; set; }
TimeSpan Timeout { get; set; }
- void SetProxy(string host, int port);
+ void SetProxy(string host, int port, string login, string password);
string ContentType { get; set; }
string Content { get; set; }
diff --git a/CryptoExchange.Net/Objects/ApiProxy.cs b/CryptoExchange.Net/Objects/ApiProxy.cs
index 21c7cb6..970f5b6 100644
--- a/CryptoExchange.Net/Objects/ApiProxy.cs
+++ b/CryptoExchange.Net/Objects/ApiProxy.cs
@@ -13,6 +13,16 @@ namespace CryptoExchange.Net.Objects
///
public int Port { get; }
+ ///
+ /// The login of the proxy
+ ///
+ public string Login { get; }
+
+ ///
+ /// The password of the proxy
+ ///
+ public string Password { get; }
+
///
/// Create new settings for a proxy
///
@@ -26,5 +36,22 @@ namespace CryptoExchange.Net.Objects
Host = host;
Port = port;
}
+
+ ///
+ ///
+ /// Create new settings for a proxy
+ ///
+ /// The proxy hostname/ip
+ /// The proxy port
+ /// The proxy login
+ /// The proxy password
+ public ApiProxy(string host, int port, string login, string password) : this(host, port)
+ {
+ if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
+ throw new ArgumentException("Proxy login or password not filled");
+
+ Login = login;
+ Password = password;
+ }
}
}
diff --git a/CryptoExchange.Net/Requests/Request.cs b/CryptoExchange.Net/Requests/Request.cs
index bbdded2..721959b 100644
--- a/CryptoExchange.Net/Requests/Request.cs
+++ b/CryptoExchange.Net/Requests/Request.cs
@@ -54,9 +54,10 @@ namespace CryptoExchange.Net.Requests
public Uri Uri => request.RequestUri;
- public void SetProxy(string host, int port)
+ public void SetProxy(string host, int port, string login, string password)
{
request.Proxy = new WebProxy(host, port);
+ if(!string.IsNullOrEmpty(login) && !string.IsNullOrEmpty(password)) request.Proxy.Credentials = new NetworkCredential(login, password);
}
public async Task GetRequestStream()
diff --git a/CryptoExchange.Net/RestClient.cs b/CryptoExchange.Net/RestClient.cs
index b82829a..13c79f4 100644
--- a/CryptoExchange.Net/RestClient.cs
+++ b/CryptoExchange.Net/RestClient.cs
@@ -129,7 +129,7 @@ namespace CryptoExchange.Net
if (apiProxy != null)
{
log.Write(LogVerbosity.Debug, "Setting proxy");
- request.SetProxy(apiProxy.Host, apiProxy.Port);
+ request.SetProxy(apiProxy.Host, apiProxy.Port, apiProxy.Login, apiProxy.Password);
}
foreach (var limiter in RateLimiters)