74 lines
1.5 KiB
Markdown
74 lines
1.5 KiB
Markdown
# HTTPDNS Flutter SDK (SNI Hidden v1.0.0)
|
|
|
|
## 1. Initialization
|
|
|
|
```dart
|
|
import 'package:new_httpdns/new_httpdns.dart';
|
|
|
|
await NewHttpdns.init(
|
|
appId: 'app1f1ndpo9',
|
|
primaryServiceHost: 'httpdns-a.example.com',
|
|
backupServiceHost: 'httpdns-b.example.com', // optional
|
|
servicePort: 443,
|
|
secretKey: 'your-sign-secret', // optional if sign is enabled
|
|
);
|
|
|
|
await NewHttpdns.setHttpsRequestEnabled(true);
|
|
await NewHttpdns.build();
|
|
```
|
|
|
|
## 2. Resolve
|
|
|
|
```dart
|
|
final result = await NewHttpdns.resolveHostSyncNonBlocking(
|
|
'api.business.com',
|
|
ipType: 'both',
|
|
);
|
|
|
|
final ipv4 = result['ipv4'] ?? <String>[];
|
|
final ipv6 = result['ipv6'] ?? <String>[];
|
|
```
|
|
|
|
## 3. Official HTTP Adapter (IP + Host)
|
|
|
|
```dart
|
|
final adapter = NewHttpdns.createHttpAdapter(
|
|
options: const NewHttpdnsAdapterOptions(
|
|
ipType: 'auto',
|
|
connectTimeoutMs: 3000,
|
|
readTimeoutMs: 5000,
|
|
allowInsecureCertificatesForDebugOnly: false,
|
|
),
|
|
);
|
|
|
|
final resp = await adapter.request(
|
|
Uri.parse('https://api.business.com/v1/ping'),
|
|
method: 'GET',
|
|
headers: {'Accept': 'application/json'},
|
|
);
|
|
|
|
print(resp.statusCode);
|
|
print(resp.usedIp);
|
|
```
|
|
|
|
Behavior is fixed:
|
|
- Resolve host by `/resolve`.
|
|
- Connect to resolved IP over HTTPS.
|
|
- Keep `Host` header as the real 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. Deprecated Params Removed
|
|
|
|
The public init API no longer accepts:
|
|
- `accountId`
|
|
- `serviceDomain`
|
|
- `endpoint`
|
|
- `aesSecretKey`
|