Skip to content

Commit

Permalink
0.1.0 更新
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceTimee committed Dec 31, 2023
1 parent 75105f6 commit f99b715
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 21 deletions.
15 changes: 9 additions & 6 deletions Sheas-Dop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
<PackageReleaseNotes>Just Purge It</PackageReleaseNotes>
<Authors>Space Time</Authors>
<Company>Space Time</Company>
<AssemblyVersion>0.0.1</AssemblyVersion>
<Version>0.0.1</Version>
<FileVersion>0.0.1</FileVersion>
<InformationalVersion>0.0.1</InformationalVersion>
<AssemblyVersion>0.1.0</AssemblyVersion>
<Version>0.1.0</Version>
<FileVersion>0.1.0</FileVersion>
<InformationalVersion>0.1.0</InformationalVersion>
<PackageTags>Tool;Sheas;Dop;Dns</PackageTags>
<ApplicationIcon>Sheas-Dop-Logo.ico</ApplicationIcon>
<PackageIcon>Sheas Dop Logo.png</PackageIcon>
Expand All @@ -22,7 +22,7 @@
<RepositoryType>git</RepositoryType>
<Copyright>Copyright © 2077</Copyright>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows10.0.22000.0</TargetFramework>
<TargetFramework>net8.0-windows10.0.22000.0</TargetFramework>
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
<RootNamespace>Sheas_Dop</RootNamespace>
<Nullable>enable</Nullable>
Expand Down Expand Up @@ -60,10 +60,13 @@

<ItemGroup>
<PackageReference Include="MaterialDesignThemes" Version="4.9.0" />
<PackageReference Include="TurnerSoftware.DinoDNS" Version="0.3.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

<ItemGroup>
<Reference Include="Ona-Core">
<HintPath>..\Ona-Core\bin\Release\net5.0-windows10.0.22000.0\Ona-Core.dll</HintPath>
</Reference>
<Reference Include="Sheas-Core">
<HintPath>..\Sheas-Core\bin\Release\Sheas-Core.dll</HintPath>
</Reference>
Expand Down
6 changes: 6 additions & 0 deletions Sheas-Dop.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sheas-Dop", "Sheas-Dop.cspr
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sheas-Core", "..\Sheas-Core\Sheas-Core.csproj", "{42491572-0050-4CDA-9189-DFC98BDBBF73}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ona-Core", "..\Ona-Core\Ona-Core.csproj", "{158FB33D-ADE2-446F-9E24-D84242FEE808}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -21,6 +23,10 @@ Global
{42491572-0050-4CDA-9189-DFC98BDBBF73}.Debug|Any CPU.Build.0 = Debug|Any CPU
{42491572-0050-4CDA-9189-DFC98BDBBF73}.Release|Any CPU.ActiveCfg = Release|Any CPU
{42491572-0050-4CDA-9189-DFC98BDBBF73}.Release|Any CPU.Build.0 = Release|Any CPU
{158FB33D-ADE2-446F-9E24-D84242FEE808}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{158FB33D-ADE2-446F-9E24-D84242FEE808}.Debug|Any CPU.Build.0 = Debug|Any CPU
{158FB33D-ADE2-446F-9E24-D84242FEE808}.Release|Any CPU.ActiveCfg = Release|Any CPU
{158FB33D-ADE2-446F-9E24-D84242FEE808}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
41 changes: 26 additions & 15 deletions Windows/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Net;
using System.Linq;
using System.Net.Http;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
Expand All @@ -9,15 +11,15 @@
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Threading;
using TurnerSoftware.DinoDNS;
using TurnerSoftware.DinoDNS.Protocol;
using TurnerSoftware.DinoDNS.Protocol.ResourceRecords;
using Newtonsoft.Json.Linq;
using OnaCore;

namespace Sheas_Dop;

public partial class MainWindow : Window
{
private static readonly DispatcherTimer MONITOR_TIMER = new() { Interval = new TimeSpan(1000000) }; //0.1s
private readonly HttpClient MAIN_CLIENT = new(); //当前窗口使用的唯一的 HttpClient

public MainWindow()
{
Expand Down Expand Up @@ -92,12 +94,26 @@ private async void SingleButton_Click(object sender, RoutedEventArgs e)
{
try
{
if (GlobalButton.Content.ToString() != "全局解析")
MessageBox.Show("使用单个解析时需停止全局解析");
else
await ResolveDNS(new DnsClient(new NameServer[] { new NameServer(IPAddress.Parse("8.8.8.8"), NameServers.DefaultDoHPort, ConnectionType.DoH) }, DnsMessageOptions.Default));
List<string> ips = [];

JToken arashiAnswers = await DomainResolve($"https://ns.net.kg/dns-query?name={DomainBox.Text}&type=A");
if (arashiAnswers != null)
foreach (JToken arashiAnswer in arashiAnswers)
ips.Add(arashiAnswer["data"]!.ToString());

//NameServers.Cloudflare.IPv4.GetPrimary(ConnectionType.DoH)
JToken quad101Answers = await DomainResolve($"https://101.101.101.101/dns-query?name={DomainBox.Text}&type=A");
if (quad101Answers != null)
foreach (JToken quad101Answer in quad101Answers)
ips.Add(quad101Answer["data"]!.ToString());

if (ips.Count > 0)
{
ips = ips.Distinct().ToList();
foreach (string ip in ips)
if (MessageBox.Show(ip, "解析结果", MessageBoxButton.OKCancel) == MessageBoxResult.Cancel) break;
}
else
MessageBox.Show("没有符合的解析结果", "解析结果");
}
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); }
}
Expand All @@ -107,12 +123,7 @@ private void AboutButton_Click(object sender, RoutedEventArgs e)
catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); }
}

private async Task ResolveDNS(DnsClient client)
{
DnsMessage dnsMessage = await client.QueryAsync(DomainBox.Text, DnsQueryType.A);
foreach (ARecord aRecord in dnsMessage.Answers.WithARecords())
if (MessageBox.Show(aRecord.ToIPAddress().ToString(), "解析结果", MessageBoxButton.OKCancel) == MessageBoxResult.Cancel) break;
}
private async Task<JToken> DomainResolve(string resolverUrl) => JObject.Parse(await Http.GetAsync<string>(resolverUrl, MAIN_CLIENT))["Answer"]!;

private void MainWin_KeyDown(object sender, KeyEventArgs e)
{
Expand Down

0 comments on commit f99b715

Please sign in to comment.