sdk final

This commit is contained in:
robin
2026-03-05 16:53:59 +08:00
parent a10f3f3740
commit 491ade1bc3
44 changed files with 1595 additions and 960 deletions

View File

@@ -1,33 +1,41 @@
# HTTPDNS iOS SDK (SNI Hidden v1.0.0)
# HTTPDNS iOS SDK (Edge Service v1.0.0)
## 1. Init
Import the umbrella header and initialize the `HttpdnsEdgeService`.
```objc
#import <TrustHTTPDNS/TrustHTTPDNS.h>
#import <NewHttpDNS/NewHttpDNS.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
initWithAppId:@"app1flndpo9"
apiUrl:@"https://httpdns.deepwaf.xyz:8445"
signSecret:@"your-sign-secret"];
```
## 2. Resolve
Support for `A` and `AAAA` query types.
```objc
[service resolveHost:@"api.business.com" queryType:@"A" completion:^(HttpdnsEdgeResolveResult * _Nullable result, NSError * _Nullable error) {
[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);
}];
```
## 3. Official Request Adapter (IP + Host)
> [!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 `qtype` as either `A` or `AAAA`.
## 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.
```objc
NSURL *url = [NSURL URLWithString:@"https://api.business.com/v1/ping"];
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;
@@ -36,23 +44,15 @@ NSURL *url = [NSURL URLWithString:@"https://api.business.com/v1/ping"];
}];
```
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. 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.
## 4. Public Errors
## 5. Deprecated Parameters
- `NO_IP_AVAILABLE`
- `TLS_EMPTY_SNI_FAILED`
- `HOST_ROUTE_REJECTED`
- `RESOLVE_SIGN_INVALID`
## 5. Removed Public Params
Do not expose legacy public parameters:
Do NOT use legacy parameters from `HttpDnsService`:
- `accountId`
- `serviceDomain`
- `endpoint`
- `secretKey`
- `aesSecretKey`
- `serviceDomain` (use `dn` parameter or `host` in API)