IPv6 asynchronous resolution interface (deprecated)

Updated at:
Warning

The resolution interfaces described in this document are deprecated and will be removed in a future version. For more information, see the latest Domain Name Resolution Interface document.

Important

To ensure compatibility with IPv6-Only network environments when you use HTTPDNS, note the following:

  • When you make a network request using a URL that contains an IP address, the formats for IPv4 and IPv6 addresses are different.

    • IPv4: http://x.x.x.x/path

    • IPv6: http://[2001:db8:c000:221::]/path

    When you use an IPv6 address in a URL, you must enclose the address in brackets (`[]`).

    For developer convenience, HTTPDNS provides an interface to retrieve an IP address in the correct URL format: -[HttpDnsService getIpByHostAsyncInURLFormat:].

  • When you retrieve an IP address from HTTPDNS to use in a URL for network access, you can use the API mentioned above to obtain the IP address in the correct format, such as *x.x.x.x* or *[2001:db8:c000:221::]*.

    If you only need the raw IP address for other purposes, you can continue to use the original interface: -[HttpDnsService getIpByHostAsync:].

Enable IPv6

You can enable or disable IPv6 resolution. If this feature is enabled, the service requests to resolve IPv6 addresses.

Important
  • After you enable this feature, you can use the getIPv6ByHostAsync: interface.

  • After you enable IPv6 resolution, the software development kit (SDK) in an IPv6-Only network environment no longer automatically transforms IPv4 resolution results into IPv6 addresses. The getIpsByHostAsync: interface returns an IPv4 address, and the getIPv6ByHostAsync: interface returns an IPv6 address.

Interface definition

 - (void)enableIPv6:(BOOL)enable;

Parameter descriptions

Parameter

Type

Required

Description

enable

BOOL

Yes

Specifies whether to enable the feature. The default value is NO.

Resolve a domain name to an IPv6 address asynchronously

Note

This operation asynchronously resolves a domain name to an IPv6 address. If IPv6 resolution is enabled and the domain name has an IPv6 address, the IPv6 address is returned. For example, if the domain name `ipv6.sjtu.edu.cn` has the IPv4 address `192.168.XX.XX` and the IPv6 address `2001:da8:8000:1:0:0:XX:XX`, a successful resolution returns `2001:da8:8000:1:0:0:XX:XX`.

Important

If IPv6 resolution is not enabled, null is returned.

Interface definition

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

The interface name was optimized in version 2.1.0. If you use SDK version 2.1.0 or later, you must use the new API provided below. The old API may be removed in a future version.

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

Parameter descriptions

Parameter

Type

Required

Description

host

NSString

Yes

The destination domain name.

Asynchronously resolve a domain name to a list of IPv6 addresses

Note

This operation asynchronously resolves a domain name to IPv6 addresses. If IPv6 resolution is enabled and the domain name has IPv6 addresses, the IPv6 resolution results are returned. For example, if the domain name `ipv6.sjtu.edu.cn` has the IPv4 address `192.168.XX.XX` and the IPv6 address `2001:da8:8000:1:0:0:XX:XX`, a successful resolution returns `2001:da8:8000:1:0:0:XX:XX`.

Important

If IPv6 resolution is not enabled, null is returned.

Interface definition

- (NSArray *)getIPv6sByHostAsync:(NSString *)host
Important

The interface names were updated in version 2.1.0. If you use SDK version 2.1.0 or later, use the new API. The old API is deprecated and may be removed in a future version.

- (NSArray *)getIPv6ListForHostAsync:(NSString *)host;

Parameters

Parameter

Type

Required

Description

host

NSString

Yes

The destination domain name.

Simultaneous IPv4 and IPv6 resolution

Note

This operation simultaneously queries for IPv4 and IPv6 addresses and returns a dictionary. The keys in the dictionary correspond to the following values:

IPv4: ALICLOUDHDNS_IPV4

IPv6: ALICLOUDHDNS_IPV6

The returned dictionary is in the following format:

{

ALICLOUDHDNS_IPV4: ['xxx.xxx.xxx.xxx', 'xxx.xxx.xxx.xxx'],

ALICLOUDHDNS_IPV6: ['xx:xx:xx:xx:xx:xx:xx:xx', 'xx:xx:xx:xx:xx:xx:xx:xx']

}

Interface definition

- (NSDictionary <NSString *, NSArray *>*)getIPv4_v6ByHostAsync:(NSString *)host;
Important

The interface name was optimized in version 2.1.0. If you use SDK version 2.1.0 or later, you must use the new API provided below. The old API may be removed in a future version.

- (NSDictionary <NSString *, NSArray *>*)getHttpDnsResultHostAsync:(NSString *)host;

Parameter descriptions

Parameter

Type

Required

Description

host

NSString

Yes

The destination domain name.

Automatic resolution based on the current network stack

Note

If the current network is IPv4-Only, this operation returns only IPv4 addresses. If the network is IPv6-Only, it returns only IPv6 addresses. If the network is dual-stack, it returns both IPv4 and IPv6 addresses.

This operation simultaneously queries for IPv4 and IPv6 addresses and returns a dictionary. The keys in the dictionary correspond to the following values:

IPv4: ALICLOUDHDNS_IPV4

IPv6: ALICLOUDHDNS_IPV6

The returned dictionary is in the following format:

{

ALICLOUDHDNS_IPV4: ['xxx.xxx.xxx.xxx', 'xxx.xxx.xxx.xxx'],

ALICLOUDHDNS_IPV6: ['xx:xx:xx:xx:xx:xx:xx:xx', 'xx:xx:xx:xx:xx:xx:xx:xx']

}

Important

If IPv6 resolution is not enabled, null is returned.

Interface definition

-(NSDictionary <NSString *, NSArray *>*)autoGetIpsByHostAsync:(NSString *)host;
Important

The interface name was optimized in version 2.1.0. If you use SDK version 2.1.0 or later, you must use the new API provided below. The old API may be removed in a future version.

-(NSDictionary <NSString *, NSArray *>*)autoGetHttpDnsResultForHostAsync:(NSString *)host;

Parameter descriptions

Parameter

Type

Required

Description

host

NSString

Yes

The destination domain name.