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

dnsc: Fallback to getaddrinfo without any DNS servers #1195

Merged
merged 1 commit into from
Oct 11, 2024

Conversation

weili-jiang
Copy link
Contributor

On current Android and iOS platforms, access to the system DNS server lists is restricted (e.g. https://developer.android.com/about/versions/oreo/android-8.0-changes.html#o-pri). Even when it is available, it is often broken in certain situations (e.g. https://forums.developer.apple.com/forums/thread/75449). It is therefore practically impossible to perform manual DNS queries as re typically does for SIP.

Currently, re partially supports these platforms by offering the option to use getaddrinfo, but even this fails when no DNS servers are known due to /etc/resolv.conf not being accessible. Note that manually specifying 'well-known' DNS servers like 8.8.8.8 is not an acceptable workaround for private networks. Nor is it acceptable to manually specify a fixed private DNS, IT admins will require DNS to be centrally distributed via DHCP.

This change fixes the above use case by making two changes:

  1. Allow SIP A / AAAA queries to proceed without any DNS servers when getaddrinfo is configured. getaddrinfo doesn't need to know the servers so we don't need to reject it with EINVAL.
  2. When getaddrinfo is configured and there are no DNS servers, if SIP transport is set but not the port (e.g. sip:my-proxy.com;transport=tls, use the default transport port and do a A / AAAA query instead of attempting a SRV / NAPTR that cannot possibly work.

I have tested this on Android where dns_srv_get always fails to return any servers. Previously Baresip would fail to even register, with this change it is able to register and make calls using a URI such as sip:my-proxy.com;transport=tls.

src/dns/client.c Outdated Show resolved Hide resolved
src/sip/request.c Outdated Show resolved Hide resolved
@sreimers sreimers changed the title dns: Fallback to A/AAAA lookup when getaddrinfo is used without any DNS servers dnsc: Fallback to getaddrinfo without any DNS servers Oct 11, 2024
@sreimers sreimers merged commit 0032e8e into baresip:main Oct 11, 2024
36 checks passed
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.

3 participants