带阿里标识的版本

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,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',
);