Documentation
¶
Index ¶
- Constants
- Variables
- type AgentConn
- func (c *AgentConn) AwaitReachable(ctx context.Context) bool
- func (c *AgentConn) Close() error
- func (c *AgentConn) DebugLogs(ctx context.Context) ([]byte, error)
- func (c *AgentConn) DebugMagicsock(ctx context.Context) ([]byte, error)
- func (c *AgentConn) DebugManifest(ctx context.Context) ([]byte, error)
- func (c *AgentConn) DialContext(ctx context.Context, network string, addr string) (net.Conn, error)
- func (c *AgentConn) GetPeerDiagnostics() tailnet.PeerDiagnostics
- func (c *AgentConn) ListeningPorts(ctx context.Context) (codersdk.WorkspaceAgentListeningPortsResponse, error)
- func (c *AgentConn) Ping(ctx context.Context) (time.Duration, bool, *ipnstate.PingResult, error)
- func (c *AgentConn) PrometheusMetrics(ctx context.Context) ([]byte, error)
- func (c *AgentConn) ReconnectingPTY(ctx context.Context, id uuid.UUID, height, width uint16, command string) (net.Conn, error)
- func (c *AgentConn) SSH(ctx context.Context) (*gonet.TCPConn, error)
- func (c *AgentConn) SSHClient(ctx context.Context) (*ssh.Client, error)
- func (c *AgentConn) Speedtest(ctx context.Context, direction speedtest.Direction, duration time.Duration) ([]speedtest.Result, error)
- type AgentConnOptions
- type AgentConnectionInfo
- type AgentReconnectingPTYInit
- type Client
- func (c *Client) AgentConnectionInfo(ctx context.Context, agentID uuid.UUID) (AgentConnectionInfo, error)
- func (c *Client) AgentConnectionInfoGeneric(ctx context.Context) (AgentConnectionInfo, error)
- func (c *Client) AgentReconnectingPTY(ctx context.Context, opts WorkspaceAgentReconnectingPTYOpts) (net.Conn, error)
- func (c *Client) DialAgent(dialCtx context.Context, agentID uuid.UUID, options *DialAgentOptions) (agentConn *AgentConn, err error)
- type DialAgentOptions
- type ReconnectingPTYRequest
- type WorkspaceAgentReconnectingPTYOpts
Constants ¶
const ( AgentSSHPort = tailnet.WorkspaceAgentSSHPort AgentReconnectingPTYPort = tailnet.WorkspaceAgentReconnectingPTYPort AgentSpeedtestPort = tailnet.WorkspaceAgentSpeedtestPort // AgentHTTPAPIServerPort serves a HTTP server with endpoints for e.g. // gathering agent statistics. AgentHTTPAPIServerPort = 4 // AgentMinimumListeningPort is the minimum port that the listening-ports // endpoint will return to the client, and the minimum port that is accepted // by the proxy applications endpoint. Coder consumes ports 1-4 at the // moment, and we reserve some extra ports for future use. Port 9 and up are // available for the user. // // This is not enforced in the CLI intentionally as we don't really care // *that* much. The user could bypass this in the CLI by using SSH instead // anyways. AgentMinimumListeningPort = 9 )
Variables ¶
var AgentIP = netip.MustParseAddr("fd7a:115c:a1e0:49d6:b259:b7ac:b1b2:48f4")
AgentIP is a static IPv6 address with the Tailscale prefix that is used to route connections from clients to this node. A dynamic address is not required because a Tailnet client only dials a single agent at a time.
Deprecated: use tailnet.IP() instead. This is kept for backwards compatibility with outdated CLI clients and Workspace Proxies that dial it. See: https://github.com/coder/coder/issues/11819
var AgentIgnoredListeningPorts = map[uint16]struct{}{
0: {},
1: {},
2: {},
3: {},
4: {},
5: {},
6: {},
7: {},
8: {},
20: {},
21: {},
22: {},
23: {},
25: {},
53: {},
110: {},
143: {},
179: {},
389: {},
636: {},
465: {},
587: {},
989: {},
990: {},
993: {},
995: {},
3306: {},
3389: {},
5432: {},
27017: {},
27018: {},
27019: {},
28017: {},
}
AgentIgnoredListeningPorts contains a list of ports to ignore when looking for running applications inside a workspace. We want to ignore non-HTTP servers, so we pre-populate this list with common ports that are not HTTP servers.
This is implemented as a map for fast lookup.
var ErrSkipClose = xerrors.New("skip tailnet close")
Functions ¶
This section is empty.
Types ¶
type AgentConn ¶
AgentConn represents a connection to a workspace agent. @typescript-ignore AgentConn
func NewAgentConn ¶
func NewAgentConn(conn *tailnet.Conn, opts AgentConnOptions) *AgentConn
NewAgentConn creates a new WorkspaceAgentConn. `conn` may be unique to the WorkspaceAgentConn, or it may be shared in the case of coderd. If the conn is shared and closing it is undesirable, you may return ErrNoClose from opts.CloseFunc. This will ensure the underlying conn is not closed.
func (*AgentConn) AwaitReachable ¶
AwaitReachable waits for the agent to be reachable.
func (*AgentConn) DebugMagicsock ¶
DebugMagicsock makes a request to the workspace agent's magicsock debug endpoint.
func (*AgentConn) DebugManifest ¶
DebugManifest returns the agent's in-memory manifest. Unfortunately this must be returns as a []byte to avoid an import cycle.
func (*AgentConn) DialContext ¶
DialContext dials the address provided in the workspace agent. The network must be "tcp" or "udp".
func (*AgentConn) GetPeerDiagnostics ¶
func (c *AgentConn) GetPeerDiagnostics() tailnet.PeerDiagnostics
func (*AgentConn) ListeningPorts ¶
func (c *AgentConn) ListeningPorts(ctx context.Context) (codersdk.WorkspaceAgentListeningPortsResponse, error)
ListeningPorts lists the ports that are currently in use by the workspace.
func (*AgentConn) Ping ¶
Ping pings the agent and returns the round-trip time. The bool returns true if the ping was made P2P.
func (*AgentConn) PrometheusMetrics ¶
PrometheusMetrics returns a response from the agent's prometheus metrics endpoint
func (*AgentConn) ReconnectingPTY ¶
func (c *AgentConn) ReconnectingPTY(ctx context.Context, id uuid.UUID, height, width uint16, command string) (net.Conn, error)
ReconnectingPTY spawns a new reconnecting terminal session. `ReconnectingPTYRequest` should be JSON marshaled and written to the returned net.Conn. Raw terminal output will be read from the returned net.Conn.
func (*AgentConn) SSH ¶
SSH pipes the SSH protocol over the returned net.Conn. This connects to the built-in SSH server in the workspace agent.
type AgentConnOptions ¶
@typescript-ignore AgentConnOptions
type AgentConnectionInfo ¶
type AgentConnectionInfo struct { DERPMap *tailcfg.DERPMap `json:"derp_map"` DERPForceWebSockets bool `json:"derp_force_websockets"` DisableDirectConnections bool `json:"disable_direct_connections"` }
AgentConnectionInfo returns required information for establishing a connection with a workspace. @typescript-ignore AgentConnectionInfo
type AgentReconnectingPTYInit ¶
AgentReconnectingPTYInit initializes a new reconnecting PTY session. @typescript-ignore AgentReconnectingPTYInit
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) AgentConnectionInfo ¶
func (*Client) AgentConnectionInfoGeneric ¶
func (c *Client) AgentConnectionInfoGeneric(ctx context.Context) (AgentConnectionInfo, error)
func (*Client) AgentReconnectingPTY ¶
func (c *Client) AgentReconnectingPTY(ctx context.Context, opts WorkspaceAgentReconnectingPTYOpts) (net.Conn, error)
AgentReconnectingPTY spawns a PTY that reconnects using the token provided. It communicates using `agent.ReconnectingPTYRequest` marshaled as JSON. Responses are PTY output that can be rendered.
type DialAgentOptions ¶
type DialAgentOptions struct { Logger slog.Logger // BlockEndpoints forced a direct connection through DERP. The Client may // have DisableDirect set which will override this value. BlockEndpoints bool // CaptureHook is a callback that captures Disco packets and packets sent // into the tailnet tunnel. CaptureHook capture.Callback }
@typescript-ignore DialAgentOptions
type ReconnectingPTYRequest ¶
type ReconnectingPTYRequest struct { Data string `json:"data,omitempty"` Height uint16 `json:"height,omitempty"` Width uint16 `json:"width,omitempty"` }
ReconnectingPTYRequest is sent from the client to the server to pipe data to a PTY. @typescript-ignore ReconnectingPTYRequest
type WorkspaceAgentReconnectingPTYOpts ¶
type WorkspaceAgentReconnectingPTYOpts struct { AgentID uuid.UUID Reconnect uuid.UUID Width uint16 Height uint16 Command string // SignedToken is an optional signed token from the // issue-reconnecting-pty-signed-token endpoint. If set, the session token // on the client will not be sent. SignedToken string }
@typescript-ignore:WorkspaceAgentReconnectingPTYOpts