From 6bc52785ed4e5d0db00b39401f082fe4702114f2 Mon Sep 17 00:00:00 2001 From: Robin Elfrink Date: Fri, 25 Oct 2024 12:38:22 +0200 Subject: [PATCH] fix: update guestinfo on incoming ping On incoming ping request send updated guest info. Exclude NIC info, since that is already sent on incoming broadcastIP option request. Signed-off-by: Robin Elfrink --- internal/tboxcmds/guestinfo.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/internal/tboxcmds/guestinfo.go b/internal/tboxcmds/guestinfo.go index b1ec9b2..0bd14a2 100644 --- a/internal/tboxcmds/guestinfo.go +++ b/internal/tboxcmds/guestinfo.go @@ -211,6 +211,16 @@ func (cmd *GuestInfoCommands) PushGuestInfo() { cmd.SendGuestInfoNIC() } +// PingHandler pushes updated guest info on ping request. +func (cmd *GuestInfoCommands) PingHandler([]byte) ([]byte, error) { + cmd.SendGuestInfoDNSName() + cmd.SendGuestInfoOSNameFull() + cmd.SendGuestInfoOSName() + cmd.SendGuestInfoUptime() + + return nil, nil +} + // RegisterGuestInfoCommands registers the guest info commands. func RegisterGuestInfoCommands(svc *nanotoolbox.Service, delegate NicDelegate) { cmd := &GuestInfoCommands{ @@ -220,6 +230,7 @@ func RegisterGuestInfoCommands(svc *nanotoolbox.Service, delegate NicDelegate) { } svc.RegisterResetHandler(cmd.PushGuestInfo) svc.RegisterOptionHandler("broadcastIP", cmd.BroadcastIPOptionHandler) + svc.RegisterCommandHandler("ping", cmd.PingHandler) // As stated in guestInfoServer.c, VMX expects uptime information in response // to the capabilities request.