I would like to create a custom DNS to utilise CloudFlare 1.1.1.1 and 1.0.0.1 for all my RetroFit connections. This should replace the SYSTEM DNS.
So I did this:
import okhttp3.Dns
import java.net.InetAddress
class CustomDns : Dns {
override fun lookup(hostname: String): List<InetAddress> {
TODO("Not yet implemented")
}
}
I'm a bit lost as in how to implement the abstract lookup function.
The documentation says:
Returns the IP addresses of hostname, in the order they will be attempted by OkHttp. If a connection to an address fails, OkHttp will retry the connection with the next address until either a connection is made, the set of IP addresses is exhausted, or a limit is exceeded.abstract fun lookup(hostname:String):List
Does it mean I create a HashMap. The key will be the domain of my API, and value will contain a list of the IP addresses that my API resolves to? Doesn't seem quite right to me.
Is there a way to use just 1.1.1.1 as DNS resolver within this implementation?