diff --git a/@libs/dnscrypt-proxy.toml b/@libs/dnscrypt-proxy.toml
index 84d0bb2..2a24387 100644
--- a/@libs/dnscrypt-proxy.toml
+++ b/@libs/dnscrypt-proxy.toml
@@ -86,7 +86,7 @@ disabled_server_names = []
## (dnscrypt-proxy will always encrypt everything even using UDP), and can
## only increase latency.
-force_tcp = true
+force_tcp = false
## SOCKS proxy
diff --git a/FastGithub.Dns/DnsInterceptor.cs b/FastGithub.Dns/DnsInterceptor.cs
index 71220cc..2743dac 100644
--- a/FastGithub.Dns/DnsInterceptor.cs
+++ b/FastGithub.Dns/DnsInterceptor.cs
@@ -70,7 +70,7 @@ namespace FastGithub.Dns
{
try
{
- this.ProcessDnsPacket(packetBuffer, ref packetLength);
+ this.ProcessDnsPacket(packetBuffer, ref winDivertAddress, ref packetLength);
}
catch (Exception ex)
{
@@ -136,7 +136,9 @@ namespace FastGithub.Dns
/// 处理DNS数据包
///
///
- private void ProcessDnsPacket(byte[] packetBuffer, ref uint packetLength)
+ ///
+ ///
+ private void ProcessDnsPacket(byte[] packetBuffer, ref WinDivertAddress winDivertAddress, ref uint packetLength)
{
var packetData = packetBuffer.AsSpan(0, (int)packetLength).ToArray();
var packet = Packet.ParsePacket(LinkLayers.Raw, packetData);
@@ -144,6 +146,11 @@ namespace FastGithub.Dns
var udpPacket = (UdpPacket)ipPacket.PayloadPacket;
var request = Request.FromArray(udpPacket.PayloadData);
+ if (request.OperationCode != OperationCode.Query)
+ {
+ return;
+ }
+
var question = request.Questions.FirstOrDefault();
if (question == null || question.Type != RecordType.A)
{
@@ -175,6 +182,16 @@ namespace FastGithub.Dns
// 修改数据内容和数据长度
packet.Bytes.CopyTo(packetBuffer, 0);
packetLength = (uint)packet.Bytes.Length;
+
+ // 反转方向
+ if (winDivertAddress.Direction == WinDivertDirection.Inbound)
+ {
+ winDivertAddress.Direction = WinDivertDirection.Outbound;
+ }
+ else
+ {
+ winDivertAddress.Direction = WinDivertDirection.Inbound;
+ }
}
}
}
diff --git a/FastGithub.DomainResolve/DomainResolver.cs b/FastGithub.DomainResolve/DomainResolver.cs
index 427fae8..7801c55 100644
--- a/FastGithub.DomainResolve/DomainResolver.cs
+++ b/FastGithub.DomainResolve/DomainResolver.cs
@@ -1,4 +1,5 @@
-using DNS.Client.RequestResolver;
+using DNS.Client;
+using DNS.Client.RequestResolver;
using DNS.Protocol;
using DNS.Protocol.ResourceRecords;
using FastGithub.Configuration;
@@ -178,7 +179,11 @@ namespace FastGithub.DomainResolve
{
try
{
- var request = new Request();
+ var request = new Request
+ {
+ RecursionDesired = true,
+ OperationCode = OperationCode.Query
+ };
request.Questions.Add(new Question(new Domain(domain.Host), RecordType.A));
using var timeoutTokenSource = new CancellationTokenSource(this.lookupTimeout);
@@ -288,7 +293,8 @@ namespace FastGithub.DomainResolve
public Task Resolve(IRequest request, CancellationToken cancellationToken = default)
{
- return this.resolver.Resolve(request, cancellationToken);
+ var clientRequest = new ClientRequest(this.resolver, request);
+ return clientRequest.Resolve(cancellationToken);
}
public override string ToString()