-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Allow user to pass SocketProtectFn for android #1974
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
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
Signed-off-by: San Zhang <[email protected]>
Contributor
Author
|
@zonyitoo, Please check this new PR. |
zonyitoo
reviewed
Jun 18, 2025
zonyitoo
reviewed
Jun 18, 2025
Collaborator
|
This is not the design I have mentioned in the previous PR. What I wanted was: trait SocketProtect {
fn protect(fd: RawFd) -> io::Result<()>;
}
struct SocketProtectFn<F> {
f: F
}
impl<F> SocketProtect for SocketProtectFn<F>
where F: Fn(RawFd) -> io::Result<()>
{
fn protect(&self, fd: RawFd) -> io::Result<()> {
self.f(fd)
}
}
pub fn make_socket_protect_fn(f: F) -> SocketProtectFn<F>
where F: Fn(RawFd) -> io::Result<()> + Send + Sync + Clone
{
SocketProtectFn { f }
}
struct ConnectOpts {
// ... other fields
#[cfg(target_os = "android")]
pub vpn_socket_protect_fn: Option<Arc<Box<dyn SocketProtect + Send + Sync>>>,
}I would recommend |
zonyitoo
reviewed
Jun 18, 2025
Signed-off-by: San Zhang <[email protected]>
Signed-off-by: San Zhang <[email protected]>
Signed-off-by: San Zhang <[email protected]>
Signed-off-by: San Zhang <[email protected]>
Signed-off-by: San Zhang <[email protected]>
Signed-off-by: San Zhang <[email protected]>
zonyitoo
reviewed
Jun 18, 2025
Signed-off-by: San Zhang <[email protected]>
zonyitoo
reviewed
Jun 18, 2025
Signed-off-by: San Zhang <[email protected]>
Signed-off-by: San Zhang <[email protected]>
Signed-off-by: San Zhang <[email protected]>
zonyitoo
added a commit
that referenced
this pull request
Jun 21, 2025
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.
Allow user to implement the Rust interface which calls the Java VPNService protect method on Android, and to be used to protect the socket fd right after the socket is created.