fix: avoid modifying the request message id

This commit is contained in:
Skyxim 2023-02-14 21:09:37 +08:00
parent 6fb4ebba15
commit 28c7de6185
2 changed files with 2 additions and 0 deletions

View file

@ -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 // 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 // as "application/dns-message", SHOULD use a DNS ID of 0 in every DNS
// request. // request.
m=m.Copy()
id := m.Id id := m.Id
m.Id = 0 m.Id = 0
defer func() { defer func() {

View file

@ -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) { 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 // When sending queries over a QUIC connection, the DNS Message ID MUST be
// set to zero. // set to zero.
m = m.Copy()
id := m.Id id := m.Id
m.Id = 0 m.Id = 0
defer func() { defer func() {