Skip to content

Commit 9423147

Browse files
committed
Fix streaming to non-default port
1 parent bd0348f commit 9423147

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

internal/daemon/daemon.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)