mirror of
https://ghfast.top/https://github.com/StarCitizenToolBox/app.git
synced 2025-07-01 01:21:58 +08:00
feat: 新增 Hosts 写入功能,通过预设的干净 DNS 获取ip 并 写入 hosts 文件
This commit is contained in:
@ -257,4 +257,10 @@ foreach ($adapter in $adapterMemory) {
|
||||
await Process.run(
|
||||
SystemHelper.powershellPath, ["explorer.exe", "/select,\"$path\""]);
|
||||
}
|
||||
|
||||
static String getHostsFilePath() {
|
||||
final envVars = Platform.environment;
|
||||
final systemRoot = envVars["SYSTEMROOT"];
|
||||
return "$systemRoot\\System32\\drivers\\etc\\hosts";
|
||||
}
|
||||
}
|
||||
|
@ -51,13 +51,20 @@ class RSHttp {
|
||||
}
|
||||
|
||||
static Future<RustHttpResponse> head(String url,
|
||||
{Map<String, String>? headers}) async {
|
||||
{Map<String, String>? headers, String? withIpAddress}) async {
|
||||
final r = await rust_http.fetch(
|
||||
method: MyMethod.head, url: url, headers: headers);
|
||||
method: MyMethod.head,
|
||||
url: url,
|
||||
headers: headers,
|
||||
withIpAddress: withIpAddress);
|
||||
return r;
|
||||
}
|
||||
|
||||
static Future<List<String>> dnsLookupTxt(String host) async {
|
||||
return await rust_http.dnsLookupTxt(host: host);
|
||||
}
|
||||
|
||||
static Future<List<String>> dnsLookupIps(String host) async {
|
||||
return await rust_http.dnsLookupIps(host: host);
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ extension AsyncError on Future {
|
||||
return await this;
|
||||
} catch (e) {
|
||||
dPrint("unwrap error:$e");
|
||||
if (context != null) {
|
||||
if (context != null && context.mounted) {
|
||||
showToast(context, "出现错误: $e");
|
||||
}
|
||||
return null;
|
||||
|
Reference in New Issue
Block a user