HTTPDNS for iOS: IPv6 Q&A

更新时间:
复制 MD 格式

  • Question: Does the SDK support IPv6 access? What does the IPv6 environment described in the SDK documentation refer to?

  • Answer: The SDK supports Apple's IPv6-only review environment to ensure that your app is compatible and can pass the review process. This is not a native IPv6 environment. For more information about the IPv6-only environment, see https://developer.apple.com/support/ipv6/.

  • Question: In an IPv6-only environment, do I need to make any adjustments to my application when using HTTPDNS?

  • Answer: There are two scenarios. 1. If your application uses a single-stack (IPv4) mode, no adjustments are required. In an IPv6-only environment, the SDK automatically synthesizes and returns an IPv6 address from the corresponding IPv4 address. 2. If your application uses a dual-stack (IPv4 and IPv6) mode and you want to select which IP address to use based on the current network environment, you must enable the enableIPv6 switch. The SDK will then not automatically synthesize an IPv6 address from an IPv4 address. You must determine the network environment and select the appropriate IP address.

Note: The URL format for direct IP connections is different for IPv4 and IPv6 addresses.

IPv4: http://192.168.0.1:8080/xxx

IPv6: http://[64:ff9b::192.168.0.1]:8080/xxxxx. The SDK provides the getIpByHostAsyncInURLFormat method to automatically format the URL.

For more information, see https://developer.apple.com/library/archive/documentation/NetworkingInternetWeb/Conceptual/NetworkingOverview/UnderstandingandPreparingfortheIPv6Transition/UnderstandingandPreparingfortheIPv6Transition.html.

  • Question: How can I detect an IPv6-only environment?

  • Answer: You can check the local DNS address type. If all DNS addresses are IPv6 addresses, the current environment is considered IPv6-only.

  • Question: How does the SDK synthesize an IPv6 address from an IPv4 address?

  • Answer: For iOS 9.2 and later, the SDK uses getaddrinfo to synthesize the IPv6 address. For versions earlier than iOS 9.2, it uses a locally supported prefix for the conversion. For more information, see rfc7050.

Note: According to the standard, NAT64 must support the Well-Known Prefix (64:ff9b::/96). However, Apple's documentation states that this is not always the case. Therefore, you must perform the conversion based on the actual local prefix.

References:

https://developer.apple.com/support/ipv6/

https://datatracker.ietf.org/doc/html/rfc6052

https://datatracker.ietf.org/doc/html/rfc7050

  • Question: Does the following method automatically distinguish between and return IPv4 and IPv6 addresses?

    - (NSString *)getIpByHostAsyncInURLFormat:(NSString *)host;
  • Answer: No, it does not. The getIpByHostAsyncInURLFormat method is designed for IPv6-only network environments and converts an IPv4 address to a mapped IPv6 address.

    - (NSString *)getIPv6ByHostAsync:(NSString *)host;

    The getIPv6ByHostAsync method returns the domain's native IPv6 address. This is independent of the device's network environment.



  • Question: Will it affect the app review if `enableIPv6` is not set? In other words, is setting `enableIPv6` required?

    - (void)enableIPv6:(BOOL)enable;
  • Answer: No. Your app can pass the Apple review even if this switch is not set. This switch enables the IPv6 feature. To use this feature, you must have your own IPv6 IP addresses and configure them in the console. You can use this feature as needed.


  • Question: Does the HTTPDNS SDK internally detect the system's current network configuration, such as an IPv4/IPv6 dual-stack? If the system is in an IPv4-only environment, will calling interfaces for IPv6 IP addresses still return a result? Conversely, if the system is in an IPv6-only environment, will calling interfaces for IPv4 IP addresses still return a result? Will the result be synthesized using DNS64?

  • Answer:

 - (void)enableIPv6:(BOOL)enable;
 @param enable Specifies whether to enable IPv6 result parsing. The default value is NO.
 After you enable this feature, call the getIPv6ByHostAsync: interface.

 - (NSString *)getIPv6ByHostAsync:(NSString *)host;
@param host The domain name to parse. @return The parsed IPv6 result. Returns nil if no IPv6 address exists.
 Asynchronously parses a domain name and returns an IPv6 address. After you enable IPv6 result parsing, this method returns the parsed IPv6 result if an IPv6 address exists for the domain.

Example: Domain name: ipv6.sjtu.edu.cn,
IPv4 address: 202.120.XX.XX,
IPv6 address: 2001:da8:8000:1:0:0:0:80,
After a successful parsing, the interface returns: 2001:da8:8000:1:0:0:0:80

[Note] After you enable IPv6 result parsing, the SDK no longer automatically converts IPv4 parsing results to IPv6 addresses in an IPv6-only network environment. 
             getIpsByHostAsync: returns an IPv4 address, and getIPv6ByHostAsync: returns an IPv6 address.