Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DialFn ¶
func UnixDialer ¶
type Mux ¶
type Mux struct {
// contains filtered or unexported fields
}
Mux is a hack to be able to use buildkit's ssh forwarding with things that are not necessarily ssh agents. By default all requests are forwarded to an underlying ssh agent service, but you may register other handlers that will be used based on the request ID.
The SSH forwarding API is called by the buildkit server (into the client) over the session API to deal with forwarding SSH sockets. Buildkit itself does care what the API implementation is as long as it implements the sshforward.SSHServer API. What is used to to provide that API is setup when creating the buildkit client. So you can, as an example, use ProxyHandler for that implementation OR you can use the implementation from buildkit, but you can't use both... unless you use Mux to handle routing requests from buildkit and send to the proper backend based on the socket ID.
func (*Mux) CheckAgent ¶
func (m *Mux) CheckAgent(ctx context.Context, req *sshforward.CheckAgentRequest) (*sshforward.CheckAgentResponse, error)
func (*Mux) ForwardAgent ¶
func (m *Mux) ForwardAgent(stream sshforward.SSH_ForwardAgentServer) error
type MuxOption ¶
type MuxOption func(*Mux)
func WithDefaultHandler ¶
func WithDefaultHandler(srv sshforward.SSHServer) MuxOption
WithDefaultHandler sets the default handler for all requests that do not match any registered route.
func WithMuxRoute ¶
func WithMuxRoute(prefix string, srv sshforward.SSHServer) MuxOption
WithMuxRoute registers a new route with the given prefix. The prefix is used to match incoming requests.
type PipeListener ¶
type PipeListener struct {
// contains filtered or unexported fields
}
PipeListener is a net.Listener that uses net.Pipe to create connections and is useful for in-memory ProxyHandler implementations.
PipelListener can be created using the zero value.
func (*PipeListener) Addr ¶
func (pl *PipeListener) Addr() net.Addr
func (*PipeListener) Close ¶
func (pl *PipeListener) Close() error
func (*PipeListener) Dialer ¶
Dialer implements the [DialerFn] type for ProxyHandler.
type ProxyConfig ¶
type ProxyConfig struct {
// ID is the identifier for the proxy connection.
// If empty, the default ID will be used.
// This must be unique across all proxies in a single [ProxyHandler] instance.
//
// This is the ID that the client uses to identify the socket it wants to forward.
// e.g. docker build --ssh <id>[=<socket-path>] ...
ID string
// Dialer is the function that will be used to establish a connection to the
// proxy target.
Dialer DialFn
}
type ProxyHandler ¶
type ProxyHandler struct {
// contains filtered or unexported fields
}
ProxyHandler implements the sshforward.SSHServer interface It can be used to create a raw proxy over buildkit's SSH forwarding mechanism.
Create one with NewProxyHandler
func NewProxyHandler ¶
func NewProxyHandler(configs []ProxyConfig) (*ProxyHandler, error)
func (*ProxyHandler) CheckAgent ¶
func (h *ProxyHandler) CheckAgent(ctx context.Context, req *sshforward.CheckAgentRequest) (*sshforward.CheckAgentResponse, error)
CheckAgent checks if a connection exists for the given ID.
Buildkit will call this method to verify if the agent is available before attempting to forward it.
func (*ProxyHandler) ForwardAgent ¶
func (h *ProxyHandler) ForwardAgent(stream sshforward.SSH_ForwardAgentServer) error
ForwardAgent creates a bi-directional stream with the caller.
Messages on the stream are used to encapsulate the raw data to be forwarded between the client and the target proxy connection.
The ID of the connection is determined by the metadata in the context using the sshforward.KeySSHID key. If not set, the default ID will be used.
func (*ProxyHandler) Register ¶
func (h *ProxyHandler) Register(srv *grpc.Server)
Register registers the ProxyHandler with the given gRPC server.
This is what allows the ProxyHandler to act as a session.Attachable service to be used with a buildkit client. In this case the ProxyHandler will be run as a GRPC service on the client which buildkit will connect to to establish the connection to the proxy target (using the ProxyHandler.ForwardAgent method).