feat(net): 新增 DoH 解析服务器地址功能 (#1863)
This commit is contained in:
30
PCL.Test/Network/DohConnection.cs
Normal file
30
PCL.Test/Network/DohConnection.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using PCL.Core.Net;
|
||||
|
||||
namespace PCL.Test.Network;
|
||||
|
||||
[TestClass]
|
||||
public class DohConnection
|
||||
{
|
||||
[TestMethod]
|
||||
public async Task TestDohConnection()
|
||||
{
|
||||
using var client = new HttpClient(new SocketsHttpHandler()
|
||||
{
|
||||
ConnectCallback = HostConnectionHandler.Instance.GetConnectionAsync
|
||||
}
|
||||
);
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, "https://www.cloudflare.com/cdn-cgi/trace");
|
||||
request.Version = HttpVersion.Version30;
|
||||
using var response = await client.SendAsync(request, TestContext.CancellationTokenSource.Token);
|
||||
Assert.IsTrue(response.IsSuccessStatusCode);
|
||||
Assert.IsTrue(response.Content.Headers.ContentLength > 0);
|
||||
Console.WriteLine(await response.Content.ReadAsStringAsync(TestContext.CancellationTokenSource.Token));
|
||||
}
|
||||
|
||||
public TestContext TestContext { get; set; }
|
||||
}
|
||||
@@ -215,12 +215,15 @@
|
||||
<ColumnDefinition Width="1*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="28" />
|
||||
<RowDefinition Height="9" />
|
||||
<RowDefinition Height="28" />
|
||||
<RowDefinition Height="9" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Row="0" VerticalAlignment="Center" HorizontalAlignment="Left" Text="HTTP 代理" Margin="0,0,25,0" />
|
||||
<Grid Grid.Row="0" Grid.Column="1">
|
||||
<local:MyCheckBox x:Name="CheckNetDohEnable" Tag="SystemNetEnableDoH" Grid.Row="0" Grid.ColumnSpan="2" Text="使用 DoH 解析地址" ToolTip="使用 DoH 解析地址可以获取更加优质的 IP 结果,提高启动器的网络访问水平。如果您已部署 DoH 解析服务,可以关闭此功能。"/>
|
||||
<TextBlock Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Left" Text="HTTP 代理" Margin="0,0,25,0" />
|
||||
<Grid Grid.Row="2" Grid.Column="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="1*" />
|
||||
<ColumnDefinition Width="1*" />
|
||||
@@ -231,7 +234,7 @@
|
||||
<local:MyRadioBox Text="使用系统代理" x:Name="RadioHttpProxyType1" Height="22" Tag="SystemHttpProxyType/1" Grid.Column="1" />
|
||||
<local:MyRadioBox Text="自定义代理" x:Name="RadioHttpProxyType2" Height="22" Tag="SystemHttpProxyType/2" Grid.Column="2" />
|
||||
</Grid>
|
||||
<Grid Grid.Row="2" Grid.Column="1" x:Name="HttpProxyCustom" Visibility="{Binding ElementName=RadioHttpProxyType2,Path=Checked,Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
<Grid Grid.Row="4" Grid.Column="1" x:Name="HttpProxyCustom" Visibility="{Binding ElementName=RadioHttpProxyType2,Path=Checked,Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="28"/>
|
||||
<RowDefinition Height="9"/>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
Imports PCL.Core.App.Configuration
|
||||
Imports PCL.Core.App
|
||||
Imports PCL.Core.App.Configuration
|
||||
Imports PCL.Core.UI
|
||||
Imports PCL.Core.Utils.Exts
|
||||
|
||||
@@ -66,6 +67,7 @@ Class PageSetupSystem
|
||||
TextSystemHttpProxyCustomUsername.Text = Setup.Get("SystemHttpProxyCustomUsername")
|
||||
TextSystemHttpProxyCustomPassword.Text = Setup.Get("SystemHttpProxyCustomPassword")
|
||||
CType(FindName($"RadioHttpProxyType{Setup.Get("SystemHttpProxyType")}"), MyRadioBox).SetChecked(True, False)
|
||||
CheckNetDohEnable.Checked = Config.System.NetworkConfig.EnableDoH
|
||||
|
||||
'调试选项
|
||||
CheckDebugMode.Checked = Setup.Get("SystemDebugMode")
|
||||
@@ -105,6 +107,7 @@ Class PageSetupSystem
|
||||
Setup.Reset("SystemHttpProxyCustomUsername")
|
||||
Setup.Reset("SystemHttpProxyCustomPassword")
|
||||
Setup.Reset("SystemUseDefaultProxy")
|
||||
Config.System.NetworkConfig.Reset()
|
||||
Setup.Reset("UiAniFPS")
|
||||
|
||||
Log("[Setup] 已初始化启动器页设置")
|
||||
@@ -117,7 +120,7 @@ Class PageSetupSystem
|
||||
End Sub
|
||||
|
||||
'将控件改变路由到设置改变
|
||||
Private Shared Sub CheckBoxChange(sender As MyCheckBox, e As Object) Handles CheckDebugMode.Change, CheckDebugDelay.Change, CheckDebugSkipCopy.Change, CheckUpdateRelease.Change, CheckUpdateSnapshot.Change, CheckHelpChinese.Change, CheckDownloadIgnoreQuilt.Change, CheckDownloadClipboard.Change, CheckSystemDisableHardwareAcceleration.Change, CheckDownloadAutoSelectVersion.Change, CheckSystemTelemetry.Change, CheckFixAuthlib.Change
|
||||
Private Shared Sub CheckBoxChange(sender As MyCheckBox, e As Object) Handles CheckDebugMode.Change, CheckDebugDelay.Change, CheckDebugSkipCopy.Change, CheckUpdateRelease.Change, CheckUpdateSnapshot.Change, CheckHelpChinese.Change, CheckDownloadIgnoreQuilt.Change, CheckDownloadClipboard.Change, CheckSystemDisableHardwareAcceleration.Change, CheckDownloadAutoSelectVersion.Change, CheckSystemTelemetry.Change, CheckFixAuthlib.Change, CheckNetDohEnable.Change
|
||||
If AniControlEnabled = 0 Then Setup.Set(sender.Tag, sender.Checked)
|
||||
End Sub
|
||||
Private Shared Sub SliderChange(sender As MySlider, e As Object) Handles SliderDebugAnim.Change, SliderDownloadThread.Change, SliderDownloadSpeed.Change, SliderAniFPS.Change, SliderMaxLog.Change
|
||||
|
||||
Reference in New Issue
Block a user