add tcp daemon listener with token auth

This commit is contained in:
2026-05-27 14:19:14 +01:00
parent 5149224000
commit 63cb8a4388
6 changed files with 368 additions and 12 deletions

View File

@@ -33,6 +33,7 @@ type ClientOptions struct {
Stdout io.Writer
RawMode bool
AutoStart bool
Token string
Cols uint16
Rows uint16
}
@@ -66,6 +67,14 @@ func RunAttachedClient(ctx context.Context, opts ClientOptions) error {
return c.run(ctx)
}
func DialTCPTransport(addr string) (protocol.Transport, error) {
conn, err := net.Dial("tcp", addr)
if err != nil {
return nil, err
}
return protocol.NewConnTransport(conn), nil
}
func dialDaemonTransport(projectDir string, autoStart bool) (protocol.Transport, error) {
socket, _, err := RuntimeDaemonPaths()
if err != nil {
@@ -120,6 +129,7 @@ type netClient struct {
out io.Writer
raw bool
projectDir string
token string
layout terminalLayout
mu sync.Mutex
@@ -141,6 +151,7 @@ func newNetClient(opts ClientOptions) *netClient {
out: opts.Stdout,
raw: opts.RawMode,
projectDir: opts.ProjectDir,
token: opts.Token,
layout: layout,
renderer: newViewportRenderer(layout),
}
@@ -204,6 +215,7 @@ func (c *netClient) run(ctx context.Context) error {
func (c *netClient) sendAttach() error {
f, err := protocol.NewFrame(protocol.FrameAttach, protocol.Attach{
ProjectPath: c.projectPath(),
Token: c.token,
TermSize: protocol.Size{
Cols: c.layout.childCols(),
Rows: c.layout.childRows(),