From 28c7de6185a23a9acc58cfbf158e7abc12e74669 Mon Sep 17 00:00:00 2001 From: Skyxim Date: Tue, 14 Feb 2023 21:09:37 +0800 Subject: [PATCH] fix: avoid modifying the request message id --- dns/doh.go | 1 + dns/doq.go | 1 + 2 files changed, 2 insertions(+) diff --git a/dns/doh.go b/dns/doh.go index df3df6b4..0a9efe1c 100644 --- a/dns/doh.go +++ b/dns/doh.go @@ -109,6 +109,7 @@ func (doh *dnsOverHTTPS) ExchangeContext(ctx context.Context, m *D.Msg) (msg *D. // formats that include the ID field from the DNS message header, such // as "application/dns-message", SHOULD use a DNS ID of 0 in every DNS // request. + m=m.Copy() id := m.Id m.Id = 0 defer func() { diff --git a/dns/doq.go b/dns/doq.go index 1097b500..1354f177 100644 --- a/dns/doq.go +++ b/dns/doq.go @@ -89,6 +89,7 @@ func (doq *dnsOverQUIC) Address() string { return doq.addr } func (doq *dnsOverQUIC) ExchangeContext(ctx context.Context, m *D.Msg) (msg *D.Msg, err error) { // When sending queries over a QUIC connection, the DNS Message ID MUST be // set to zero. + m = m.Copy() id := m.Id m.Id = 0 defer func() {