Client integration overview

更新时间:
复制 MD 格式

Learn how to integrate HTTPDNS into your client application to replace traditional DNS resolution.

Introduction

HTTPDNS is a client-side DNS solution that replaces traditional local DNS to prevent domain hijacking, resolution latency, high failure rates, and inaccurate scheduling. Integration involves these steps:

  1. Activate the service

  2. Add domain names to the resolution list

  3. Obtain development configurations

  4. Obtain the resolved IP address

  5. Apply the resolution result to the network library

  6. Verify successful integration

Note

If you use custom parsing for service scheduling, configure a custom parsing policy. Custom parsing.

Complete the first three console steps before proceeding. Product workflow. This topic covers the client integration process (the last three steps), starting with how DNS resolvers work.

DNS resolvers

A DNS resolver receives domain queries and returns IP addresses. When an app client sends a network request, its network library (NSURLSession, OkHttp, or libcurl) uses a DNS resolver to resolve the domain to an IP address before connecting. Two types exist:

  • System DNS resolver: An OS-provided component invoked through standard APIs such as POSIX getaddrinfo(), Windows DnsQuery(), or Apple Network.framework. It queries based on local configuration (hosts file, DNS cache, network settings) and forwards requests to recursive DNS servers — typically ISP-assigned via DHCP or user-configured servers like 8.8.8.8.

  • Custom DNS resolver: Application or third-party logic that bypasses the system resolver to access a service like HTTPDNS directly for authoritative IP addresses. Common methods include overriding the network library's DNS interface (OkHttp's Dns interface or libcurl's resolve mechanism) or intercepting traffic through a proxy for DNS hooking.

Integrating with HTTPDNS means implementing a custom DNS resolver backed by the HTTPDNS service. The following diagram shows how a client uses a custom DNS resolver or DNS-over-HTTPS (DoH) to apply HTTPDNS resolution results, ensuring requests use the optimal IP address.

image

Integration process

After activating the service and adding domain names in the console, implement a custom DNS resolver with HTTPDNS in three steps:

  • Obtain the resolved IP address: Access the HTTPDNS server to obtain the IP address for a domain name.

  • Apply the resolution result: Inject the obtained IP address into the network request.

  • Verify successful integration: Use logs or packet captures to confirm that the previous two steps were successful.

Get the resolved IP address

Obtain resolution results from HTTPDNS through an SDK, the HTTP API, or DoH.

An SDK is recommended for most scenarios.

Apply the resolution result

Apply the resolved IP address during your network requests. If your library supports DNS hooks or domain mapping, inject the result directly. Otherwise, use direct IP connection, protocol replacement, or a local proxy. Adaptation solutions for common libraries and frameworks:

Note

For other libraries or frameworks (Socket.io, HttpClient, Glide, SwiftNIO, Libcurl), contact Technical support.

Verify successful integration

Verify integration success using one of these methods:

  1. Log verification (Recommended)

    • Method: Log the resolved IP addresses from HTTPDNS and verify that business requests use them correctly.

    • Simple, lightweight, and suitable for most scenarios.

  • Hijacking simulation:

    • Method: Set the device's Wi-Fi DNS server to an invalid address and verify that business requests still succeed through HTTPDNS.

    • Blocks system DNS interference for more accurate verification.


Summary

HTTPDNS integration builds a custom DNS resolver in three steps: obtain a resolved IP, apply it to the network library, and verify the result. Choose the guide for your integration method: