MCPcopy Index your code
hub / github.com/coder/coder / runCoderConnectStdio

Function runCoderConnectStdio

cli/ssh.go:1690–1713  ·  view source on GitHub ↗
(ctx context.Context, addr string, stdin io.Reader, stdout io.Writer, stack *closerStack, logger slog.Logger)

Source from the content-addressed store, hash-verified

1688}
1689
1690func runCoderConnectStdio(ctx context.Context, addr string, stdin io.Reader, stdout io.Writer, stack *closerStack, logger slog.Logger) error {
1691 dialer := testOrDefaultDialer(ctx)
1692 var conn net.Conn
1693 if err := retryWithInterval(ctx, logger, sshRetryInterval, sshMaxAttempts, func() error {
1694 var err error
1695 conn, err = dialer.DialContext(ctx, "tcp", addr)
1696 if err != nil {
1697 return xerrors.Errorf("dial coder connect host %q over tcp: %w", addr, err)
1698 }
1699 return nil
1700 }); err != nil {
1701 return err
1702 }
1703 if err := stack.push("tcp conn", conn); err != nil {
1704 return err
1705 }
1706
1707 agentssh.Bicopy(ctx, conn, &StdioRwc{
1708 Reader: stdin,
1709 Writer: stdout,
1710 })
1711
1712 return nil
1713}
1714
1715type StdioRwc struct {
1716 io.Reader

Callers 2

TestCoderConnectStdioFunction · 0.85
sshMethod · 0.85

Calls 6

BicopyFunction · 0.92
testOrDefaultDialerFunction · 0.85
retryWithIntervalFunction · 0.85
pushMethod · 0.80
DialContextMethod · 0.65
ErrorfMethod · 0.45

Tested by 1

TestCoderConnectStdioFunction · 0.68