带阿里标识的版本

This commit is contained in:
robin
2026-02-28 18:55:33 +08:00
parent 150799f41d
commit 5d0b7c7e91
477 changed files with 10813 additions and 4044 deletions

View File

@@ -1,11 +1,11 @@
## 1.0.2
* 升级 iOS HTTPDNS SDK 3.4.0 版本
* 升级 iOS HTTPDNS SDK <EFBFBD><EFBFBD>?3.4.0 版本
## 1.0.1
* 新增 IP 优选功
* 新增 IP 优选功<EFBFBD><EFBFBD>?
* 现有接口功能优化
* 升级 Android HTTPDNS SDK 2.6.7 版本
* 升级 iOS HTTPDNS SDK 3.3.0 版本
* 升级 Android HTTPDNS SDK <EFBFBD><EFBFBD>?2.6.7 版本
* 升级 iOS HTTPDNS SDK <EFBFBD><EFBFBD>?3.3.0 版本
## 1.0.0
* 重构插件,更新接入方式和各个接口

View File

@@ -1,4 +1,4 @@
# HTTPDNS Flutter SDK (SNI Hidden v1.0.0)
# HTTPDNS Flutter SDK (SNI Hidden v1.0.0)
## 1. Initialization

View File

@@ -1,20 +1,20 @@
package com.aliyun.ams.httpdns
package com.TrustAPP.ams.httpdns
import android.content.Context
import android.util.Log
import androidx.annotation.NonNull
import com.alibaba.sdk.android.httpdns.HttpDns
import com.alibaba.sdk.android.httpdns.HttpDnsService
import com.alibaba.sdk.android.httpdns.InitConfig
import com.alibaba.sdk.android.httpdns.RequestIpType
import com.alibaba.sdk.android.httpdns.log.HttpDnsLog
import com.Trust.sdk.android.httpdns.HttpDns
import com.Trust.sdk.android.httpdns.HttpDnsService
import com.Trust.sdk.android.httpdns.InitConfig
import com.Trust.sdk.android.httpdns.RequestIpType
import com.Trust.sdk.android.httpdns.log.HttpDnsLog
import io.flutter.embedding.engine.plugins.FlutterPlugin
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel
import io.flutter.plugin.common.MethodChannel.MethodCallHandler
import io.flutter.plugin.common.MethodChannel.Result
class AliyunHttpDnsPlugin : FlutterPlugin, MethodCallHandler {
class TrustAPPHttpDnsPlugin : FlutterPlugin, MethodCallHandler {
private lateinit var channel: MethodChannel
private var appContext: Context? = null
@@ -36,7 +36,7 @@ class AliyunHttpDnsPlugin : FlutterPlugin, MethodCallHandler {
override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
appContext = flutterPluginBinding.applicationContext
channel = MethodChannel(flutterPluginBinding.binaryMessenger, "aliyun_httpdns")
channel = MethodChannel(flutterPluginBinding.binaryMessenger, "TrustAPP_httpdns")
channel.setMethodCallHandler(this)
}
@@ -58,14 +58,14 @@ class AliyunHttpDnsPlugin : FlutterPlugin, MethodCallHandler {
else -> ""
}
if (parsedAppId.isBlank()) {
Log.i("AliyunHttpDns", "initialize missing appId")
Log.i("TrustAPPHttpDns", "initialize missing appId")
result.success(false)
return
}
val primaryHostArg = (args["primaryServiceHost"] as? String)?.trim()
if (primaryHostArg.isNullOrBlank()) {
Log.i("AliyunHttpDns", "initialize missing primaryServiceHost")
Log.i("TrustAPPHttpDns", "initialize missing primaryServiceHost")
result.success(false)
return
}
@@ -86,7 +86,7 @@ class AliyunHttpDnsPlugin : FlutterPlugin, MethodCallHandler {
servicePort = if (port != null && port > 0) port else null
Log.i(
"AliyunHttpDns",
"TrustAPPHttpDns",
"initialize appId=$appId, primaryServiceHost=$primaryServiceHost, backupServiceHost=$backupServiceHost, servicePort=$servicePort"
)
result.success(true)
@@ -194,7 +194,7 @@ class AliyunHttpDnsPlugin : FlutterPlugin, MethodCallHandler {
.invoke(builder, primaryServiceHost)
hostConfigApplied = true
} catch (t: Throwable) {
Log.w("AliyunHttpDns", "setPrimaryServiceHost failed: ${t.message}")
Log.w("TrustAPPHttpDns", "setPrimaryServiceHost failed: ${t.message}")
}
try {
backupServiceHost?.let {
@@ -250,7 +250,7 @@ class AliyunHttpDnsPlugin : FlutterPlugin, MethodCallHandler {
try {
desiredIPRankingMap?.let { map ->
if (map.isNotEmpty()) {
val beanClass = Class.forName("com.alibaba.sdk.android.httpdns.ranking.IPRankingBean")
val beanClass = Class.forName("com.Trust.sdk.android.httpdns.ranking.IPRankingBean")
val ctor = beanClass.getConstructor(String::class.java, Int::class.javaPrimitiveType)
val list = ArrayList<Any>()
map.forEach { (host, port) ->
@@ -264,7 +264,7 @@ class AliyunHttpDnsPlugin : FlutterPlugin, MethodCallHandler {
}
if (!hostConfigApplied) {
Log.w("AliyunHttpDns", "build failed: sdk core does not support primaryServiceHost")
Log.w("TrustAPPHttpDns", "build failed: sdk core does not support primaryServiceHost")
result.success(false)
return
}
@@ -279,7 +279,7 @@ class AliyunHttpDnsPlugin : FlutterPlugin, MethodCallHandler {
result.success(true)
} catch (t: Throwable) {
Log.w("AliyunHttpDns", "build failed: ${t.message}")
Log.w("TrustAPPHttpDns", "build failed: ${t.message}")
result.success(false)
}
}

View File

@@ -1,6 +1,6 @@
# aliyun_httpdns_example
# TrustAPP_httpdns_example
Demonstrates how to use the aliyun_httpdns plugin with various network libraries.
Demonstrates how to use the TrustAPP_httpdns plugin with various network libraries.
## Features
@@ -18,7 +18,7 @@ This example demonstrates:
1. Replace the SDK init parameters in `lib/main.dart` with your own values:
```dart
await AliyunHttpdns.init(
await TrustAPPHttpdns.init(
appId: 'YOUR_APP_ID',
primaryServiceHost: 'httpdns-a.example.com',
backupServiceHost: 'httpdns-b.example.com',

View File

@@ -2,4 +2,4 @@
You can customize the launch screen with your own desired assets by replacing the image files in this directory.
You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images.
You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images.

View File

@@ -4,7 +4,7 @@ import 'dart:convert';
import 'dart:io';
import 'package:http/http.dart' as http;
import 'net/httpdns_http_client_adapter.dart';
import 'package:aliyun_httpdns/aliyun_httpdns.dart';
import 'package:TrustAPP_httpdns/TrustAPP_httpdns.dart';
void main() {
runApp(const MyApp());
@@ -63,22 +63,19 @@ class _MyHomePageState extends State<MyHomePage> {
if (_httpdnsReady || _httpdnsIniting) return;
_httpdnsIniting = true;
try {
await AliyunHttpdns.init(
await TrustAPPHttpdns.init(
appId: 'app1f1ndpo9', // 请替换为您的应用 AppId
primaryServiceHost: 'httpdns-a.example.com', // 请替换为主服务域
backupServiceHost: 'httpdns-b.example.com', // 可选:备服务域名
servicePort: 443,
secretKey: 'your_sign_secret_here', // 可选:仅验签开启时需要
);
await AliyunHttpdns.setHttpsRequestEnabled(true);
await AliyunHttpdns.setLogEnabled(true);
await AliyunHttpdns.setPersistentCacheIPEnabled(true);
await AliyunHttpdns.setReuseExpiredIPEnabled(true);
await AliyunHttpdns.build();
primaryServiceHost: 'httpdns-a.example.com', // 请替换为主服务域<EFBFBD><EFBFBD>? backupServiceHost: 'httpdns-b.example.com', // 可选备服务域<E58AA1><E59F9F>? servicePort: 443,
secretKey: 'your_sign_secret_here', // 可选仅验签开启时需<E697B6><E99C80>? );
await TrustAPPHttpdns.setHttpsRequestEnabled(true);
await TrustAPPHttpdns.setLogEnabled(true);
await TrustAPPHttpdns.setPersistentCacheIPEnabled(true);
await TrustAPPHttpdns.setReuseExpiredIPEnabled(true);
await TrustAPPHttpdns.build();
// 先build再执行解析相关动
final preResolveHosts = 'www.aliyun.com';
await AliyunHttpdns.setPreResolveHosts([preResolveHosts], ipType: 'both');
// 先build再执行解析相关动<EFBFBD><EFBFBD>?
final preResolveHosts = 'www.TrustAPP.com';
await TrustAPPHttpdns.setPreResolveHosts([preResolveHosts], ipType: 'both');
debugPrint('[httpdns] pre-resolve scheduled for host=$preResolveHosts');
_httpdnsReady = true;
} catch (e) {
@@ -92,9 +89,9 @@ class _MyHomePageState extends State<MyHomePage> {
void initState() {
super.initState();
// 设置默认的API URL用于演示
_urlController.text = 'https://www.aliyun.com';
_urlController.text = 'https://www.TrustAPP.com';
// 仅首次进入页面时初始HTTPDNS
// 仅首次进入页面时初始<EFBFBD><EFBFBD>?HTTPDNS
_initHttpDnsOnce();
// 先初始化HTTPDNS再初始化Dio
@@ -218,7 +215,7 @@ class _MyHomePageState extends State<MyHomePage> {
}
}
// 使用 HTTPDNS 解析当前 URL host 并显示结
// 使用 HTTPDNS 解析当前 URL <EFBFBD><EFBFBD>?host 并显示结<EFBFBD><EFBFBD>?
Future<void> _testHttpDnsResolve() async {
final text = _urlController.text.trim();
if (text.isEmpty) {
@@ -244,9 +241,9 @@ class _MyHomePageState extends State<MyHomePage> {
});
try {
// 确保只初始化一
// 确保只初始化一<EFBFBD><EFBFBD>?
await _initHttpDnsOnce();
final res = await AliyunHttpdns.resolveHostSyncNonBlocking(
final res = await TrustAPPHttpdns.resolveHostSyncNonBlocking(
uri.host,
ipType: 'both',
);
@@ -281,12 +278,12 @@ class _MyHomePageState extends State<MyHomePage> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// URL输入
// URL输入<EFBFBD><EFBFBD>?
TextField(
controller: _urlController,
decoration: const InputDecoration(
labelText: 'Enter URL',
hintText: 'https://www.aliyun.com',
hintText: 'https://www.TrustAPP.com',
border: OutlineInputBorder(),
prefixIcon: Icon(Icons.link),
),

View File

@@ -4,12 +4,12 @@ import 'package:dio/io.dart';
import 'package:flutter/foundation.dart';
import 'package:http/http.dart' as http;
import 'package:http/io_client.dart';
import 'package:aliyun_httpdns/aliyun_httpdns.dart';
import 'package:TrustAPP_httpdns/TrustAPP_httpdns.dart';
/* *
* 构建HTTPDNS 能力IOHttpClientAdapter
* 构建<EFBFBD><EFBFBD>?HTTPDNS 能力<EFBFBD><EFBFBD>?IOHttpClientAdapter
*
* 本方案由EMAS团队设计实现参考请注明出处
* 本方案由EMAS团队设计实现参考请注明出处<EFBFBD><EFBFBD>?
*/
IOHttpClientAdapter buildHttpdnsHttpClientAdapter() {
@@ -43,7 +43,7 @@ void _configureHttpClient(HttpClient client) {
client.maxConnectionsPerHost = 8;
}
// 配置基于 HTTPDNS 的连接工
// 配置基于 HTTPDNS 的连接工<EFBFBD><EFBFBD>?
void _configureConnectionFactory(HttpClient client) {
client
.connectionFactory = (Uri uri, String? proxyHost, int? proxyPort) async {
@@ -86,10 +86,10 @@ void _configureConnectionFactory(HttpClient client) {
};
}
// 通过 HTTPDNS 解析目标 IP 列表IPv4 优先;失败则返回空列表(上层回退系统 DNS
// 通过 HTTPDNS 解析目标 IP 列表IPv4 优先;失败则返回空列表(上层回退系统 DNS<EFBFBD><EFBFBD>?
Future<List<InternetAddress>> _resolveTargets(String domain) async {
try {
final res = await AliyunHttpdns.resolveHostSyncNonBlocking(
final res = await TrustAPPHttpdns.resolveHostSyncNonBlocking(
domain,
ipType: 'both',
);

View File

@@ -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),

View File

@@ -54,7 +54,7 @@ flutter:
# To add custom fonts to your plugin package, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# "list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler