diff --git a/dnsclient.go b/dnsclient.go index dbba5fe..1d8232b 100644 --- a/dnsclient.go +++ b/dnsclient.go @@ -65,6 +65,9 @@ func NewDNSClient(id, endpoint, network string, opt DNSClientOptions) (*DNSClien // Resolve a DNS query. func (d *DNSClient) Resolve(q *dns.Msg, ci ClientInfo) (*dns.Msg, error) { + // Packing a message is not always a read-only operation, make a copy + q = q.Copy() + logger(d.id, q, ci).WithFields(logrus.Fields{ "resolver": d.endpoint, "protocol": d.net, diff --git a/dohclient.go b/dohclient.go index f463349..35b03af 100644 --- a/dohclient.go +++ b/dohclient.go @@ -101,6 +101,9 @@ func NewDoHClient(id, endpoint string, opt DoHClientOptions) (*DoHClient, error) // Resolve a DNS query. func (d *DoHClient) Resolve(q *dns.Msg, ci ClientInfo) (*dns.Msg, error) { + // Packing a message is not always a read-only operation, make a copy + q = q.Copy() + logger(d.id, q, ci).WithFields(logrus.Fields{ "resolver": d.endpoint, "protocol": "doh", diff --git a/dotclient.go b/dotclient.go index 9420f07..22df881 100644 --- a/dotclient.go +++ b/dotclient.go @@ -71,6 +71,9 @@ func NewDoTClient(id, endpoint string, opt DoTClientOptions) (*DoTClient, error) // Resolve a DNS query. func (d *DoTClient) Resolve(q *dns.Msg, ci ClientInfo) (*dns.Msg, error) { + // Packing a message is not always a read-only operation, make a copy + q = q.Copy() + logger(d.id, q, ci).WithFields(logrus.Fields{ "resolver": d.endpoint, "protocol": "dot", diff --git a/dtlsclient.go b/dtlsclient.go index 9c42078..251f2f1 100644 --- a/dtlsclient.go +++ b/dtlsclient.go @@ -93,6 +93,9 @@ func NewDTLSClient(id, endpoint string, opt DTLSClientOptions) (*DTLSClient, err // Resolve a DNS query. func (d *DTLSClient) Resolve(q *dns.Msg, ci ClientInfo) (*dns.Msg, error) { + // Packing a message is not always a read-only operation, make a copy + q = q.Copy() + logger(d.id, q, ci).WithFields(logrus.Fields{ "resolver": d.endpoint, "protocol": "dtls",