Introduction
All interfaces described in this document should be used alongside writing custom resolution functions for scenarios where basic resolution is insufficient, enabling customized domain name resolution.
You can configure common parameters required for each custom domain name resolution request through setting custom resolution global parameters.
Custom synchronous resolution interface
The custom synchronous resolution interface resolves domain names by blocking the current thread until a valid result is obtained and returned.
This interface first checks the cache using cacheKey. If an active resolution result is present, it immediately returns the cached result. If not, it blocks the current thread that invokes the resolution and performs domain name resolution in a worker thread. It returns the result upon completion or an empty value if the timeout is reached.
The total time taken by the synchronous resolution interface is governed by timeout configuration. If resolution is unsuccessful within the set timeout, an empty result is immediately returned.
getHttpDnsResultForHostSync
Interface Definition
HTTPDNSResult getHttpDnsResultForHostSync(String host, RequestIpType requestIpType, Map<String, String> params, String cacheKey)
Method added in version 2.4.0.
Class
HttpDnsService
Parameter Description
Parameter | Type | Required | Description |
host | String | Yes | The domain name to be resolved. |
requestIpType | RequestIpType | Yes | The type of IP address to be resolved. It is recommended to use RequestIpType.both Enumeration type, representing the type of IP address to be resolved:
|
params | Map<String, String> | Yes | Additional parameters carried with the domain name resolution, corresponding to the event.parameters parameter in the server-side custom resolution function. |
cacheKey | String | Yes | The local cache key corresponding to the domain name. If the additional parameters change and require re-resolution on the server side, the cacheKey needs to be changed. |
Return Description
Type | Description |
HTTPDNSResult | Resolution result. |
Code Example
val httpdns = HttpDns.getService(applicationContext, accountID, secretKey)
val httpDnsResult = dnsService?.getHttpDnsResultForHostSync(host, RequestIpType.auto, params, cacheKey)
HttpDnsService httpdns = HttpDns.getService(applicationContext, accountID, secretKey);
HTTPDNSResult httpDnsResult = httpdns.getHttpDnsResultForHostSync(host, RequestIpType.auto, params, cacheKey);
Custom asynchronous resolution interface
The custom asynchronous resolution interface resolves domain names without blocking the current thread, returning the result via callback.
This interface first checks the cache. If an active resolution result is present, it immediately returns the cached result through a callback. If not, it performs domain name resolution in a worker thread and returns the result via callback upon completion or when the timeout is reached.
The total time taken by the asynchronous resolution interface is governed by timeout configuration. If resolution is unsuccessful within the set timeout, an empty result is immediately returned.
getHttpDnsResultForHostAsync
Interface Definition
void getHttpDnsResultForHostAsync(String host, RequestIpType requestIpType, Map<String, String> params, String cacheKey, HttpDnsCallback callback)
Method added in version 2.4.0.
Class
HttpDnsService
Parameter Description
Parameter | Type | Required | Description |
host | String | Yes | The domain name to be resolved. |
requestIpType | RequestIpType | Yes | The type of IP address to be resolved. It is recommended to use RequestIpType.both Enumeration type, representing the type of IP address to be resolved:
|
params | Map<String, String> | Yes | Additional parameters carried with the domain name resolution, corresponding to the event.parameters parameter in the server-side custom resolution function. |
cacheKey | String | Yes | The local cache key corresponding to the domain name. If the additional parameters change and require re-resolution on the server side, the cacheKey needs to be changed. |
callback | HttpDnsCallback | Yes | Resolution result callback class. |
Code Example
val httpdns = HttpDns.getService(applicationContext, accountID, secretKey)
dnsService?.getHttpDnsResultForHostAsync(host, RequestIpType.auto, params, cacheKey, HttpDnsCallback {
httpDnsResult = it
})
HttpDnsService httpdns = HttpDns.getService(applicationContext, accountID, secretKey);
httpdns.getHttpDnsResultForHostAsync(host, RequestIpType.auto, params, cacheKey, new HttpDnsCallback() {
void onHttpDnsCompleted(HTTPDNSResult result) {
}
});
Custom synchronous non-blocking resolution interface
The custom synchronous non-blocking interface resolves domain names without blocking the current thread but may return an empty result.
This interface only queries the cache and returns the result from the cache. If the cache has no result or the result has expired, it performs domain name resolution in a worker thread. Once successful, it updates the cache for subsequent calls.
getHttpDnsResultForHostSyncNonBlocking
Interface Definition
HTTPDNSResult getHttpDnsResultForHostSyncNonBlocking(String host, RequestIpType requestIpType, Map<String, String> params, String cacheKey)
Class
HttpDnsService
Parameter Description
Parameter | Type | Required | Description |
host | String | Yes | The domain name to be resolved. |
requestIpType | RequestIpType | Yes | The type of IP address to be resolved. It is recommended to use RequestIpType.both Enumeration type, representing the type of IP address to be resolved:
|
params | Map<String, String> | Yes | Additional parameters carried with the domain name resolution, corresponding to the event.parameters parameter in the server-side custom resolution function. |
cacheKey | String | Yes | The local cache key corresponding to the domain name. If the additional parameters change and require re-resolution on the server side, the cacheKey needs to be changed. |
Return Description
Type | Description |
HTTPDNSResult | Resolution result. |
Code Example
val httpdns = HttpDns.getService(applicationContext, accountID, secretKey)
val httpDnsResult = dnsService?.getHttpDnsResultForHostSyncNonBlocking(host, RequestIpType.auto, params, cacheKey)
HttpDnsService httpdns = HttpDns.getService(applicationContext, accountID, secretKey);
HTTPDNSResult httpDnsResult = httpdns.getHttpDnsResultForHostSyncNonBlocking(host, RequestIpType.auto, params, cacheKey);
getIpsByHostAsync
Use synchronous non-blocking mode to custom resolve IPv4 addresses.
Interface Definition
HTTPDNSResult getIpsByHostAsync(String host, Map<String,String> params, String cacheKey)
This method was deprecated in version 2.4.0 and may be removed in future versions. Please use HTTPDNSResult getHttpDnsResultForHostSyncNonBlocking(String host, RequestIpType requestIpType, Map params, String cacheKey)
Class
HttpDnsService
Parameter Description
Parameter | Type | Required | Description |
host | String | Yes | The domain name to be resolved. |
params | Map<String, String> | Yes | Additional parameters carried with the domain name resolution, corresponding to the event.parameters parameter in the server-side custom resolution function. |
cacheKey | String | Yes | The local cache key corresponding to the domain name. If the additional parameters change and require re-resolution on the server side, the cacheKey needs to be changed. |
Return Description
Type | Description |
HTTPDNSResult | Resolution result. |
getHttpDnsResultForHostAsync
Use synchronous non-blocking mode to custom resolve IPv4 addresses.
Interface Definition
HTTPDNSResult getHttpDnsResultForHostAsync(String host, Map<String, String> params, String cacheKey);
This method was deprecated in version 2.4.0 and may be removed in future versions. Please use HTTPDNSResult getHttpDnsResultForHostSyncNonBlocking(String host, RequestIpType requestIpType, Map params, String cacheKey)
Class
HttpDnsService
Parameter Description
Parameter | Type | Required | Description |
host | String | Yes | The domain name to be resolved. |
params | Map<String, String> | Yes | Additional parameters carried with the domain name resolution, corresponding to the event.parameters parameter in the server-side custom resolution function. |
cacheKey | String | Yes | The local cache key corresponding to the domain name. If the additional parameters change and require re-resolution on the server side, the cacheKey needs to be changed. |
Return Description
Type | Description |
HTTPDNSResult | Resolution result. |
getIpsByHostAsync
Use synchronous non-blocking mode to custom resolve specified IP type addresses.
Interface Description
HTTPDNSResult getIpsByHostAsync(String host, RequestIpType requestIpType, Map<String,String> params, String cacheKey)
This method was deprecated in version 2.4.0 and may be removed in future versions. Please use HTTPDNSResult getHttpDnsResultForHostSyncNonBlocking(String host, RequestIpType requestIpType, Map params, String cacheKey)
Class
HttpDnsService
Parameter Description
Parameter | Type | Required | Description |
host | String | Yes | The domain name to be resolved. |
requestIpType | RequestIpType | Yes | The type of IP address to be resolved. It is recommended to use RequestIpType.both |
params | Map<String, String> | Yes | Additional parameters carried with the domain name resolution, corresponding to the event.parameters parameter in the server-side custom resolution function. |
cacheKey | String | Yes | The local cache key corresponding to the domain name. If the additional parameters change and require re-resolution on the server side, the cacheKey needs to be changed. |
Return Description
Type | Description |
HTTPDNSResult | Resolution result. |
getHttpDnsResultForHostAsync
Interface Description
HTTPDNSResult getHttpDnsResultForHostAsync(String host, RequestIpType type, Map<String, String> params, String cacheKey)
This method was deprecated in version 2.4.0 and may be removed in future versions. Please use HTTPDNSResult getHttpDnsResultForHostSyncNonBlocking(String host, RequestIpType requestIpType, Map params, String cacheKey)
Class
HttpDnsService
Parameter Description
Parameter | Type | Required | Description |
host | String | Yes | The domain name to be resolved. |
requestIpType | RequestIpType | Yes | The type of IP address to be resolved. It is recommended to use RequestIpType.both |
params | Map<String, String> | Yes | Additional parameters carried with the domain name resolution, corresponding to the event.parameters parameter in the server-side custom resolution function. |
cacheKey | String | Yes | The local cache key corresponding to the domain name. If the additional parameters change and require re-resolution on the server side, the cacheKey needs to be changed. |
Return Description
Type | Description |
HTTPDNSResult | Resolution result. |