File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -344,9 +344,6 @@ func (d *Daemon) handleConnect(req Request) Response {
344344
345345 target := req .Target
346346 port := req .Port
347- if port == 0 {
348- port = 7000
349- }
350347
351348 // If no target specified, use first cached device
352349 if target == "" {
@@ -361,6 +358,21 @@ func (d *Daemon) handleConnect(req Request) Response {
361358 d .mu .Unlock ()
362359 }
363360
361+ // Look up the discovered port for this target if not explicitly provided.
362+ if port == 0 {
363+ d .mu .Lock ()
364+ for _ , dev := range d .devices {
365+ if dev .IP == target {
366+ port = dev .Port
367+ break
368+ }
369+ }
370+ d .mu .Unlock ()
371+ }
372+ if port == 0 {
373+ port = 7000
374+ }
375+
364376 // Launch connection in background goroutine
365377 connCtx , cancel := context .WithCancel (context .Background ())
366378
You can’t perform that action at this time.
0 commit comments