Support Shadowsocks outbound proxy hops - #2157
Open
missdeer wants to merge 2 commits into
Open
Conversation
Add TCP-only encrypted hop chaining with first-hop SIP003 plugins and fail closed for unsupported UDP traffic.
missdeer
marked this pull request as ready for review
July 20, 2026 05:06
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds TCP-only Shadowsocks (
ss://) hops to the existingoutbound_proxychain used bysslocalandssserver.It allows an outbound connection to traverse an encrypted Shadowsocks edge hop before reaching the normal Shadowsocks server or another supported proxy hop. Existing SOCKS5, HTTP, and HTTPS outbound-proxy configurations continue to use the same configuration forms and connection paths.
Motivation
The existing outbound chain can hide the final Shadowsocks server behind SOCKS5/HTTP CONNECT proxies, but it cannot use a Shadowsocks server itself as an encrypted intermediate hop. This is useful for deployments where:
sslocalorssserverprocess instead of requiring an additional local forwarding process.What changed
Configuration and URL compatibility
OutboundProxyis now an enum with separate plain-proxy and Shadowsocks-hop variants.ss://URLs are parsed throughServerConfig, so cipher, password, remarks, and SIP003 plugin parameters use the existing Shadowsocks parser.to_url()supports round-tripping Shadowsocks hops.outbound_proxyconfiguration formats remain supported.examples/chain-ss.json5.TCP chain composition
OutboundProxyKindgains anSsvariant backed by anArc<ServerConfig>.ProxyClientStreamfor anss://hop.OutboundProxyStreamgains a boxed Shadowsocks variant. Boxing breaks the recursive stream type while preserving static async I/O dispatch.SIP003 plugin lifecycle
Plugindrop behavior.Unsupported; supporting those requires per-connection rendezvous plumbing and is intentionally outside this PR.UDP behavior
Shadowsocks outbound hops are TCP-only in this PR.
ss://hop reports that it does not support UDP.OutboundProxyDatagramassociation returnsio::ErrorKind::Unsupportedwith a specific diagnostic.Diagnostics and documentation
ss://, first-hop plugin support, TCP-only behavior, and the new example.Compatibility and limitations
Tests
The new integration suite covers:
Send + Synccompatibility of the cached outbound client;Local validation completed successfully:
cargo test -p shadowsocks-service --test outbound_ss --no-default-features --features aead-cipher -- --nocapture(6 passed,2 ignoredhelper entry points)cargo check --features full-extracargo build --features fullon Windows with NASM 3.01cargo clippy --features "full-extra local-flow-stat utility-url-outline" -- -A clippy::absurd_extreme_comparisonsgit diff --checkGitHub Actions completed successfully on the pushed branch:
Security considerations
ss://chains instead of bypassing the configured route.