Skip to content

Commit 347a0bf

Browse files
committed
pkg/hostagent/dns: truncate messages
Fix issue 80: `lima busybox nslookup storage.googleapis.com 192.168.5.3` fails with `Can't find storage.googleapis.com: Parse error` Signed-off-by: Akihiro Suda <[email protected]>
1 parent dff324c commit 347a0bf

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pkg/hostagent/dns/dns.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ import (
1111
"github.com/sirupsen/logrus"
1212
)
1313

14+
// Truncate for avoiding "Parse error" from `busybox nslookup`
15+
// https://github.com/lima-vm/lima/issues/380
16+
const truncateSize = 512
17+
1418
type Handler struct {
1519
clientConfig *dns.ClientConfig
1620
clients []*dns.Client
@@ -174,6 +178,7 @@ func (h *Handler) handleQuery(w dns.ResponseWriter, req *dns.Msg) {
174178
}
175179
}
176180
if handled {
181+
reply.Truncate(truncateSize)
177182
_ = w.WriteMsg(&reply)
178183
return
179184
}
@@ -186,13 +191,15 @@ func (h *Handler) handleDefault(w dns.ResponseWriter, req *dns.Msg) {
186191
addr := fmt.Sprintf("%s:%s", srv, h.clientConfig.Port)
187192
reply, _, err := client.Exchange(req, addr)
188193
if err == nil {
194+
reply.Truncate(truncateSize)
189195
_ = w.WriteMsg(reply)
190196
return
191197
}
192198
}
193199
}
194200
var reply dns.Msg
195201
reply.SetReply(req)
202+
reply.Truncate(truncateSize)
196203
_ = w.WriteMsg(&reply)
197204
}
198205

0 commit comments

Comments
 (0)