带阿里标识的版本
This commit is contained in:
@@ -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),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user