Skip to content

proxy_server: restrict SNI-rewrite dispatch to HTTPS CONNECT/SOCKS targets#50

Merged
therealaleph merged 1 commit into
therealaleph:mainfrom
freeinternet865:fix/limit-sni-rewrite-to-https
Apr 23, 2026
Merged

proxy_server: restrict SNI-rewrite dispatch to HTTPS CONNECT/SOCKS targets#50
therealaleph merged 1 commit into
therealaleph:mainfrom
freeinternet865:fix/limit-sni-rewrite-to-https

Conversation

@freeinternet865
Copy link
Copy Markdown
Contributor

@freeinternet865 freeinternet865 commented Apr 23, 2026

dispatch_tunnel() is only used by the HTTP CONNECT and SOCKS5 listeners.
It previously forced hosts matched by matches_sni_rewrite() or the hosts
override map into do_sni_rewrite_tunnel_from_tcp() regardless of port.

That tunnel is TLS-specific: it accepts inbound TLS from the client and
opens a second TLS connection to the Google edge. For non-HTTPS targets
such as :80, selecting that path makes the proxy wait for a ClientHello
that will never arrive.

Introduce should_use_sni_rewrite() and require port 443 before forcing the
rewrite tunnel from dispatch_tunnel(). Non-HTTPS targets now remain on the
normal dispatch path.

The tests now cover both suffix-based and hosts-map matches on ports 443
and 80.


Edited and written by GPT.

@freeinternet865 freeinternet865 force-pushed the fix/limit-sni-rewrite-to-https branch from 1130267 to dd057b7 Compare April 23, 2026 09:13
…rgets

dispatch_tunnel() is only used by the HTTP CONNECT and SOCKS5 listeners.
It previously forced hosts matched by matches_sni_rewrite() or the hosts
override map into do_sni_rewrite_tunnel_from_tcp() regardless of port.

That tunnel is TLS-specific: it accepts inbound TLS from the client and
opens a second TLS connection to the Google edge. For non-HTTPS targets
such as :80, selecting that path makes the proxy wait for a ClientHello
that will never arrive.

Introduce should_use_sni_rewrite() and require port 443 before forcing the
rewrite tunnel from dispatch_tunnel(). Non-HTTPS targets now remain on the
normal dispatch path.

The tests now cover both suffix-based and hosts-map matches on ports 443
and 80.
@freeinternet865 freeinternet865 force-pushed the fix/limit-sni-rewrite-to-https branch from dd057b7 to bbf270a Compare April 23, 2026 09:14
@freeinternet865 freeinternet865 changed the title Restrict SNI-rewrite dispatch to HTTPS CONNECT/SOCKS targets proxy_server: restrict SNI-rewrite dispatch to HTTPS CONNECT/SOCKS targets Apr 23, 2026
@therealaleph therealaleph merged commit cd3e486 into therealaleph:main Apr 23, 2026
therealaleph added a commit that referenced this pull request Apr 23, 2026
…only (#60)

Contains the three safety fixes from PRs #48/#49/#50 and the Persian
README RTL polishing from #58, all squashed into main. Merge details
already in their individual PR comments; summary:

  #48: reject truncated Content-Length relay responses (previously
       silently accepted whatever bytes arrived before EOF)
  #49: reject truncated or malformed (missing CRLF) chunked-encoding
       relay responses (same class of silent-acceptance bug)
  #50: restrict the SNI-rewrite tunnel dispatch to port 443. Plain
       HTTP (:80) targets that happened to match google.com / hosts
       override were being steered into the TLS tunnel and blocking
       waiting for a ClientHello that would never arrive.
  #58: trailing-whitespace line-breaks on Persian bullet lists in
       README so the RTL rendering doesn't collapse consecutive
       items into a single paragraph.

Test suite grew from 54 to 58 passing (three new negative tests for
the relay-reader correctness fixes + one SNI-rewrite port filter).

Telegram CI notify default switched to file-plus-link:
  - script gains a `--with-changelog` flag; default OFF
  - workflow only passes it when `vars.TELEGRAM_INCLUDE_CHANGELOG=true`
  - every routine release now posts just the APK + short caption
    (title + SHA-256 + repo URL + release URL) with no long body

To include bullets for a given release again:
  gh variable set TELEGRAM_INCLUDE_CHANGELOG --body true
The existing `vars.TELEGRAM_NOTIFY_ENABLED` job-level gate remains —
changelog toggle is orthogonal to enable/disable.

Also closes PR #55 without merging; ads/analytics domains were being
lumped under a YouTube-specific toggle, and the PR committed per-
machine \`.cargo/config.toml\` + zig-cc cross-compile helpers that
would have broken CI on actual Windows / macOS runners.
@freeinternet865 freeinternet865 deleted the fix/limit-sni-rewrite-to-https branch April 23, 2026 13:41
therealaleph pushed a commit that referenced this pull request Apr 25, 2026
…rgets (#50)

dispatch_tunnel() is only used by the HTTP CONNECT and SOCKS5 listeners.
It previously forced hosts matched by matches_sni_rewrite() or the hosts
override map into do_sni_rewrite_tunnel_from_tcp() regardless of port.

That tunnel is TLS-specific: it accepts inbound TLS from the client and
opens a second TLS connection to the Google edge. For non-HTTPS targets
such as :80, selecting that path makes the proxy wait for a ClientHello
that will never arrive.

Introduce should_use_sni_rewrite() and require port 443 before forcing the
rewrite tunnel from dispatch_tunnel(). Non-HTTPS targets now remain on the
normal dispatch path.

The tests now cover both suffix-based and hosts-map matches on ports 443
and 80.

Co-authored-by: freeinternet865 <free@internet865.com>
therealaleph added a commit that referenced this pull request Apr 25, 2026
…only (#60)

Contains the three safety fixes from PRs #48/#49/#50 and the Persian
README RTL polishing from #58, all squashed into main. Merge details
already in their individual PR comments; summary:

  #48: reject truncated Content-Length relay responses (previously
       silently accepted whatever bytes arrived before EOF)
  #49: reject truncated or malformed (missing CRLF) chunked-encoding
       relay responses (same class of silent-acceptance bug)
  #50: restrict the SNI-rewrite tunnel dispatch to port 443. Plain
       HTTP (:80) targets that happened to match google.com / hosts
       override were being steered into the TLS tunnel and blocking
       waiting for a ClientHello that would never arrive.
  #58: trailing-whitespace line-breaks on Persian bullet lists in
       README so the RTL rendering doesn't collapse consecutive
       items into a single paragraph.

Test suite grew from 54 to 58 passing (three new negative tests for
the relay-reader correctness fixes + one SNI-rewrite port filter).

Telegram CI notify default switched to file-plus-link:
  - script gains a `--with-changelog` flag; default OFF
  - workflow only passes it when `vars.TELEGRAM_INCLUDE_CHANGELOG=true`
  - every routine release now posts just the APK + short caption
    (title + SHA-256 + repo URL + release URL) with no long body

To include bullets for a given release again:
  gh variable set TELEGRAM_INCLUDE_CHANGELOG --body true
The existing `vars.TELEGRAM_NOTIFY_ENABLED` job-level gate remains —
changelog toggle is orthogonal to enable/disable.

Also closes PR #55 without merging; ads/analytics domains were being
lumped under a YouTube-specific toggle, and the PR committed per-
machine \`.cargo/config.toml\` + zig-cc cross-compile helpers that
would have broken CI on actual Windows / macOS runners.
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.

2 participants