Android 上的域 InetAddress.getAllByName 与 chrome

发布于 2025-01-11 19:35:27 字数 820 浏览 1 评论 0 原文

我有一个类似于 myservice 的主机别名,它被解析为 myservice.mydomain.tld

我想自己做ip地址解析;我尝试在 Android 应用程序中调用 InetAddress.getAllByName("myservice") 但抛出 UnknownHostException。一般解析有效,调用 InetAddress.getAllByName("myservice.mydomain.tld") 返回预期结果。

现在,当我在同一设备上使用 chrome 并浏览 https://myservice 时,chrome 能够解析为导航到 https://myservice 后面的页面。

我尝试从 chromium/chrome 来源 搜索所需的调用,但我只找到了对 <代码> getAllByName 作为android_getaddrinfofornetwork 与记录的相同。

关于 Chrome 等应用程序如何在 Android 上进行 DNS 解析的任何其他提示?

I have a host alias like myservice that is resolved as myservice.mydomain.tld.

I would like to do the ipaddress resolution myself; I tried to call InetAddress.getAllByName("myservice") in my android app but that throws UnknownHostException. Generell resolution works, calling InetAddress.getAllByName("myservice.mydomain.tld") returns expected result.

Now, when i use chrome on the same device and browse https://myservice, chrome is able to resolve as navigation to the page behind https://myservice works.

I tried to search the required calls from chromium/chrome sources but i only found calls to getAllByName as android_getaddrinfofornetwork which is the same as documented.

Any other hints on how apps like chrome do DNS resolution on android?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沙沙粒小 2025-01-18 19:35:27

Have you tried using Network.getAllByName()? Looks like that'll do the hostname resolution for you, and then return matching InetAddresses

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文