mirror of
https://github.com/JKorf/CryptoExchange.Net
synced 2025-06-12 02:16:23 +00:00
Merge pull request #11 from mql4coder/master
Proxy authentication added
This commit is contained in:
commit
cacc096111
@ -11,7 +11,7 @@ namespace CryptoExchange.Net.Interfaces
|
|||||||
WebHeaderCollection Headers { get; set; }
|
WebHeaderCollection Headers { get; set; }
|
||||||
string Method { get; set; }
|
string Method { get; set; }
|
||||||
TimeSpan Timeout { 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 ContentType { get; set; }
|
||||||
string Content { get; set; }
|
string Content { get; set; }
|
||||||
|
@ -13,6 +13,16 @@ namespace CryptoExchange.Net.Objects
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int Port { get; }
|
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>
|
/// <summary>
|
||||||
/// Create new settings for a proxy
|
/// Create new settings for a proxy
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -26,5 +36,22 @@ namespace CryptoExchange.Net.Objects
|
|||||||
Host = host;
|
Host = host;
|
||||||
Port = port;
|
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 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);
|
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()
|
public async Task<Stream> GetRequestStream()
|
||||||
|
@ -129,7 +129,7 @@ namespace CryptoExchange.Net
|
|||||||
if (apiProxy != null)
|
if (apiProxy != null)
|
||||||
{
|
{
|
||||||
log.Write(LogVerbosity.Debug, "Setting proxy");
|
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)
|
foreach (var limiter in RateLimiters)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user