From dd586f2786ee5e269fb178a2afa0853f75cf95ca Mon Sep 17 00:00:00 2001 From: Naiming Shen Date: Tue, 23 Apr 2024 14:02:08 -0700 Subject: [PATCH] allow edgeview VNC access even the app does not get an IP Signed-off-by: Naiming Shen --- pkg/edgeview/src/network.go | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/pkg/edgeview/src/network.go b/pkg/edgeview/src/network.go index e014f3c2f4..f725ad4e6a 100644 --- a/pkg/edgeview/src/network.go +++ b/pkg/edgeview/src/network.go @@ -492,20 +492,28 @@ func getAllAppIPs() []appIPvnc { status := strings.TrimSuffix(string(retbytes1), "\n") appIPs, appUUID := getAppIPs(status) var oneAppIPs []appIPvnc - if len(appIPs) > 0 { - retbytes1, err := os.ReadFile("/run/zedagent/AppInstanceConfig/" + appUUID.String() + ".json") - if err != nil { - log.Errorf("getAllAppIPs: run appinstcfg %v", err) - continue - } - var appInstCfg types.AppInstanceConfig - err = json.Unmarshal(retbytes1, &appInstCfg) - if err != nil { - log.Errorf("getAllAppIPs: unmarshal %v", err) - continue - } + retbytes1, err = os.ReadFile("/run/zedagent/AppInstanceConfig/" + appUUID.String() + ".json") + if err != nil { + log.Errorf("getAllAppIPs: run appinstcfg %v", err) + continue + } + var appInstCfg types.AppInstanceConfig + err = json.Unmarshal(retbytes1, &appInstCfg) + if err != nil { + log.Errorf("getAllAppIPs: unmarshal %v", err) + continue + } - enableVNC := appInstCfg.FixedResources.EnableVnc + enableVNC := appInstCfg.FixedResources.EnableVnc + // Even if the app has no IP address, we still want to allow VNC if it is enabled + if len(appIPs) == 0 { + ipVNC := appIPvnc{ + vncEnable: enableVNC, + appName: appInstCfg.DisplayName, + vncPort: int(appInstCfg.FixedResources.VncDisplay), + } + oneAppIPs = append(oneAppIPs, ipVNC) + } else { for _, ipaddr := range appIPs { ipVNC := appIPvnc{ ipAddr: ipaddr,