modules.services.xray.client: use ali dns

This commit is contained in:
2025-10-06 05:56:54 +08:00
parent b4eb553987
commit f7651d639f
3 changed files with 34 additions and 3 deletions

View File

@@ -69,6 +69,7 @@ in platformConfig //
{ commandLineArgs = prev.commandLineArgs or "" + " --disable-features=GlobalShortcutsPortal"; });
google-chrome = prev.google-chrome.override (prev:
{ commandLineArgs = prev.commandLineArgs or "" + " --disable-features=GlobalShortcutsPortal"; });
xray = prev.xray.overrideAttrs (prev: { patches = prev.patches or [] ++ [ ./xray.patch ]; });
}
// (
let

View File

@@ -0,0 +1,30 @@
diff --git a/app/dns/nameserver_doh.go b/app/dns/nameserver_doh.go
index cba59423..19c6d34f 100644
--- a/app/dns/nameserver_doh.go
+++ b/app/dns/nameserver_doh.go
@@ -1,7 +1,7 @@
package dns
import (
- "bytes"
+ "encoding/base64"
"context"
"crypto/tls"
go_errors "errors"
@@ -188,14 +188,13 @@ func (s *DoHNameServer) sendQuery(ctx context.Context, noResponseErrCh chan<- er
}
func (s *DoHNameServer) dohHTTPSContext(ctx context.Context, b []byte) ([]byte, error) {
- body := bytes.NewBuffer(b)
- req, err := http.NewRequest("POST", s.dohURL, body)
+ query := fmt.Sprintf("%s?dns=%s", s.dohURL, base64.URLEncoding.WithPadding(base64.NoPadding).EncodeToString(b))
+ req, err := http.NewRequest("GET", query, nil)
if err != nil {
return nil, err
}
req.Header.Add("Accept", "application/dns-message")
- req.Header.Add("Content-Type", "application/dns-message")
req.Header.Set("X-Padding", strings.Repeat("X", int(crypto.RandBetween(100, 1000))))