Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ EstablishSocksTunnelAsync()

static async ValueTask System.Net.Http.SocksHelper.EstablishSocksTunnelAsync ( Stream stream,
string host,
int port,
Uri proxyUri,
ICredentials proxyCredentials,
bool async,
CancellationToken cancellationToken )
inlinestatic

Definition at line 13 of file SocksHelper.cs.

14 {
15 using (cancellationToken.Register(delegate(object s)
16 {
17 ((Stream)s).Dispose();
18 }, stream))
19 {
20 _ = 2;
21 try
22 {
23 NetworkCredential credentials = proxyCredentials?.GetCredential(proxyUri, proxyUri.Scheme);
24 if (string.Equals(proxyUri.Scheme, "socks5", StringComparison.OrdinalIgnoreCase))
25 {
26 await EstablishSocks5TunnelAsync(stream, host, port, proxyUri, credentials, async).ConfigureAwait(continueOnCapturedContext: false);
27 }
28 else if (string.Equals(proxyUri.Scheme, "socks4a", StringComparison.OrdinalIgnoreCase))
29 {
30 await EstablishSocks4TunnelAsync(stream, isVersion4a: true, host, port, proxyUri, credentials, async, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
31 }
32 else if (string.Equals(proxyUri.Scheme, "socks4", StringComparison.OrdinalIgnoreCase))
33 {
34 await EstablishSocks4TunnelAsync(stream, isVersion4a: false, host, port, proxyUri, credentials, async, cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
35 }
36 }
37 catch
38 {
39 stream.Dispose();
40 throw;
41 }
42 }
43 }
static async ValueTask EstablishSocks5TunnelAsync(Stream stream, string host, int port, Uri proxyUri, NetworkCredential credentials, bool async)
static async ValueTask EstablishSocks4TunnelAsync(Stream stream, bool isVersion4a, string host, int port, Uri proxyUri, NetworkCredential credentials, bool async, CancellationToken cancellationToken)

References System.cancellationToken, System.Net.Equals, System.Net.Http.SocksHelper.EstablishSocks4TunnelAsync(), System.Net.Http.SocksHelper.EstablishSocks5TunnelAsync(), System.Net.ICredentials.GetCredential(), System.s, System.Uri.Scheme, System.Net.Sockets.Stream, and System.stream.

Referenced by System.Net.Http.HttpConnectionPool.EstablishSocksTunnel().