Skip to content

Commit 1b522f2

Browse files
committed
Retrieve RemoteCVDLocator from listCVDsSingleHost for webrtc based connection
1 parent 58618bb commit 1b522f2

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

pkg/cli/cli.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,14 +1380,24 @@ func runConnectionWebrtcAgentCommand(flags *ConnectFlags, c *command, args []str
13801380
if err != nil {
13811381
return err
13821382
}
1383-
1384-
devSpec := RemoteCVDLocator{
1385-
Host: flags.host,
1386-
WebRTCDeviceID: device,
1383+
controlDir := opts.InitialConfig.ConnectionControlDirExpanded()
1384+
hosts, err := listCVDsSingleHost(srvClient, opts.InitialConfig.ConnectionControlDirExpanded(), flags.host)
1385+
if err != nil {
1386+
return fmt.Errorf("failed to list cvds from host %q: %w", flags.host, err)
1387+
}
1388+
cvds := flattenCVDs(hosts)
1389+
var connectionCVD *RemoteCVDLocator
1390+
for _, cvd := range cvds {
1391+
if cvd.RemoteCVDLocator.WebRTCDeviceID == device {
1392+
connectionCVD = &cvd.RemoteCVDLocator
1393+
break
1394+
}
1395+
}
1396+
if connectionCVD == nil {
1397+
return fmt.Errorf("failed to find %q from host %q", device, flags.host)
13871398
}
13881399

1389-
controlDir := opts.InitialConfig.ConnectionControlDirExpanded()
1390-
ret, err := FindOrConnect(controlDir, devSpec, srvClient, localICEConfig)
1400+
ret, err := FindOrConnect(controlDir, *connectionCVD, srvClient, localICEConfig)
13911401
if err != nil {
13921402
return err
13931403
}

0 commit comments

Comments
 (0)