Is there a way for iOS NSURLSession to control dns resolution by itself, similar to the ability of the libcurl library (https://curl.se/libcurl/c/CURLOPT_RESOLVE.html). Because I found that my app's domain name was hijacked in the public network.
Control DNS with NSURLSession
I want to directly set the mapping relationship between the domain name and ip in my app. Is there a corresponding function?
I want to directly set the mapping relationship between the domain name and ip in my app.
Not in NSURLSession
.
Even if there were, this is likely to cause problems in the various odd environments that Apple devices find themselves in, for example, on an IPv6-only network. We strongly recommend that folks use APIs that connect by name, not using a specific IP address.
Because I found that my app's domain name was hijacked in the public network.
It seems that fixing that is a better path forward here. What exactly do you mean by “hijacked”?
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
Is there the interface?
Not in NSURLSession
.
IMO the best way to fix this is to fix your DNS. Connecting by IP address is not recommended on our platforms, and our high-level APIs do not offer the flexibility to do things that we don’t recommend.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
Is there any recommended way to fix my DNS?
That depends on what’s broken with your DNS. Earlier you wrote:
The IP resolved from the domain name is not the real IP.
That sounds like you need to update the A
records in your DNS. Most folks use a third-party DNS provider that allows the domain owner to update DNS records via their web site.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"