mirror of
https://github.com/CHN-beta/nixos.git
synced 2026-01-12 02:09:26 +08:00
modules.services.xray.client: use ali dns
This commit is contained in:
@@ -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
|
||||
|
||||
30
flake/lib/buildNixpkgsConfig/xray.patch
Normal file
30
flake/lib/buildNixpkgsConfig/xray.patch
Normal 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))))
|
||||
|
||||
Reference in New Issue
Block a user