Skip to content

v3.0.0: static API, error codes, tests, CI/CD#1

Merged
Titlehhhh merged 5 commits intomasterfrom
refactor/cleanup-and-bugfixes
Mar 8, 2026
Merged

v3.0.0: static API, error codes, tests, CI/CD#1
Titlehhhh merged 5 commits intomasterfrom
refactor/cleanup-and-bugfixes

Conversation

@Titlehhhh
Copy link
Owner

Summary

  • Static APIProxy.ConnectAsync(Uri, host, port) + Uri.ConnectThroughProxyAsync() extension methods for mass proxy checking (zero client allocation)
  • ProxyProtocolException + ProxyErrorCode enum — structured errors with specific codes (Timeout, AuthRequired, AuthFailed, ConnectionFailed, InvalidResponse, Socks*)
  • Timeout handlingProxyErrorCode.Timeout with informative messages including proxy host:port
  • HTTPS support in ProxyConnector — static API now handles all 5 protocols
  • HttpResponseParser hardening — 16 KB max header size limit, fixes infinite loop on malformed responses
  • 45 unit tests — HttpHelper, SocksHelper, PrefixedStream, HttpResponseParser, integration tests
  • CI/CD — build.yaml (build+test), publish.yaml (NuGet on tag), .NET 8/9/10
  • Zero runtime dependencies — removed DotNext, BCL only
  • Performance — zero-alloc HTTP CONNECT builder, ArrayPool everywhere, benchmarks confirming IndexOf is optimal

Breaking changes

  • Minimum target: net8.0 (dropped older targets)
  • All proxy errors now throw ProxyProtocolException instead of raw SocketException
  • ProxyClientFactory.Instance is now a cached singleton

Test plan

  • 45/45 unit tests pass locally (net10.0)
  • CI build passes on .NET 8/9/10
  • Manual test with real proxy (HTTP_PROXY_URI / SOCKS5_PROXY_URI env vars)

🤖 Generated with Claude Code

TitleHHHH and others added 5 commits March 6, 2026 23:23
…ng bugs

- Delete QuickProxyNet.Pipelines (Pipelines experiment for SOCKS, not useful)
- Migrate QuickProxyNet.sln → QuickProxyNet.slnx
- Remove ZString and DotNext dependencies; replace with BCL (ArrayPool, StringBuilder)
- Fix HttpResponseParser: IndexOf not LastIndexOf, correct over-read byte handling
- Add PrefixedStream to serve over-read bytes before delegating to inner stream
- Fix HttpsProxyClient: remove deprecated ServicePointManager, dead SslCertificateValidationInfo/SslChainElement, duplicate SslStream callback
- Fix ProxyClient nullable warnings (LingerState, CancellationToken.Register lambda)
- Delete dead files: ConnectHelper, CancellationHelper, Http3ErrorCode, RequestRetryType, SslClientAuthenticationOptionsExtensions, SocketHelper, Ext
- Update deps: xunit→2.9.3, xunit.runner.visualstudio→3.0.0, BenchmarkDotNet→0.15.8
- Update tests to use GetStatusCode() and ToString() on HttpResponseParser
- Add CLAUDE.md project documentation

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
HttpHelper.BuildConnectionCommand: replace StringBuilder with direct
ArrayPool<byte> writes — eliminates 4 allocations per connection
(StringBuilder, sb.ToString(), credBytes string, Convert.ToBase64String).
Now uses Utf8Formatter.TryFormat for port, Base64.EncodeToUtf8 for
credentials, Encoding.UTF8.GetBytes(span) for host.

Remove [MethodImpl(AggressiveInlining|AggressiveOptimization)] from all
async and virtual methods — JIT ignores these attributes on state machines
and virtual dispatch. Remove now-unused System.Runtime.CompilerServices
usings from client files.

Remove SocksHelper.WriteAsync single-line wrapper; inline stream.WriteAsync
at call sites directly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… benchmarks

- Add Proxy.ConnectAsync static methods (zero client allocation) for mass checkers
- Add ProxyUriExtensions with ConnectThroughProxyAsync extension on Uri
- Add HTTPS support to ProxyConnector (SslStream + default TLS options)
- Fix ProxyClientFactory.Instance to be a cached singleton
- Add FindEndOfHeadersBenchmark comparing IndexOf vs SearchValues approaches
- Update benchmarks: net10.0 target, InProcess toolchain, BenchmarkSwitcher
- Include CI/CD workflows, ProxyErrorCode enum, and prior refactoring changes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…parsing

- Add ProxyErrorCode.Timeout; detect timeouts via StrongBox<bool>+Volatile
  instead of letting ObjectDisposedException propagate untyped
- Wrap SocketException in ProxyProtocolException with proxy+target context
- Fix SslStream leak in ProxyConnector HTTPS path (auth+tunnel in one try)
- Fix timer race in Proxy.ConnectCoreAsync (dispose before returning stream)
- Replace EndOfStreamException with ProxyProtocolException in HttpHelper
- Include SOCKS5 REP code in rejection error messages
- Fix Split(':') → IndexOf+Substring for passwords containing colons
- Add SOCKS4 reply VN=0 check, separate SOCKS5 auth VER/STATUS checks
- Fix ProxyClient constructor null-check order (validate before new Uri)
- Narrow EncodeString catch to ArgumentException
- Add comprehensive tests for HttpResponseParser, HttpHelper, SOCKS5, PrefixedStream

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Rewrite README with static API examples, error codes table, and features
- Update NuGet readme with Proxy.ConnectAsync and extension method examples
- Add .NET 10.x to build.yaml and publish.yaml CI workflows

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Titlehhhh Titlehhhh merged commit ed57d83 into master Mar 8, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant