Skip to content

Commit 3eaa898

Browse files
committed
Don't log DNS queries by default
Local server names/addresses are often considered confidential and should not by default be logged. Their loglevel has been lowered to TRACE. The host agent code now switches to TRACE level logging when the instance is started via `limactl --debug start ...`. Signed-off-by: Jan Dubois <[email protected]>
1 parent cf132ea commit 3eaa898

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

cmd/limactl/hostagent.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,5 +122,10 @@ func initLogrus(stderr io.Writer) {
122122
logrus.SetOutput(stderr)
123123
// JSON logs are parsed in pkg/hostagent/events.Watcher()
124124
logrus.SetFormatter(new(logrus.JSONFormatter))
125-
logrus.SetLevel(logrus.DebugLevel)
125+
// HostAgent logging is one level more verbose than the start command itself
126+
if logrus.GetLevel() == logrus.DebugLevel {
127+
logrus.SetLevel(logrus.TraceLevel)
128+
} else {
129+
logrus.SetLevel(logrus.DebugLevel)
130+
}
126131
}

pkg/hostagent/dns/dns.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func (s *Server) Shutdown() {
6767
}
6868

6969
func newStaticClientConfig(ips []string) (*dns.ClientConfig, error) {
70-
logrus.Debugf("newStaticClientConfig creating config for the the following IPs: %v", ips)
70+
logrus.Tracef("newStaticClientConfig creating config for the the following IPs: %v", ips)
7171
s := ``
7272
for _, ip := range ips {
7373
s += fmt.Sprintf("nameserver %s\n", ip)
@@ -152,7 +152,7 @@ func (h *Handler) handleQuery(w dns.ResponseWriter, req *dns.Msg) {
152152
)
153153
defer w.Close()
154154
reply.SetReply(req)
155-
logrus.Debugf("handleQuery received DNS query: %v", req)
155+
logrus.Tracef("handleQuery received DNS query: %v", req)
156156
for _, q := range req.Question {
157157
hdr := dns.RR_Header{
158158
Name: q.Name,
@@ -315,7 +315,7 @@ func (h *Handler) handleQuery(w dns.ResponseWriter, req *dns.Msg) {
315315
}
316316

317317
func (h *Handler) handleDefault(w dns.ResponseWriter, req *dns.Msg) {
318-
logrus.Debugf("handleDefault for %v", req)
318+
logrus.Tracef("handleDefault for %v", req)
319319
for _, client := range h.clients {
320320
for _, srv := range h.clientConfig.Servers {
321321
addr := fmt.Sprintf("%s:%s", srv, h.clientConfig.Port)
@@ -325,7 +325,7 @@ func (h *Handler) handleDefault(w dns.ResponseWriter, req *dns.Msg) {
325325
continue
326326
}
327327
if h.truncate {
328-
logrus.Debugf("handleDefault truncating reply: %v", reply)
328+
logrus.Tracef("handleDefault truncating reply: %v", reply)
329329
reply.Truncate(truncateSize)
330330
}
331331
if err = w.WriteMsg(reply); err != nil {
@@ -337,7 +337,7 @@ func (h *Handler) handleDefault(w dns.ResponseWriter, req *dns.Msg) {
337337
var reply dns.Msg
338338
reply.SetReply(req)
339339
if h.truncate {
340-
logrus.Debugf("handleDefault truncating reply: %v", reply)
340+
logrus.Tracef("handleDefault truncating reply: %v", reply)
341341
reply.Truncate(truncateSize)
342342
}
343343
if err := w.WriteMsg(&reply); err != nil {

0 commit comments

Comments
 (0)