-
Notifications
You must be signed in to change notification settings - Fork 175
Android: fix IPv6-only server connectivity #3045
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
base: master
Are you sure you want to change the base?
Conversation
062df2a to
d8224e4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
ebdf2b0 to
df85703
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 8 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Client/TeamTalkAndroid/src/main/java/dk/bearware/backend/TeamTalkService.java
Outdated
Show resolved
Hide resolved
Client/TeamTalkAndroid/src/main/java/dk/bearware/backend/TeamTalkService.java
Outdated
Show resolved
Hide resolved
Client/TeamTalkAndroid/src/main/java/dk/bearware/backend/TeamTalkService.java
Outdated
Show resolved
Hide resolved
Client/TeamTalkAndroid/src/main/java/dk/bearware/backend/TeamTalkService.java
Outdated
Show resolved
Hide resolved
Client/TeamTalkAndroid/src/main/java/dk/bearware/backend/TeamTalkService.java
Outdated
Show resolved
Hide resolved
Client/TeamTalkAndroid/src/main/java/dk/bearware/backend/TeamTalkService.java
Outdated
Show resolved
Hide resolved
- Fix native UDP socket family for IPv6 (Android) - Make address resolution robust on Android (IPv6 literals + getaddrinfo quirks) - Add Android-side DNS fallback for Private DNS resolver timeouts (udp/53) - Respect system address ordering and cache DNS results Signed-off-by: Patrick ZAJDA <patrick@zajda.fr>
df85703 to
06f219e
Compare
|
Copilot Review suggestions applied, except hostname and port are two different fields and a TeamTalk server can be on a local network. |
|
Is there a way to avoid changing files in TeamTalk DLL? It appears strange that it works on all other platform than Android. Is it possible to make the DNS lookup in TeamTalkAndroid and always pass an IP-address (instead of a hostname) to TT_Connect()? |
|
I tried an Android-only approach (no changes in TeamTalk DLL / TeamTalkLib): resolve hostnames in DNS: Candidates for ipv6.hostname.tld -> [2001:xxxx:yyyy:zzzz::]
connect() to 2001:xxxx:yyyy:zzzz:: ... -> falseAnd even when entering the IPv6 literal directly: connect(): host=2001:xxxx:yyyy:zzzz:: candidates=[2001:xxxx:yyyy:zzzz::]
connect() ... -> falseSo this is not just a hostname/DNS issue. The Android native layer (JNI / underlying socket/connect path) appears to fail for IPv6, meaning an Android-only DNS workaround cannot fix #1987 on its own. I pushed a branch called Proposed compromise: |
Library/TeamTalkLib/myace/MyINet.cpp
Outdated
| const auto host_utf8_full = UnicodeToUtf8(host); | ||
| const char* host_utf8_cstr = host_utf8_full.c_str(); | ||
| std::string host_utf8(host_utf8_cstr != nullptr ? host_utf8_cstr : ""); | ||
| if (!host_utf8.empty() && host_utf8.front() == '[' && host_utf8.back() == ']') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Putting IPv6-address in brackets seems to be a Java-thing. The stripping should be done in Java, so host is just an IP-address. Should I look into fixing this or can you?
Library/TeamTalkLib/myace/MyINet.cpp
Outdated
| if (curr->ai_family == AF_INET6) | ||
| { | ||
| addr.in6_.sin6_port = encode ? ACE_NTOHS(port) : port; | ||
| addr.in6_.sin6_port = encode ? ACE_HTONS(port) : port; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
encode is always true, so it can be deleted.
Library/TeamTalkLib/myace/MyINet.cpp
Outdated
| { | ||
| errno = ADDRINFOERROR; | ||
| #if defined(ANDROID) | ||
| __android_log_print(ANDROID_LOG_WARN, "bearware-native", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use MYTRACE instead. It goes to Android log.
Library/TeamTalkLib/myace/MyINet.cpp
Outdated
| const int ADDRINFOERROR = ACE_OS::getaddrinfo(UnicodeToUtf8(host).c_str(), nullptr, &hints, &res); | ||
| // Android's resolver may return EAI_AGAIN transiently even when DNS works | ||
| // (e.g. during network transitions). Retry a few times before giving up. | ||
| int ADDRINFOERROR = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uppercase is for constants. ADDRINFOERROR is not a constant.
| import java.io.FileWriter; | ||
| import java.io.IOException; | ||
| import java.io.StringReader; | ||
| import java.net.DatagramPacket; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move the DNS code to a separate class in utils. It is unrelated to TeamTalkService.
Signed-off-by: Patrick ZAJDA <patrick@zajda.fr>
Fixes #1987
Context
The Android client could not connect to an IPv6-only TeamTalk server. On some Android devices/networks, name resolution via
getaddrinfo()can also fail transiently (EAI_AGAIN), making connections unreliable even when IPv6 connectivity is available.What this changes
EAI_AGAIN, avoid problematicgetaddrinfo()flags/constraints, and handle numeric IPv4/IPv6 literals without relying on the platform resolver.DnsResolver(system ordering) and only fall back to UDP/53 DNS as a last resort (resolver timeouts/failures), with caching and logs limited to the fallback path.Compatibility / Risk
Testing