Skip to content
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

feat: Android compatibility #22

Merged
merged 9 commits into from
Mar 23, 2023
Merged

Conversation

dignifiedquire
Copy link
Contributor

@dignifiedquire dignifiedquire commented Mar 12, 2023

Unfortunately the default ways are not as easily used on different Android versions.

This implements two different versions for doing this on Android, which should allow supporting Android back to NDK API version 16 (the one that I need currently) up to today.

The first approach is to use dlopen to load libc and use getifaddrs which should work on API 24 and up. The headers are unfortunately not exposed, which is why this workaround is needed.
For all other versions where the symbols are not available, a backup using netlink is implemented.

This is currently still being tested, which is why I am opening this as a draft, for feedback if this would be merged once it is confirmed to be working.

(Sorry for the whitespace changes, I ran cargo fmt on the files I was working on)

@link2xt
Copy link
Contributor

link2xt commented Mar 19, 2023

Is this ready for review?

(Sorry for the whitespace changes, I ran cargo fmt on the files I was working on)

I opened #23, would be nice if the project source was formatted already.

@dignifiedquire dignifiedquire marked this pull request as ready for review March 19, 2023 12:49
@dignifiedquire
Copy link
Contributor Author

Is this ready for review?

Yes, tested and works now in the described cases.

@link2xt
Copy link
Contributor

link2xt commented Mar 20, 2023

@dignifiedquire Looks like dlopen is not maintained: szymonwieloch/rust-dlopen#47
There is a maintained dlopen2 with updated dependencies.

@flub
Copy link
Contributor

flub commented Mar 21, 2023

@shellrow we had some discussion about whether it's worth switching to dlopen2 or not and were rather inconclusive. So it's up to you really, would you prefer us to switch over or leave it as is?

@shellrow
Copy link
Owner

@flub Sorry for the late reply. We should migrate to dlopen2 which is still maintained.
(I'll continue to maintain default-net, although I don't have enough time at the moment)

@flub
Copy link
Contributor

flub commented Mar 22, 2023

@flub Sorry for the late reply. We should migrate to dlopen2 which is still maintained.

Cool, done.

(I'll continue to maintain default-net, although I don't have enough time at the moment)

Thanks! If you like we [0] would always be happy to help out maintaining as we'll be relying on this and keep having stakes on it working on lots of platforms. Of course I know that's a tall demand from people you've never known before... so don't worry if you'd rather decline. But also don't hesitate to ask whatever you'd like to see done. We can at least make it as simple as hitting the merge button on a bunch of PRs.

[0] That would be the n0 and deltachat teams: https://github.com/n0-computer and https://github.com/deltachat

Copy link
Owner

@shellrow shellrow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants