Skip to content

Commit 900933d

Browse files
committed
Avoid copying dns.Msg structs containing atomic.Bool
Fixes go vet warning Fixes #3073
1 parent b457005 commit 900933d

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

dnscrypt-proxy/plugin_cache.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const StaleResponseTTL = 30 * time.Second
1515

1616
type CachedResponse struct {
1717
expiration time.Time
18-
msg dns.Msg
18+
msg *dns.Msg
1919
}
2020

2121
type CachedResponses struct {
@@ -141,7 +141,7 @@ func (plugin *PluginCacheResponse) Eval(pluginsState *PluginsState, msg *dns.Msg
141141
)
142142
cachedResponse := CachedResponse{
143143
expiration: time.Now().Add(ttl),
144-
msg: *msg,
144+
msg: msg.Copy(),
145145
}
146146
var cacheInitError error
147147
cachedResponses.cacheOnce.Do(func() {

dnscrypt-proxy/serversInfo.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ func fetchDNSCryptServerInfo(proxy *Proxy, name string, stamp stamps.ServerStamp
761761
msg, _, _, err := DNSExchange(
762762
proxy,
763763
proxy.xTransport.mainProto,
764-
&query,
764+
query,
765765
stamp.ServerAddrStr,
766766
dnscryptRelay,
767767
&name,
@@ -849,7 +849,7 @@ func dohNXTestPacket(msgID uint16) []byte {
849849
return msg.Data
850850
}
851851

852-
func plainNXTestPacket(msgID uint16) dns.Msg {
852+
func plainNXTestPacket(msgID uint16) *dns.Msg {
853853
qName := make([]byte, 16)
854854
charset := "abcdefghijklmnopqrstuvwxyz"
855855
for i := range qName {
@@ -858,7 +858,7 @@ func plainNXTestPacket(msgID uint16) dns.Msg {
858858
msg := dns.NewMsg(string(qName)+".test.dnscrypt.", dns.TypeNS)
859859
msg.ID = msgID
860860
msg.RecursionDesired = true
861-
return *msg
861+
return msg
862862
}
863863

864864
func fetchDoHServerInfo(proxy *Proxy, name string, stamp stamps.ServerStamp, isNew bool) (ServerInfo, error) {

0 commit comments

Comments
 (0)