1.5 KiB
1.5 KiB
HTTPDNS Flutter SDK (SNI Hidden v1.0.0)
1. Initialization
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
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)
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
Hostheader as the real business domain. - No fallback to domain direct request.
4. Public Errors
NO_IP_AVAILABLETLS_EMPTY_SNI_FAILEDHOST_ROUTE_REJECTEDRESOLVE_SIGN_INVALID
5. Deprecated Params Removed
The public init API no longer accepts:
accountIdserviceDomainendpointaesSecretKey