sdk final
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:TrustAPP_httpdns/TrustAPP_httpdns.dart';
|
||||
import 'package:new_httpdns/new_httpdns.dart';
|
||||
|
||||
void main() {
|
||||
runApp(const MyApp());
|
||||
@@ -13,7 +13,6 @@ void main() {
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
|
||||
// This widget is the root of your application.
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
@@ -63,18 +62,20 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
if (_httpdnsReady || _httpdnsIniting) return;
|
||||
_httpdnsIniting = true;
|
||||
try {
|
||||
// 使用官方测试参数
|
||||
await TrustAPPHttpdns.init(
|
||||
appId: 'app1f1ndpo9', // 请替换为您的应用 AppId
|
||||
primaryServiceHost: 'httpdns-a.example.com', // 请替换为主服务域<E58AA1><E59F9F>? backupServiceHost: 'httpdns-b.example.com', // 可选:备服务域<E58AA1><E59F9F>? servicePort: 443,
|
||||
secretKey: 'your_sign_secret_here', // 可选:仅验签开启时需<E697B6><E99C80>? );
|
||||
appId: 'app1flndpo9',
|
||||
apiUrl: 'https://httpdns.deepwaf.xyz:8445',
|
||||
secretKey: 'ss_67fb8471a45b',
|
||||
);
|
||||
await TrustAPPHttpdns.setHttpsRequestEnabled(true);
|
||||
await TrustAPPHttpdns.setLogEnabled(true);
|
||||
await TrustAPPHttpdns.setPersistentCacheIPEnabled(true);
|
||||
await TrustAPPHttpdns.setReuseExpiredIPEnabled(true);
|
||||
await TrustAPPHttpdns.build();
|
||||
|
||||
// 先build再执行解析相关动<EFBFBD><EFBFBD>?
|
||||
final preResolveHosts = 'www.TrustAPP.com';
|
||||
// 先 build 再执行解析相关动作
|
||||
final preResolveHosts = 'demo.cloudxdr.com';
|
||||
await TrustAPPHttpdns.setPreResolveHosts([preResolveHosts], ipType: 'both');
|
||||
debugPrint('[httpdns] pre-resolve scheduled for host=$preResolveHosts');
|
||||
_httpdnsReady = true;
|
||||
@@ -88,13 +89,13 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// 设置默认的API URL用于演示
|
||||
_urlController.text = 'https://www.TrustAPP.com';
|
||||
// 设置默认的 API URL 用于演示
|
||||
_urlController.text = 'https://demo.cloudxdr.com';
|
||||
|
||||
// 仅首次进入页面时初始<EFBFBD><EFBFBD>?HTTPDNS
|
||||
// 仅首次进入页面时初始化 HTTPDNS
|
||||
_initHttpDnsOnce();
|
||||
|
||||
// 先初始化HTTPDNS再初始化Dio
|
||||
// 先初始化 HTTPDNS 再初始化 Dio
|
||||
_dio = Dio();
|
||||
_dio.httpClientAdapter = buildHttpdnsHttpClientAdapter();
|
||||
_dio.options.headers['Connection'] = 'keep-alive';
|
||||
@@ -124,7 +125,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
_responseText = 'Sending request...';
|
||||
});
|
||||
|
||||
final uri = Uri.parse(_urlController.text);
|
||||
final uri = Uri.parse(_urlController.text.trim());
|
||||
|
||||
try {
|
||||
final String libraryName = _selectedLibrary.displayName;
|
||||
@@ -215,7 +216,6 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
}
|
||||
}
|
||||
|
||||
// 使用 HTTPDNS 解析当前 URL <20><>?host 并显示结<E7A4BA><E7BB93>?
|
||||
Future<void> _testHttpDnsResolve() async {
|
||||
final text = _urlController.text.trim();
|
||||
if (text.isEmpty) {
|
||||
@@ -241,7 +241,6 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
});
|
||||
|
||||
try {
|
||||
// 确保只初始化一<E58C96><E4B880>?
|
||||
await _initHttpDnsOnce();
|
||||
final res = await TrustAPPHttpdns.resolveHostSyncNonBlocking(
|
||||
uri.host,
|
||||
@@ -278,12 +277,11 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
// URL输入<E8BE93><E585A5>?
|
||||
TextField(
|
||||
controller: _urlController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Enter URL',
|
||||
hintText: 'https://www.TrustAPP.com',
|
||||
hintText: 'https://demo.cloudxdr.com',
|
||||
border: OutlineInputBorder(),
|
||||
prefixIcon: Icon(Icons.link),
|
||||
),
|
||||
@@ -346,7 +344,6 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// HTTPDNS 解析按钮
|
||||
ElevatedButton.icon(
|
||||
onPressed: _isLoading ? null : _testHttpDnsResolve,
|
||||
icon: const Icon(Icons.dns),
|
||||
@@ -357,10 +354,8 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// 保留空白分隔
|
||||
const SizedBox(height: 16),
|
||||
|
||||
// 响应文本显示区域
|
||||
Expanded(
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
|
||||
Reference in New Issue
Block a user