client: share connect between cli and mobile#475
Draft
kp-antonio-yang wants to merge 5 commits into
Draft
Conversation
- LightwayConnection -> MobileConnection - ClientConnection -> CliConnection
Both the CLI path (connect) and mobile path (lightway_client_connect) were duplicating TLS context construction, connection building, and keepalive wiring. Extract that logic into a single pub(crate) establish() function that returns a Connect<T> struct bundling the live connection, keepalive handle, keepalive task/config, event stream, ticker task, and PMTUD timer task. Platform-specific builder tweaks are injected via two closures: - customize_ctx: called after cipher/plugins are set, before .build() - customize_conn: called after .with_auth()/.with_event_cb(), before .connect() Both call sites are updated to call establish() and destructure Connect<T>, removing ~60 lines of duplicated setup code. Unused imports in the mobile module are cleaned up as a result.
Rename CliConnection (non-mobile path) to ClientConnection behind to ClientConnection behind #[cfg(feature = "mobile")], giving both paths a single consistent name while keeping their distinct field sets. Add two feature-gated Connect::into_client_connect() methods as a clean constructor API for callers that work with an intact Connect value: - non-mobile: takes task, inside_io, outside_io (desktop-gated), connected_signal, stop_signal, network_change_signal, and encoding_request_signal; contributes conn from self - mobile (Connect<Option<Arc<Tun>>>): takes outside_io_task, new_outside_io_sender, join_set, instance_id, and expresslane_event_rx; contributes conn, keepalive, keepalive_task, and keepalive_config from self
|
Code coverage summary for a55e71f: ✅ Region coverage 68% passes |
When cross-compiling from a desktop host to a mobile target, the `desktop` cfg alias would incorrectly match. Added `not(feature="mobile")` guard so the alias only resolves for actual desktop client builds.
kp-antonio-yang
force-pushed
the
refact-client-connect
branch
from
July 23, 2026 01:53
1e76468 to
d00f7a0
Compare
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.
Description
Motivation and Context
How Has This Been Tested?
Types of changes
Checklist:
main