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 support for socket protection callbacks, which is especially important for Android VPN clients to exclude sockets from VPN routing (using Android's VpnService.protect()). It also improves TCP connection reliability by enabling TCP keepalive and refines the packet loop for more responsive keepalive handling. Additionally, a flush method is added to the connection manager, and the FFI layer is updated to expose the new callback to JNI.
Android socket protection and FFI integration:
ProtectSocketCallbacktype and a newprotect_socketfield to theSoftEtherCallbacksstruct, with associated default and clone implementations, allowing the FFI consumer to provide a callback for socket protection [1] [2] [3] [4].jni_protect_socketfunction and registration in the JNI bridge, enabling Android to call back into Java to protect sockets [1] [2].TCP connection reliability improvements:
socket2crate and enabled TCP keepalive on VPN connections (both normal and protected), which is critical for preventing NAT timeouts, especially on mobile networks [1] [2] [3] [4].Connection logic enhancements:
connect_with_protectasync method inVpnConnection(Unix only), which calls the protect socket callback before establishing TLS, ensuring the socket is protected before any sensitive traffic is sent.connect_with_protectand pass the callback from the FFI layer, both for initial and redirect connections [1] [2].Packet loop and connection management:
flushasync method toConnectionManagerto flush all send-capable connections, which can be useful for ensuring all pending data is sent.