带阿里标识的版本
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import 'dart:async';
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
class AliyunHttpdns {
|
||||
static const MethodChannel _channel = MethodChannel('aliyun_httpdns');
|
||||
class TrustAPPHttpdns {
|
||||
static const MethodChannel _channel = MethodChannel('TrustAPP_httpdns');
|
||||
|
||||
/// New API only:
|
||||
/// appId + primary/backup service host + optional sign secret.
|
||||
@@ -156,20 +156,20 @@ class AliyunHttpdns {
|
||||
await _channel.invokeMethod<void>('cleanAllHostCache');
|
||||
}
|
||||
|
||||
static AliyunHttpdnsHttpAdapter createHttpAdapter({
|
||||
AliyunHttpdnsAdapterOptions options = const AliyunHttpdnsAdapterOptions(),
|
||||
static TrustAPPHttpdnsHttpAdapter createHttpAdapter({
|
||||
TrustAPPHttpdnsAdapterOptions options = const TrustAPPHttpdnsAdapterOptions(),
|
||||
}) {
|
||||
return AliyunHttpdnsHttpAdapter._(options);
|
||||
return TrustAPPHttpdnsHttpAdapter._(options);
|
||||
}
|
||||
}
|
||||
|
||||
class AliyunHttpdnsAdapterOptions {
|
||||
class TrustAPPHttpdnsAdapterOptions {
|
||||
final String ipType;
|
||||
final int connectTimeoutMs;
|
||||
final int readTimeoutMs;
|
||||
final bool allowInsecureCertificatesForDebugOnly;
|
||||
|
||||
const AliyunHttpdnsAdapterOptions({
|
||||
const TrustAPPHttpdnsAdapterOptions({
|
||||
this.ipType = 'auto',
|
||||
this.connectTimeoutMs = 3000,
|
||||
this.readTimeoutMs = 5000,
|
||||
@@ -177,13 +177,13 @@ class AliyunHttpdnsAdapterOptions {
|
||||
});
|
||||
}
|
||||
|
||||
class AliyunHttpdnsRequestResult {
|
||||
class TrustAPPHttpdnsRequestResult {
|
||||
final int statusCode;
|
||||
final Map<String, List<String>> headers;
|
||||
final Uint8List body;
|
||||
final String usedIp;
|
||||
|
||||
const AliyunHttpdnsRequestResult({
|
||||
const TrustAPPHttpdnsRequestResult({
|
||||
required this.statusCode,
|
||||
required this.headers,
|
||||
required this.body,
|
||||
@@ -191,17 +191,17 @@ class AliyunHttpdnsRequestResult {
|
||||
});
|
||||
}
|
||||
|
||||
class AliyunHttpdnsHttpAdapter {
|
||||
final AliyunHttpdnsAdapterOptions _options;
|
||||
class TrustAPPHttpdnsHttpAdapter {
|
||||
final TrustAPPHttpdnsAdapterOptions _options;
|
||||
|
||||
AliyunHttpdnsHttpAdapter._(this._options);
|
||||
TrustAPPHttpdnsHttpAdapter._(this._options);
|
||||
|
||||
/// Fixed behavior:
|
||||
/// 1) resolve host by HTTPDNS
|
||||
/// 2) connect to IP:443
|
||||
/// 3) keep HTTP Host as original domain
|
||||
/// 4) no fallback to domain connect
|
||||
Future<AliyunHttpdnsRequestResult> request(
|
||||
Future<TrustAPPHttpdnsRequestResult> request(
|
||||
Uri uri, {
|
||||
String method = 'GET',
|
||||
Map<String, String>? headers,
|
||||
@@ -214,7 +214,7 @@ class AliyunHttpdnsHttpAdapter {
|
||||
throw const HttpException('TLS_EMPTY_SNI_FAILED: only https is supported');
|
||||
}
|
||||
|
||||
final Map<String, List<String>> resolved = await AliyunHttpdns.resolveHostSyncNonBlocking(
|
||||
final Map<String, List<String>> resolved = await TrustAPPHttpdns.resolveHostSyncNonBlocking(
|
||||
uri.host,
|
||||
ipType: _options.ipType,
|
||||
);
|
||||
@@ -264,7 +264,7 @@ class AliyunHttpdnsHttpAdapter {
|
||||
resp.headers.forEach((String name, List<String> values) {
|
||||
responseHeaders[name] = values;
|
||||
});
|
||||
return AliyunHttpdnsRequestResult(
|
||||
return TrustAPPHttpdnsRequestResult(
|
||||
statusCode: resp.statusCode,
|
||||
headers: responseHeaders,
|
||||
body: Uint8List.fromList(payload),
|
||||
|
||||
Reference in New Issue
Block a user