1
0
mirror of https://github.com/JKorf/CryptoExchange.Net.git synced 2026-08-15 02:13:01 +00:00

Update SetProxy

This commit is contained in:
Mohammad Reza
2022-04-13 17:37:48 +04:30
parent 4f4d2ccff3
commit c4f4ddcdc5
2 changed files with 7 additions and 29 deletions
@@ -212,18 +212,15 @@ namespace CryptoExchange.Net.Sockets
/// <inheritdoc />
public virtual void SetProxy(ApiProxy proxy)
{
if (!proxy.IsSchemaProvided())
{
_socket.Options.Proxy = new WebProxy(proxy.Host, proxy.Port);
}
else
{
_socket.Options.Proxy = new WebProxy
Uri.TryCreate($"{proxy.Host}:{proxy.Port}", UriKind.Absolute, out var uri);
_socket.Options.Proxy = uri?.Scheme == null
? _socket.Options.Proxy = new WebProxy(proxy.Host, proxy.Port)
: _socket.Options.Proxy = new WebProxy
{
Address = new Uri($"{proxy.Host}:{proxy.Port}"),
Credentials = proxy.Password == null ? null : new NetworkCredential(proxy.Login, proxy.Password)
Address = uri
};
}
if (proxy.Login != null)
_socket.Options.Proxy.Credentials = new NetworkCredential(proxy.Login, proxy.Password);
}
/// <inheritdoc />