[英]okhttp3 how to set Dns
I need set a DNS in my app. 我需要在我的应用中设置DNS。
I can't figure out how to add it: 我无法弄清楚如何添加它:
//Http Client
OkHttpClient.Builder client = new OkHttpClient.Builder();
client.addInterceptor(interceptor);
client.dns("172.10.0.100");
You can set the DNS via the WIFI settings and then just do this: 您可以通过WIFI设置设置DNS,然后执行以下操作:
client.dns(Dns.SYSTEM);
now it should get the info from there. 现在应该从那里获取信息。
This is an example of setting an alternative DNS strategy or per host overrides 这是设置备用DNS策略或每个主机覆盖的示例
Dns dns = ...
builder.dns(dns);
See this post dns-android-okhttp and add dependency which I defined below, and it will work :) 看到这篇文章dns-android-okhttp并添加我在下面定义的依赖项,它会工作:)
compile 'dnsjava:dnsjava:2.1.7' 编译'dnsjava:dnsjava:2.1.7'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.