-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SOCKS4/4a/5 proxy support in SocketsHttpHandler (#48883)
* Separate method for proxy scheme validation. * Pass socks connection kind. * Unauthorized socks5 connection. * Username and password auth. * Fix response address. * Fix proxyUri value and assertion. * Use HttpConnectionKind for SOCKS. * Handle more connection kind assertions. * SOCKS4/4a support. * Move version selection into SocksHelper. * Call sync version of read write. * Cancellation by disposing stream. * Dispose cancellation registration. * IP addressing for SOCKS5. * IP addressing for SOCKS4. * Wrap write method. * Cancellation and optimization. * Optimize. * Apply suggestions from code review Co-authored-by: Miha Zupan <mihazupan.zupan1@gmail.com> * Clarify logic. * Remove ssl assertion. * SocksException. * Make SocksException derive from IOException. * Use binary primitives to write port in BE. * Socks loopback test. * Expand test matrix. * Try to solve certificate issue. * Pass handler to httpclient. * Update ConnectToTcpHostAsync. * Remove custom self-signed cert use from Socks test * Fix LoopbackSocksServer's parsing of Socks4a domain name * Only set RequestVersionExact for H2C Setting it in general breaks H2 => H1.1 downgrade on platforms without ALPN * Add auth test. * Add IP in test matrix. * Only override host when required. * Don't attempt NT Auth for Socks proxies * Skip HTTP2 ssl test on platforms without ALPN support * Use NetworkCredential directly * Pass AddressFamily to sync Dns resolution too * Consistently check encoded string lengths * Fix Socks5 user/pass auth * Add IPv6 test for socks5 * Exception nits * Add exceptional tests. * Fix exceptional test. * Fix NRT compilation Co-authored-by: Miha Zupan <mihazupan.zupan1@gmail.com> * Server shouldn't wait for request in exceptional test. * Add exception message to test. * Update auth failure handling. * SOCKS4 and 5 uses different auth model, requires different error message. * Revert accidental indent change. * Expand test matrix to include Sync HTTP1 * Read received bytes before returning error response in Socks4 loopback * Use named bool arguments * Improve exception messages * !IsEmpty => Length != 0 * Improve exception messages 2 * Avoid enforing Socks4 VN value Co-authored-by: Miha Zupan <mihazupan.zupan1@gmail.com>
- Loading branch information
1 parent
1132baa
commit 32d1a25
Showing
11 changed files
with
971 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/SocksException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.IO; | ||
|
||
namespace System.Net.Http | ||
{ | ||
internal class SocksException : IOException | ||
{ | ||
public SocksException(string message) : base(message) { } | ||
|
||
public SocksException(string message, Exception innerException) : base(message, innerException) { } | ||
} | ||
} |
Oops, something went wrong.