Commit Graph
578 Commits
Author SHA1 Message Date
eric d2fcffbd76 feat(ws): let a websocket transport signal the end of a request
A client that has finished sending says so by closing its write side and goes
on reading, and plenty of protocols end a request that way and no other. Over
a websocket transport that signal went nowhere: `poll_shutdown` returned
without sending anything, so the far end learned the request had ended only
when the connection itself went away -- when the downlink grace expires, ten
seconds later, by which time the reply has nowhere to go. The comment above it
said as much.

A Close frame is the obvious candidate and the wrong one. RFC 6455 makes it
the start of closing the whole connection, and tungstenite enforces that at
both ends: once a Close has been received the connection will not carry
another data frame, so the reply still on its way back is lost. Measured, not
assumed -- the server read the origin's answer and then failed to forward it.

An empty binary frame says the same thing and costs nothing. It is an ordinary
data frame carrying no bytes, so a peer that does not understand it hands
nothing to its application and carries on, which is exactly today's behaviour.
This transport's read side has always turned a frame with no bytes into an end
of stream, so between two leaf nodes it is precisely the missing signal. A
write of no bytes now returns early rather than sending one by accident.

Still behind WS_HALF_CLOSE, off by default, for the peer that would rather
error than ignore it. Booleans now also accept 1/yes/on: an option that is
silently ignored, as WS_HALF_CLOSE=1 was, is worse than one that is missing.
2026-09-09 21:28:24 +08:00
eric 64d92432ed fix(net): close inbound connections gracefully by default
Every accepted inbound socket was given SO_LINGER = 0, so closing it sent a
reset. That discards whatever is still queued for the peer: a response whose
end is marked by the close itself -- HTTP/1.0, a body with no length, anything
read to EOF -- can be truncated, and a peer that has received every byte but
not yet read them can still see the transfer fail with a reset.

What it bought was the socket back at once, with no TIME_WAIT. But TIME_WAIT
falls on whoever closes first, and on the common paths that is the client:
leaf is the passive closer and has no TIME_WAIT to avoid. The reclaim is only
ever paid for on the paths where leaf closes first -- the idle timeouts and
the error teardowns -- and those are the paths where a reset is the right
answer anyway.

So it is now off by default and available as TCP_INBOUND_ABORT_ON_CLOSE, for
devices that cannot afford the sockets. Sessions are still bounded by the
existing uplink and downlink idle timeouts.
2026-09-09 13:45:51 +08:00
eric dbc858733c style: rustfmt chain and quic inbound 2026-09-08 14:12:39 +08:00
eric f809b04782 fix(inbound): scope the tracing span guard in the TCP accept path
The entered span guard was held across the await of the connection
handler, so the span stayed entered on the thread while the task yielded
and unrelated tasks were attributed to it. The span variable was also
shadowed right after the guard was taken. Scope the guard to the debug
log and keep a single span.
2026-09-08 14:12:39 +08:00
eric 7ce1f83fe5 fix(stat): keep outbound UDP session alive across datagram split
Datagram::split() takes the inner datagram and then drops the wrapper,
which notified the cleanup task and retired the session counters right
when traffic was about to start. Only end the session on drop if the
datagram was never split; once split, the recv/send halves drive
retirement through move_to_recent. Add tests for both paths.
2026-09-08 14:12:39 +08:00
eric 1d20301570 Revert "feat(inbound): limit data transfer and concurrent connections per IP"
This reverts commit 05e872ac0a.
2026-06-18 13:28:41 +08:00
eric 05e872ac0a feat(inbound): limit data transfer and concurrent connections per IP 2026-06-17 23:28:05 +08:00
eric 7ea00627dc Increase OUTBOUND_DIAL_TIMEOUT default value from 4s to 8s 2026-06-14 13:35:19 +08:00
eric ba6cbd4134 Optimize QUIC timeout and keep-alive configuration for client and server 2026-06-14 13:11:55 +08:00
eric b7184f87be quic: avoid blocking stream opens on pooled connections 2026-06-12 15:59:56 +08:00
eric f967434f9f Add project logo 2026-05-28 15:44:46 +08:00
eric 87f50a0270 Add default method for shadowsocks inbound 2026-05-22 21:25:26 +08:00
eric 7a9101b5f5 Fix QUIC inbound 2026-04-27 20:37:09 +08:00
eric a8971524d6 Add MPTP usage 2026-03-19 07:17:33 +08:00
eric d5ed615f7f fix(mptp): make inbound CID session registration atomic under single write lock 2026-03-19 07:17:17 +08:00
eric 291af8b9f0 Refactor DNS client 2026-03-15 17:53:17 +08:00
eric 26d17f9da7 Add a DNS selector 2026-03-15 17:13:09 +08:00
eric eea1f5a465 Skip invalid DNS server 2026-03-15 16:32:24 +08:00
eric a5e4d2adc9 Use aws-lc-rs 2026-03-14 10:31:18 +08:00
eric f576d34b95 Fix build and test 2026-03-14 10:05:51 +08:00
eric 019bdeaeb0 Improve openssl backend ECH handling 2026-03-14 08:18:21 +08:00
eric 309f9e9c6d Improve ring backend ECH handling 2026-03-14 07:22:35 +08:00
eric b14e2e368d Support DoH 2026-03-14 06:43:26 +08:00
eric a3459cc0d1 Support ECH config DNS lookup 2026-03-13 21:39:37 +08:00
eric 12f77224c6 Support setting environment variables in JSON config 2026-03-13 16:59:51 +08:00
eric 822889c78a Support ECH 2026-03-13 16:58:55 +08:00
eric 4dd6f89493 Fix Apple builds 2026-03-03 16:46:51 +08:00
eric b7453f50ff Fix tests 2026-03-02 08:43:14 +08:00
eric 7a567e833a Save recent connections in stat manager 2026-03-01 12:39:30 +08:00
eric a911e542f6 Resolve direct domains with direct DNS servers 2026-03-01 10:19:08 +08:00
eric d82a54e34e Add docs for MPTP 2026-03-01 08:06:52 +08:00
eric 7d5f1e5544 Add tests for MPTP 2026-03-01 08:00:12 +08:00
eric 3a150d5da3 Fix Android build 2026-03-01 07:50:58 +08:00
eric a79358236e Improve conf section name compatibility 2026-02-28 21:48:07 +08:00
eric 32895f4f8b Fix domain sniffing/override 2026-02-28 21:20:43 +08:00
eric f46cf41410 Improve logging 2026-02-28 20:38:00 +08:00
eric fa8999181e Fix MPTP UDP inbound 2026-02-28 20:21:40 +08:00
eric 50d0be1806 Refactor 2026-02-28 20:21:35 +08:00
eric 804942e4b8 Refactor 2026-02-27 22:50:19 +08:00
eric be043cd96d Fix MPTP 2026-02-27 20:15:00 +08:00
eric 4cb248086c v0.14.2 v0.14.2 2026-02-25 17:33:53 +08:00
eric 428f448f76 Support raw certificate configuration for JSON 2026-02-25 17:33:28 +08:00
eric 7474076902 v0.14.1 v0.14.1 2026-02-25 16:22:46 +08:00
eric 0bd92d4aaf Add more compatibilities to conf config 2026-02-25 11:12:39 +08:00
eric e836c9160f Fix MPTP single path blocking issue 2026-02-24 20:48:35 +08:00
eric 760820ac52 Dial MPTP sub streams concurrently 2026-02-24 19:41:46 +08:00
eric 0ff4794aa5 Add conf config support for MPTP 2026-02-24 19:32:02 +08:00
eric 9b1e62b623 Fix outbound order 2026-02-24 17:08:25 +08:00
eric c26a372b94 Update readme 2026-02-24 16:11:11 +08:00
eric f7b288ecf4 Add MPTP protocol 2026-02-24 16:01:40 +08:00