2.0 KiB
2.0 KiB
HTTPDNS iOS SDK (Edge Service v1.0.0)
1. Init
Import the umbrella header and initialize the HttpdnsEdgeService.
#import <NewHttpDNS/NewHttpDNS.h>
HttpdnsEdgeService *service = [[HttpdnsEdgeService alloc]
initWithAppId:@"app1flndpo9"
apiUrl:@"https://httpdns.deepwaf.xyz:8445"
signSecret:@"your-sign-secret"];
2. Resolve
Support for A and AAAA query types.
[service resolveHost:@"demo.cloudxdr.com" queryType:@"A" completion:^(HttpdnsEdgeResolveResult * _Nullable result, NSError * _Nullable error) {
if (error != nil) {
NSLog(@"Resolve error: %@", error.localizedDescription);
return;
}
NSLog(@"requestId=%@ ipv4=%@ ipv6=%@ ttl=%ld", result.requestId, result.ipv4s, result.ipv6s, (long)result.ttl);
}];
Note
If you need to resolve both IPv4 and IPv6 simultaneously (Dual Stack), please perform two separate requests or implement concurrent logic, as the Edge backend strictly validates
qtypeas eitherAorAAAA.
3. Business Request (SNI Support)
Use the built-in request adapter to connect to resolved IPs via HTTPS while preserving the Host header for SNI validation.
NSURL *url = [NSURL URLWithString:@"https://demo.cloudxdr.com/v1/ping"];
[service requestURL:url method:@"GET" headers:@{@"Accept": @"application/json"} body:nil completion:^(NSData * _Nullable data, NSHTTPURLResponse * _Nullable response, NSError * _Nullable error) {
if (error != nil) {
return;
}
NSLog(@"status=%ld", (long)response.statusCode);
}];
4. Key Improvements
- Security Policy: Automatically handles certificate validation for IP-based HTTPS requests (no SNI mismatch).
- Modern API: Asynchronous block-based API for efficient network operations.
- Clean Configuration: Uses HMAC-SHA256 signing for secure resolution requests.
5. Deprecated Parameters
Do NOT use legacy parameters from HttpDnsService:
accountIdsecretKeyaesSecretKeyserviceDomain(usednparameter orhostin API)