mirror of
https://github.com/JKorf/CryptoExchange.Net
synced 2025-06-07 16:06:15 +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:
commit
13c81afb79
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -491,7 +490,6 @@ namespace CryptoExchange.Net
|
|||||||
|
|
||||||
return ub.Uri;
|
return ub.Uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,7 +212,13 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public virtual void SetProxy(ApiProxy proxy)
|
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)
|
if (proxy.Login != null)
|
||||||
_socket.Options.Proxy.Credentials = new NetworkCredential(proxy.Login, proxy.Password);
|
_socket.Options.Proxy.Credentials = new NetworkCredential(proxy.Login, proxy.Password);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user