1
0
mirror of https://github.com/JKorf/CryptoExchange.Net.git synced 2026-08-11 16:32:57 +00:00

Merge pull request #135 from mohammadj22/ImproveWebSocketClientProxy

change SetProxy method in web socket client to support socks5 proxy.
This commit is contained in:
Jan Korf
2022-04-14 15:05:19 +02:00
committed by GitHub
2 changed files with 7 additions and 3 deletions
-2
View File
@@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
@@ -491,7 +490,6 @@ namespace CryptoExchange.Net
return ub.Uri;
}
}
}
@@ -212,7 +212,13 @@ namespace CryptoExchange.Net.Sockets
/// <inheritdoc />
public virtual void SetProxy(ApiProxy proxy)
{
_socket.Options.Proxy = new WebProxy(proxy.Host, proxy.Port);
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 = uri
};
if (proxy.Login != null)
_socket.Options.Proxy.Credentials = new NetworkCredential(proxy.Login, proxy.Password);
}