Files
waf-platform/EdgeHttpDNS/sdk/ios/README.md
2026-02-27 10:35:22 +08:00

59 lines
1.5 KiB
Markdown

# HTTPDNS iOS SDK (SNI Hidden v1.0.0)
## 1. Init
```objc
#import <AlicloudHTTPDNS/AlicloudHTTPDNS.h>
HttpdnsEdgeService *service = [[HttpdnsEdgeService alloc]
initWithAppId:@"app1f1ndpo9"
primaryServiceHost:@"httpdns-a.example.com"
backupServiceHost:@"httpdns-b.example.com"
servicePort:443
signSecret:@"your-sign-secret"]; // optional if sign is enabled
```
## 2. Resolve
```objc
[service resolveHost:@"api.business.com" queryType:@"A" completion:^(HttpdnsEdgeResolveResult * _Nullable result, NSError * _Nullable error) {
if (error != nil) {
return;
}
NSLog(@"requestId=%@ ipv4=%@ ipv6=%@ ttl=%ld", result.requestId, result.ipv4s, result.ipv6s, (long)result.ttl);
}];
```
## 3. Official Request Adapter (IP + Host)
```objc
NSURL *url = [NSURL URLWithString:@"https://api.business.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);
}];
```
Behavior is fixed:
- Resolve by `/resolve`.
- Connect to resolved IP over HTTPS.
- Keep `Host` header as business domain.
- No fallback to domain direct request.
## 4. Public Errors
- `NO_IP_AVAILABLE`
- `TLS_EMPTY_SNI_FAILED`
- `HOST_ROUTE_REJECTED`
- `RESOLVE_SIGN_INVALID`
## 5. Removed Public Params
Do not expose legacy public parameters:
- `accountId`
- `serviceDomain`
- `endpoint`
- `aesSecretKey`