Documentation
¶
Overview ¶
Package transport provides the direct and agent network dialers.
Package transport builds the NetTransport a plugin uses to reach its target. Connectivity is orthogonal to protocol: "direct" dials out from the gateway, "agent" dials through a reverse tunnel registered by an in-target agent.
Index ¶
- Constants
- Variables
- func Build(conn models.Connection, reg TunnelRegistry, agentMode plugin.AgentMode) (plugin.NetTransport, error)
- func ReadStreamTarget(r io.Reader) (network, addr string, err error)
- func ServeGatewayTunnel(c *websocket.Conn, connectionID string, reg *Registry, forward bool) error
- func WriteStreamTarget(w io.Writer, network, addr string) error
- type AgentConnectResponse
- type AgentHello
- type AgentProxyTarget
- type DialFunc
- type Direct
- type Registry
- type TunnelRegistry
Constants ¶
const ( AgentModeTCP = "tcp" AgentModeUnix = "unix" AgentModeHTTP = "http_proxy" AgentModeHostMonitor = "host_monitor" )
Agent proxy mode wire values, mirroring plugin.AgentMode. They live here so the standalone agent binary depends only on this package, not internal/plugin.
Variables ¶
ErrAgentUnavailable is returned when an agent-transport connection has no live tunnel registered (the agent has not connected, or has gone offline).
Functions ¶
func Build ¶
func Build(conn models.Connection, reg TunnelRegistry, agentMode plugin.AgentMode) (plugin.NetTransport, error)
Build returns the NetTransport for a connection.
func ReadStreamTarget ¶
ReadStreamTarget reads a target preamble written by WriteStreamTarget.
func ServeGatewayTunnel ¶
ServeGatewayTunnel runs the gateway side of an agent tunnel over an already authenticated WebSocket. The gateway is the yamux *client* (it opens a stream per upstream dial); the in-target agent is the yamux *server* (it accepts each stream and proxies it to the declared target). The connection's dialer is registered for the lifetime of the tunnel and removed when it closes.
It blocks until the tunnel is torn down.
Types ¶
type AgentConnectResponse ¶
type AgentConnectResponse struct {
OK bool `json:"ok"`
Error string `json:"error,omitempty"`
Proxy AgentProxyTarget `json:"proxy,omitzero"`
}
AgentConnectResponse is the gateway's reply to AgentHello. On OK the tunnel switches to multiplexed streaming; otherwise the agent disconnects.
type AgentHello ¶
AgentHello is the first message an agent sends on the connect WebSocket, presenting its enrollment token (never in the URL or query). Forward advertises that the agent understands a per-stream target preamble (see WriteStreamTarget).
type AgentProxyTarget ¶
type AgentProxyTarget struct {
Mode string `json:"mode"`
Address string `json:"address"`
TokenFile string `json:"tokenFile,omitempty"`
CAFile string `json:"caFile,omitempty"`
// Forward: each L4 stream begins with a target preamble the agent dials
// instead of Address. Set only when the plugin opted in and the agent supports it.
Forward bool `json:"forward,omitempty"`
}
AgentProxyTarget tells the agent what local endpoint to expose back. The L7 (http_proxy) fields are generic credential-injection knobs: a token file to turn into a bearer header and a CA file to verify the upstream — no protocol vocabulary, so the agent stays plugin-agnostic.
type Direct ¶
type Direct struct {
// contains filtered or unexported fields
}
Direct dials the target straight from the gateway.
func NewDirect ¶
func NewDirect() *Direct
NewDirect returns a direct transport with a sane dial timeout.
func NewDirectForConnection ¶
func NewDirectForConnection(conn models.Connection) *Direct
func (*Direct) DialContext ¶
DialContext dials the requested address directly.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is the concurrent in-memory tunnel registry.
type TunnelRegistry ¶
TunnelRegistry resolves a live agent dialer for a connection.