[GH-ISSUE #3317] Real iOS support #1168

Closed
opened 2026-03-16 01:47:25 +03:00 by kerem · 4 comments
Owner

Originally created by @lemon-sh on GitHub (Oct 17, 2025).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/3317

Is your feature request related to a problem? Please describe.
On *nixes, hickory-resolver reads DNS configuration from /etc/resolv.conf which is nonexistent on iOS, so it fails on that platform unless nameservers are explicitly specified.

Describe the solution you'd like
Hickory could possibly use a similar approach to c-ares for retrieving the system configuration, or use libresolv directly (also something that c-ares implements, and used to use on Apple before).

The libresolv solution seems easier and could be used on other, non-Apple platforms too as far as I understand (and is possibly less likely to trigger App Store Review issues?), but there are caveats (see first link).

Describe alternatives you've considered

  • implementing the above solution in my own code and passing the nameservers to hickory, just for the iOS platform
  • conditionally disabling hickory in my app in favor of a custom dnssd-based implementation, also not ideal
Originally created by @lemon-sh on GitHub (Oct 17, 2025). Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/3317 **Is your feature request related to a problem? Please describe.** On *nixes, `hickory-resolver` reads DNS configuration from `/etc/resolv.conf` which is nonexistent on iOS, so it fails on that platform unless nameservers are explicitly specified. **Describe the solution you'd like** Hickory could possibly use a [similar approach to `c-ares`](https://github.com/c-ares/c-ares/blob/1d1b3d4a808dff9359cacb4539ac1b775876dcb6/src/lib/ares_sysconfig_mac.c#L29) for retrieving the system configuration, or [use `libresolv` directly](https://stackoverflow.com/questions/31256024/get-dns-server-ip-from-iphone-settings) ([also something that c-ares implements, and used to use on Apple before](https://github.com/c-ares/c-ares/blob/1d1b3d4a808dff9359cacb4539ac1b775876dcb6/src/lib/ares_sysconfig.c#L353)). The `libresolv` solution seems easier and could be used on other, non-Apple platforms too as far as I understand (and is possibly less likely to trigger App Store Review issues?), but there are caveats (see first link). **Describe alternatives you've considered** - implementing the above solution in my own code and passing the nameservers to hickory, just for the iOS platform - conditionally disabling hickory in my app in favor of a custom `dnssd`-based implementation, also not ideal
kerem 2026-03-16 01:47:25 +03:00
Author
Owner

@lemon-sh commented on GitHub (Oct 18, 2025):

I should note that I'm willing to contribute code in order to get this done, but I'm not sure which FFI approach is preferred here by the hickory team. For example, for libresolv:

  • bindgen could be used to generate bindings for resolv.h, but it seems overkill for just the state struct and two functions, and there's a bunch of generated code to keep in the repo
  • the code could be written in C and expose a simple interface to be used by the Rust code
<!-- gh-comment-id:3418578696 --> @lemon-sh commented on GitHub (Oct 18, 2025): I should note that I'm willing to contribute code in order to get this done, but I'm not sure which FFI approach is preferred here by the hickory team. For example, for `libresolv`: - bindgen could be used to generate bindings for resolv.h, but it seems overkill for just the state struct and two functions, and there's a bunch of generated code to keep in the repo - the code could be written in C and expose a simple interface to be used by the Rust code
Author
Owner

@djc commented on GitHub (Oct 18, 2025):

Aren't there existing crates that expose a Rust interface for this? Maybe you publish/maintain such a crate and we depend on it (for relevant platforms only)?

<!-- gh-comment-id:3418626577 --> @djc commented on GitHub (Oct 18, 2025): Aren't there existing crates that expose a Rust interface for this? Maybe you publish/maintain such a crate and we depend on it (for relevant platforms only)?
Author
Owner

@lemon-sh commented on GitHub (Oct 19, 2025):

I couldn't find any that would fit the usecase here. There's libresolv-sys but it doesn't even build on my Mac, nor for docs.rs, and it seems to be glibc specific.

I could definitely try maintaining a crate like that though.

<!-- gh-comment-id:3419800028 --> @lemon-sh commented on GitHub (Oct 19, 2025): I couldn't find any that would fit the usecase here. There's [libresolv-sys](https://docs.rs/crate/libresolv-sys/latest) but it doesn't even build on my Mac, nor for docs.rs, and it seems to be glibc specific. I could definitely try maintaining a crate like that though.
Author
Owner

@lemon-sh commented on GitHub (Oct 21, 2025):

I've found a better solution without using any private APIs and just submitted a PR that would close this issue ^^

<!-- gh-comment-id:3427955929 --> @lemon-sh commented on GitHub (Oct 21, 2025): I've found a better solution without using any private APIs and just submitted a PR that would close this issue ^^
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hickory-dns#1168
No description provided.