Integration/android #19
Merged
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.
This pull request introduces several improvements focused on enhancing VPN connection reliability, especially for mobile and Android environments. The most significant changes are the addition of TCP keepalive support to prevent NAT timeouts, a new callback mechanism for socket protection (important for Android's VPN routing), and improvements to the packet loop's keepalive logic for more responsive and reliable connections.
Connection reliability and keepalive improvements:
socket2crate, configuring keepalive probes to start after 10 seconds of idle time and repeat every 5 seconds, to help prevent NAT timeouts on mobile networks (Cargo.toml,src/client/connection.rs). [1] [2] [3]src/ffi/client.rs). [1] [2] [3]Android/FFI integration and socket protection:
ProtectSocketCallbackin the FFI layer and added it to theSoftEtherCallbacksstruct, enabling the client to request protection of sockets from VPN routing (critical for Android's VpnService integration) (src/ffi/callbacks.rs). [1] [2] [3]connect_with_protectmethod inVpnConnectionthat invokes the protection callback on the socket before establishing the TLS connection, and updated FFI client code to use this method (src/client/connection.rs,src/ffi/client.rs). [1] [2] [3]onProtectSocketmethod and ensuring it is registered during native client creation (src/ffi/jni.rs). [1] [2]Other improvements:
flushmethod toConnectionManagerto allow flushing all send-capable connections, improving control over connection state (src/client/multi_connection.rs).src/ffi/client.rs).These changes collectively improve VPN stability, especially on mobile devices, and enable proper integration with Android's VPN APIs.