35 Commits
Author SHA1 Message Date
KKRainbow 268533568d test: keep one historical KCP compatibility baseline
CI / Lint (push) Canceled after 0s
CI / Linux arm64 (debug) (push) Canceled after 0s
CI / Linux arm64 (release) (push) Canceled after 0s
CI / Linux x64 (debug) (push) Canceled after 0s
CI / Linux x64 (release) (push) Canceled after 0s
CI / Windows arm64 (debug) (push) Canceled after 0s
CI / Windows arm64 (release) (push) Canceled after 0s
CI / Windows x64 (debug) (push) Canceled after 0s
CI / Windows x64 (release) (push) Canceled after 0s
CI / macOS arm64 (debug) (push) Canceled after 0s
CI / macOS arm64 (release) (push) Canceled after 0s
CI / macOS x64 (debug) (push) Canceled after 0s
CI / macOS x64 (release) (push) Canceled after 0s
CI / Cross aarch64-unknown-linux-musl (debug) (push) Canceled after 0s
CI / Cross riscv64gc-unknown-linux-musl (debug) (push) Canceled after 0s
CI / Cross x86_64-unknown-linux-musl (debug) (push) Canceled after 0s
CI / Cross aarch64-unknown-linux-musl (release) (push) Canceled after 0s
CI / Cross riscv64gc-unknown-linux-musl (release) (push) Canceled after 0s
CI / Cross x86_64-unknown-linux-musl (release) (push) Canceled after 0s
Remove the intermediate b37ee660 dev-dependency and its duplicate
compatibility cases. Keep the pre-negotiation d7427c22 endpoint as
the maintained legacy baseline.

Flatten the single-use test macro into ordinary test functions and
retain negotiation, bidirectional data, half-close, and duplicate SYN
assertions. Protocol implementation files are unchanged.

Validation: all 31 tests and strict Clippy pass.
2026-09-14 22:04:54 +08:00
KKRainbow 3ef5c4161f fix(protocol): keep stateless resets from blocking input
Use nonblocking output for reliable stateless responses when the queue
is full. Preserve legacy behavior and keep stateful controls pending.

Add a regression that saturates output and verifies an unknown FIN
cannot prevent the next connection from entering the handshake.
2026-09-14 18:13:17 +08:00
KKRainbow c84733d447 fix(protocol): recover KCP control loss with legacy negotiation
Negotiate reliable control packets in the reserved header byte while
preserving legacy handshake and output behavior for older endpoints.
Retry SYN, SYN-ACK and FIN with bounded deadlines, acknowledge FIN
independently, and handle duplicate handshakes and early empty closes.

Retain graceful close records for late FIN acknowledgements. Serialize
control sends with cleanup, cancel abandoned connects, and keep resets
and transport failures distinct from EOF.

Cover deterministic loss, reordering, queue saturation, close retention
and real d7427c2/b37ee660 interoperability. All 33 tests pass.
Both examples, formatting and strict all-targets clippy also pass.
2026-09-14 17:57:48 +08:00
KKRainbow b37ee660fb fix(endpoint): start keepalives after the handshake completes
Exclude handshake states from periodic keepalives. A startup ping can
overtake SYN, causing the peer to reset the unknown connection before
the handshake response arrives. Keep Established, LocalClosed and
PeerClosed connections eligible for their existing keepalive behavior.

Windows packet traces reproduce the premature PING, RST, then SYN on
both the original d7427c2 dependency and the close-fix branch. Add a
deterministic state-boundary regression that fails on the old behavior.

All 10 tests and both example targets pass on Linux, macOS and Windows;
Linux and macOS formatting and strict all-targets clippy checks pass.
2026-09-14 16:31:48 +08:00
KKRainbow 66a812ec01 test(endpoint): bound handshakes in close regression tests
Use a shared test helper with try_join so a failed connect immediately
cancels the pending accept instead of hanging before data timeouts are
installed. Keep the one-second connect timeout and bound the complete
handshake to report stalled accepts with useful failure context.

This exposed a Windows startup failure as a peer reset rather than an
apparent deadlock. Existing production behavior and older tests remain
unchanged.
2026-09-14 16:29:23 +08:00
KKRainbow d0dc846f22 fix(endpoint): order EOF checks and atomically expire state
Read receive-close state before peeking at buffered KCP data so a FIN
arriving after an empty peek cannot turn that stale result into EOF.
Evaluate expiration and remove state under the same state-map lock so
a concurrent pong cannot revive an entry selected for later deletion.
Remove corresponding connections after releasing state-map locks.

Run buffered half-close and simultaneous-close tests on a two-worker
runtime. All 9 tests and example targets pass, with 100 additional
multithreaded FIN drain repetitions, formatting and strict clippy.
2026-09-14 16:15:12 +08:00
KKRainbow 26aa1a461d fix(endpoint): preserve FIN received before stream creation
Accept established connections whose peer has already closed its write
direction. Initialize their receive task with the saved FIN so empty
requests produce EOF and can still receive a response. Apply the same
handling when an empty response arrives before connect resumes.

Add deterministic tests for FIN preceding accept and for SYN-ACK plus
FIN arriving before the connecting future resumes. The delayed accept
case times out before this fix and returns EOF plus its response after.

Validation: all 9 tests and both example targets pass, with formatting
and strict all-targets clippy checks passing.
2026-09-14 16:08:28 +08:00
KKRainbow 990e4f1e2a fix(stream): drain received data before reporting graceful EOF
Keep acknowledged KCP data flowing to the application after peer FIN.
Delay connection cleanup until the receive task finishes, including
when both write directions close before the application reads.
Track graceful receive completion separately from resets so AsyncRead
reports EOF for FIN and keeps errors for RST or endpoint destruction.
Answer keepalive pings while the local write direction is closed.

Cover a 200 KiB request followed by a response after EOF, simultaneous
buffered shutdown across a cleanup interval, half-close keepalives,
and pending reads interrupted by reset or endpoint destruction.

Validation: all 7 library tests and both example targets pass;
cargo fmt --check and clippy --all-targets -- -D warnings pass.
2026-09-14 16:03:52 +08:00
KKRainbow 01debae786 fix(endpoint): retain pending accepts when notifications fill
Record pending server accepts in connection state so a full bounded
notification channel cannot strand an established connection. Drain
queued IDs first and claim pending state when notifications run out.
Only server handshakes enter the accept path, and claims are serialized
to prevent duplicate delivery.

Add a regression that completes 32 handshakes before accepting any of
them. It times out on the fifth accept before the fix and delivers every
connection exactly once after the fix.
2026-09-14 16:03:52 +08:00
fanyang d7427c22d7 Merge pull request #4 from EasyTier/fix-riscv64gc-bindgen
fix: support riscv64gc bindgen target
2026-05-22 23:58:41 +08:00
KKRainbow e9042b87c5 Merge pull request #3 from EasyTier/kcp2
Update kcp to 2.0.0 and expose new APIs
2026-05-15 14:00:40 +08:00
fanyang 8d995dbf73 With cmake4 2026-05-15 13:33:29 +08:00
fanyang e83b61adcd feat: expose kcp congestion control API 2026-05-15 13:23:49 +08:00
fanyang 4feb8f7f37 chore: update kcp to 2.0.0 2026-05-15 13:04:37 +08:00
KKRainbow 76e2cfcaf4 Merge pull request #2 from fanyang89/support-zig-build
Add support for cross-compilation using cargo-zigbuild
2026-04-06 15:27:19 +08:00
fanyang 6c6f68723d ci: add full build matrix across all GitHub-hosted runners 2026-04-06 11:54:53 +08:00
fanyang 264e691582 fix(build): support zigbuild cross-compilation and llvm-ar
Rework build.rs to auto-detect cargo-zigbuild via `CC/CC_{target}` env
vars, forward zig system include paths to bindgen for cross-compilation,
and use `llvm-ar` on macOS to avoid `ar -D` warning.
2026-04-05 22:45:01 +08:00
fanyang df8fba416f chore(lint): format code and fix clippy warnings 2026-04-05 22:45:01 +08:00
fanyang 19bddd603f chore: update kcp submodule 2026-04-05 22:40:24 +08:00
KKRainbow 94964794ca Merge pull request #1 from chenx-dust/main
Upgrade bindgen to 0.72.1 to fix build issue of iOS simulator
2025-12-31 22:32:57 +08:00
Chenx Dust f78a5df86a upgrade bindgen to 0.72.1 to fix ios simulator building 2025-12-31 18:18:41 +08:00
sijie.sun 71eff18c57 release dashmap memory 2025-10-17 21:26:18 +08:00
sijie.sun 0f0a055839 all incoming packet should update pong time 2025-02-08 23:32:11 +08:00
sijie.sun d4c7af9988 add git ignore 2025-01-27 23:05:35 +08:00
sijie.sun 37f653c74e add examples and readme 2025-01-27 23:04:55 +08:00
sijie.sun 9ce5c08807 fix pingpong 2025-01-26 15:11:59 +08:00
sijie.sun b8b04da247 avoid empty header paths 2025-01-26 12:49:41 +08:00
sijie.sun a932f3ed39 use env to load clang include paths 2025-01-25 23:58:01 +08:00
sijie.sun 0f2fea1ffe fix pingpong 2025-01-25 23:32:19 +08:00
sijie.sun b82957784f try fix cross compile for 32-bit arm 2025-01-25 09:18:10 +08:00
sijie.sun 1f3af9d332 fix cross compile for aarch64 2025-01-24 21:56:48 +08:00
sijie.sun a5f4b4e3a0 support connection management 2025-01-24 17:28:11 +08:00
sijie.sun 0057f666b7 fix github workflow 2025-01-12 01:29:08 +08:00
sijie.sun b30e472539 kcp pingpong works 2025-01-12 01:23:30 +08:00
sijie.sun 519386124c initial version 2025-01-10 23:03:37 +08:00