mirror of
https://github.com/JKorf/CryptoExchange.Net
synced 2025-06-09 08:56:13 +00:00
proxy authentication added
This commit is contained in:
parent
a56de43ca3
commit
5fad5a4d8e
@ -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; }
|
||||
|
@ -13,6 +13,16 @@ namespace CryptoExchange.Net.Objects
|
||||
/// </summary>
|
||||
public int Port { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The login of the proxy
|
||||
/// </summary>
|
||||
public string Login { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The password of the proxy
|
||||
/// </summary>
|
||||
public string Password { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create new settings for a proxy
|
||||
/// </summary>
|
||||
@ -26,5 +36,22 @@ namespace CryptoExchange.Net.Objects
|
||||
Host = host;
|
||||
Port = port;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
/// <summary>
|
||||
/// Create new settings for a proxy
|
||||
/// </summary>
|
||||
/// <param name="host">The proxy hostname/ip</param>
|
||||
/// <param name="port">The proxy port</param>
|
||||
/// <param name="login">The proxy login</param>
|
||||
/// <param name="password">The proxy password</param>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<Stream> GetRequestStream()
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user