Commit 250ae60
committed
refactor(service)!: rework outbound proxy chain into a unified client
Replace the previous parallel outbound proxy implementations
(net::outbound_proxy + local::net::tcp::outbound_proxy) with a single
self-contained module at net::outbound, exposing OutboundProxyClient,
OutboundProxyStream, Socks5Auth, HttpProxyAuth and a TcpDialer trait.
Highlights:
* OutboundProxyStream is now a closed-set enum (Bypassed / Https / Http)
with statically-dispatched poll_* — no more Box<dyn ProxyStream>. The
HTTPS variant boxes its inner OutboundProxyStream solely to break the
recursive type instantiation required by the TLS libraries; this is
not dynamic dispatch.
* HTTP CONNECT client is rebuilt on top of hyper::client::conn::http1
+ hyper::upgrade. The hand-rolled status-line parser (which could
drop bytes that arrived in the same read() as the header terminator,
did not handle 100-Continue, etc.) is gone.
* Auth parameters are now strongly typed:
Socks5Auth::{None, UsernamePassword{..}}
HttpProxyAuth::{None, Basic{..}}
Both enums are #[non_exhaustive] for forward compatibility.
* AutoProxyClientStream's ProxiedViaChain variant is folded back into a
single Proxied(ProxyClientStream<MonProxyStream<OutboundTransport>>)
variant, with OutboundTransport = Direct(TcpStream) | Chained(...).
* ServiceContext (both server and local) now caches an
Arc<OutboundProxyClient> built once at set_outbound_proxies time
instead of re-parsing the chain on every connection.
* The standalone Socks5TcpClient / Socks5UdpClient implementations
previously duplicated across net::socks5_client and
local::socks::client::socks5 are unified into the latter location;
net::outbound::socks5 only keeps the chain-friendly Socks5Negotiator.
* When UDP is enabled but the configured chain contains a non-SOCKS5
hop, sslocal/ssserver emits a single startup warning. Phase 2 will
add UDP relay support for SOCKS5-only chains.
BREAKING CHANGE: the following items have moved or been removed:
* crate::net::outbound_proxy — removed; use crate::net::OutboundProxyClient
* crate::net::http_connect::HttpConnectClient — moved to
crate::net::HttpConnectClient (only available with the local-http feature)
* crate::net::Socks5TcpClient (the chain-mixing wrapper) — split: the
pure SOCKS5 client is now crate::local::socks::client::socks5::Socks5TcpClient;
the in-band negotiator is crate::net::Socks5Negotiator
* crate::local::net::tcp::outbound_proxy — removed
* ServiceContext::outbound_proxies() — replaced by outbound_client()
returning Option<&Arc<OutboundProxyClient>>1 parent e2ecfae commit 250ae60
23 files changed
Lines changed: 1375 additions & 722 deletions
File tree
- crates/shadowsocks-service/src
- local
- http
- net/tcp
- socks/client/socks5
- net
- outbound
- server
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
22 | 26 | | |
23 | 27 | | |
24 | 28 | | |
| |||
36 | 40 | | |
37 | 41 | | |
38 | 42 | | |
39 | | - | |
40 | | - | |
| 43 | + | |
| 44 | + | |
41 | 45 | | |
42 | 46 | | |
43 | 47 | | |
| |||
62 | 66 | | |
63 | 67 | | |
64 | 68 | | |
65 | | - | |
| 69 | + | |
66 | 70 | | |
67 | 71 | | |
68 | 72 | | |
| |||
115 | 119 | | |
116 | 120 | | |
117 | 121 | | |
118 | | - | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
119 | 127 | | |
120 | 128 | | |
121 | | - | |
122 | | - | |
123 | | - | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
124 | 132 | | |
125 | 133 | | |
126 | 134 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
186 | | - | |
187 | | - | |
188 | | - | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
189 | 193 | | |
190 | 194 | | |
191 | 195 | | |
| |||
Lines changed: 126 additions & 53 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
25 | 118 | | |
26 | 119 | | |
27 | 120 | | |
28 | 121 | | |
29 | 122 | | |
30 | | - | |
31 | | - | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
32 | 127 | | |
33 | 128 | | |
34 | 129 | | |
| |||
83 | 178 | | |
84 | 179 | | |
85 | 180 | | |
86 | | - | |
87 | 181 | | |
88 | 182 | | |
89 | 183 | | |
| |||
143 | 237 | | |
144 | 238 | | |
145 | 239 | | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
155 | 245 | | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
162 | 251 | | |
163 | | - | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
164 | 256 | | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
182 | 264 | | |
183 | | - | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
184 | 270 | | |
185 | 271 | | |
186 | 272 | | |
187 | 273 | | |
188 | 274 | | |
189 | | - | |
190 | 275 | | |
191 | 276 | | |
192 | 277 | | |
193 | 278 | | |
194 | 279 | | |
195 | 280 | | |
196 | 281 | | |
197 | | - | |
198 | 282 | | |
199 | 283 | | |
200 | 284 | | |
201 | 285 | | |
202 | 286 | | |
203 | 287 | | |
204 | 288 | | |
205 | | - | |
| 289 | + | |
206 | 290 | | |
207 | 291 | | |
208 | 292 | | |
209 | 293 | | |
210 | 294 | | |
211 | 295 | | |
212 | 296 | | |
213 | | - | |
214 | 297 | | |
215 | 298 | | |
216 | 299 | | |
| |||
220 | 303 | | |
221 | 304 | | |
222 | 305 | | |
223 | | - | |
224 | 306 | | |
225 | 307 | | |
226 | 308 | | |
227 | 309 | | |
228 | 310 | | |
229 | 311 | | |
230 | 312 | | |
231 | | - | |
232 | 313 | | |
233 | 314 | | |
234 | 315 | | |
235 | 316 | | |
236 | 317 | | |
237 | 318 | | |
238 | 319 | | |
239 | | - | |
240 | 320 | | |
241 | 321 | | |
242 | 322 | | |
| |||
248 | 328 | | |
249 | 329 | | |
250 | 330 | | |
251 | | - | |
252 | 331 | | |
253 | 332 | | |
254 | 333 | | |
255 | 334 | | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
0 commit comments