Documentation ¶
Index ¶
- Constants
- func FindFreeTCPPort() (int, error)
- func IsPortUnavailable(port int) bool
- func RegisterPlugin(p *sdk.Plugin, opts PluginOpts) error
- type FindPortForwardSessionRequest
- type Manager
- func (m *Manager) ClosePortForwardSession(_ *types.PluginContext, sessionID string) (*PortForwardSession, error)
- func (m *Manager) FindPortForwardSessions(_ *types.PluginContext, req FindPortForwardSessionRequest) ([]*PortForwardSession, error)
- func (m *Manager) GetPortForwardSession(_ *types.PluginContext, sessionID string) (*PortForwardSession, error)
- func (m *Manager) GetSupportedPortForwardTargets(_ *types.PluginContext) []string
- func (m *Manager) ListPortForwardSessions(_ *types.PluginContext) ([]*PortForwardSession, error)
- func (m *Manager) StartPortForwardSession(ctx *types.PluginContext, opts PortForwardSessionOptions) (*PortForwardSession, error)
- type Plugin
- type PluginClient
- func (p *PluginClient) ClosePortForwardSession(ctx *types.PluginContext, sessionID string) (*PortForwardSession, error)
- func (p *PluginClient) FindPortForwardSessions(ctx *types.PluginContext, req FindPortForwardSessionRequest) ([]*PortForwardSession, error)
- func (p *PluginClient) GetPortForwardSession(ctx *types.PluginContext, sessionID string) (*PortForwardSession, error)
- func (p *PluginClient) GetSupportedPortForwardTargets(ctx *types.PluginContext) []string
- func (p *PluginClient) ListPortForwardSessions(ctx *types.PluginContext) ([]*PortForwardSession, error)
- func (p *PluginClient) StartPortForwardSession(ctx *types.PluginContext, opts PortForwardSessionOptions) (*PortForwardSession, error)
- type PluginOpts
- type PluginServer
- func (s *PluginServer) ClosePortForwardSession(ctx context.Context, in *proto.PortForwardSessionByIdRequest) (*proto.PortForwardSessionByIdResponse, error)
- func (s *PluginServer) FindPortForwardSessions(ctx context.Context, in *proto.FindPortForwardSessionRequest) (*proto.PortForwardSessionListResponse, error)
- func (s *PluginServer) GetPortForwardSession(ctx context.Context, in *proto.PortForwardSessionByIdRequest) (*proto.PortForwardSessionByIdResponse, error)
- func (s *PluginServer) GetSupportedPortForwardTargets(ctx context.Context, _ *emptypb.Empty) (*proto.GetSupportedPortForwardTargetsResponse, error)
- func (s *PluginServer) ListPortForwardSessions(ctx context.Context, _ *emptypb.Empty) (*proto.PortForwardSessionListResponse, error)
- func (s *PluginServer) StartPortForwardSession(ctx context.Context, in *proto.PortForwardSessionOptions) (*proto.PortForwardSessionByIdResponse, error)
- type PortForwardConnectionType
- type PortForwardProtocol
- type PortForwardProvider
- type PortForwardResourceConnection
- func (c *PortForwardResourceConnection) ToProto() *proto.PortForwardResourceConnection
- func (c *PortForwardResourceConnection) ToSessionOptionsProto() *proto.PortForwardSessionOptions_ResourceConnection
- func (c *PortForwardResourceConnection) ToSessionProto() *proto.PortForwardSession_ResourceConnection
- type PortForwardSession
- type PortForwardSessionEncryption
- type PortForwardSessionOptions
- type PortForwardStaticConnection
- type Provider
- type ResourcePortForwardHandlerOpts
- type ResourcePortForwarder
- type SessionState
- type StaticPortForwardHandlerOpts
- type StaticPortForwarder
Constants ¶
const (
PluginID = "networker"
)
Variables ¶
This section is empty.
Functions ¶
func FindFreeTCPPort ¶
FindFreePort finds an available port by letting the OS pick a free port.
func IsPortUnavailable ¶
IsPortUnavailable checks if a port is unavailable (i.e., in use).
func RegisterPlugin ¶
func RegisterPlugin( p *sdk.Plugin, opts PluginOpts, ) error
Types ¶
type FindPortForwardSessionRequest ¶
type FindPortForwardSessionRequest struct { ResourceID string `json:"resource_id"` ConnectionID string `json:"connection_id"` }
func NewFindPortForwardSessionRequestFromProto ¶
func NewFindPortForwardSessionRequestFromProto( p *proto.FindPortForwardSessionRequest, ) FindPortForwardSessionRequest
func (FindPortForwardSessionRequest) ToProto ¶
func (p FindPortForwardSessionRequest) ToProto() *proto.FindPortForwardSessionRequest
type Manager ¶
Manager manages the lifecycle of networker actions, such as port forwarding sessions.
func NewManager ¶
func NewManager( settingsProvider settings.Provider, opts PluginOpts, ) *Manager
func (*Manager) ClosePortForwardSession ¶
func (m *Manager) ClosePortForwardSession( _ *types.PluginContext, sessionID string, ) (*PortForwardSession, error)
func (*Manager) FindPortForwardSessions ¶
func (m *Manager) FindPortForwardSessions( _ *types.PluginContext, req FindPortForwardSessionRequest, ) ([]*PortForwardSession, error)
func (*Manager) GetPortForwardSession ¶
func (m *Manager) GetPortForwardSession( _ *types.PluginContext, sessionID string, ) (*PortForwardSession, error)
func (*Manager) GetSupportedPortForwardTargets ¶
func (m *Manager) GetSupportedPortForwardTargets(_ *types.PluginContext) []string
func (*Manager) ListPortForwardSessions ¶
func (m *Manager) ListPortForwardSessions(_ *types.PluginContext) ([]*PortForwardSession, error)
func (*Manager) StartPortForwardSession ¶
func (m *Manager) StartPortForwardSession( ctx *types.PluginContext, opts PortForwardSessionOptions, ) (*PortForwardSession, error)
type PluginClient ¶
type PluginClient struct {
// contains filtered or unexported fields
}
func (*PluginClient) ClosePortForwardSession ¶
func (p *PluginClient) ClosePortForwardSession( ctx *types.PluginContext, sessionID string, ) (*PortForwardSession, error)
func (*PluginClient) FindPortForwardSessions ¶
func (p *PluginClient) FindPortForwardSessions( ctx *types.PluginContext, req FindPortForwardSessionRequest, ) ([]*PortForwardSession, error)
FindPortForwardSessions returns all of the port forward sessions that match the given request.
func (*PluginClient) GetPortForwardSession ¶
func (p *PluginClient) GetPortForwardSession( ctx *types.PluginContext, sessionID string, ) (*PortForwardSession, error)
GetPortForwardSession returns a port forward session by ID.
func (*PluginClient) GetSupportedPortForwardTargets ¶
func (p *PluginClient) GetSupportedPortForwardTargets(ctx *types.PluginContext) []string
GetSupportedPortForwardTargets returns the list of targets that are supported by this plugin for port forwarding.
func (*PluginClient) ListPortForwardSessions ¶
func (p *PluginClient) ListPortForwardSessions( ctx *types.PluginContext, ) ([]*PortForwardSession, error)
ListPortForwardSessions returns all of the port forward sessions.
func (*PluginClient) StartPortForwardSession ¶
func (p *PluginClient) StartPortForwardSession( ctx *types.PluginContext, opts PortForwardSessionOptions, ) (*PortForwardSession, error)
type PluginOpts ¶
type PluginOpts struct { // ResourcePortForwarders is a map of resource type to the function that is called to forward a resource's port. ResourcePortForwarders map[string]ResourcePortForwarder // StaticPortForwarders is a map of resource type to the function that is called to forward a static target of some // kind addressable by standard network addresses. StaticPortForwarders map[string]StaticPortForwarder }
type PluginServer ¶
type PluginServer struct { Impl Provider // contains filtered or unexported fields }
func (*PluginServer) ClosePortForwardSession ¶
func (s *PluginServer) ClosePortForwardSession( ctx context.Context, in *proto.PortForwardSessionByIdRequest, ) (*proto.PortForwardSessionByIdResponse, error)
func (*PluginServer) FindPortForwardSessions ¶
func (s *PluginServer) FindPortForwardSessions( ctx context.Context, in *proto.FindPortForwardSessionRequest, ) (*proto.PortForwardSessionListResponse, error)
func (*PluginServer) GetPortForwardSession ¶
func (s *PluginServer) GetPortForwardSession( ctx context.Context, in *proto.PortForwardSessionByIdRequest, ) (*proto.PortForwardSessionByIdResponse, error)
func (*PluginServer) GetSupportedPortForwardTargets ¶
func (s *PluginServer) GetSupportedPortForwardTargets( ctx context.Context, _ *emptypb.Empty, ) (*proto.GetSupportedPortForwardTargetsResponse, error)
func (*PluginServer) ListPortForwardSessions ¶
func (s *PluginServer) ListPortForwardSessions( ctx context.Context, _ *emptypb.Empty, ) (*proto.PortForwardSessionListResponse, error)
func (*PluginServer) StartPortForwardSession ¶
func (s *PluginServer) StartPortForwardSession( ctx context.Context, in *proto.PortForwardSessionOptions, ) (*proto.PortForwardSessionByIdResponse, error)
type PortForwardConnectionType ¶
type PortForwardConnectionType string
const ( PortForwardConnectionTypeResource PortForwardConnectionType = "RESOURCE" PortForwardConnectionTypeStatic PortForwardConnectionType = "STATIC" )
type PortForwardProtocol ¶
type PortForwardProtocol string
const ( PortForwardProtocolTCP PortForwardProtocol = "TCP" PortForwardProtocolUDP PortForwardProtocol = "UDP" )
func PortForwardProtocolFromProto ¶
func PortForwardProtocolFromProto( p proto.PortForwardProtocol, ) PortForwardProtocol
func (PortForwardProtocol) String ¶
func (p PortForwardProtocol) String() string
func (PortForwardProtocol) ToProto ¶
func (p PortForwardProtocol) ToProto() proto.PortForwardProtocol
type PortForwardProvider ¶
type PortForwardProvider interface { GetSupportedPortForwardTargets(*types.PluginContext) []string GetPortForwardSession(*types.PluginContext, string) (*PortForwardSession, error) ListPortForwardSessions(*types.PluginContext) ([]*PortForwardSession, error) FindPortForwardSessions( *types.PluginContext, FindPortForwardSessionRequest, ) ([]*PortForwardSession, error) StartPortForwardSession( *types.PluginContext, PortForwardSessionOptions, ) (*PortForwardSession, error) ClosePortForwardSession(*types.PluginContext, string) (*PortForwardSession, error) }
type PortForwardResourceConnection ¶
type PortForwardResourceConnection struct { ResourceData map[string]interface{} `json:"resource_data"` ConnectionID string `json:"connection_id"` PluginID string `json:"plugin_id"` ResourceID string `json:"resource_id"` ResourceKey string `json:"resource_key"` }
PortForwardSessionConnectionOptions represents the options for a session connection.
func PortForwardResourceConnectionFromProto ¶
func PortForwardResourceConnectionFromProto( o *proto.PortForwardResourceConnection, ) PortForwardResourceConnection
func (*PortForwardResourceConnection) ToProto ¶
func (c *PortForwardResourceConnection) ToProto() *proto.PortForwardResourceConnection
func (*PortForwardResourceConnection) ToSessionOptionsProto ¶
func (c *PortForwardResourceConnection) ToSessionOptionsProto() *proto.PortForwardSessionOptions_ResourceConnection
func (*PortForwardResourceConnection) ToSessionProto ¶
func (c *PortForwardResourceConnection) ToSessionProto() *proto.PortForwardSession_ResourceConnection
type PortForwardSession ¶
type PortForwardSession struct { CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` Connection interface{} `json:"connection"` Labels map[string]string `json:"labels"` ID string `json:"id"` Protocol PortForwardProtocol `json:"protocol"` State SessionState `json:"state"` ConnectionType string `json:"connection_type"` Encryption PortForwardSessionEncryption `json:"encryption"` SourcePort int `json:"source_port"` DestinationPort int `json:"destination_port"` }
PortForwardSession represents a session between a forwarding target and the host that initiated the session.
func NewPortForwardSessionFromProto ¶
func NewPortForwardSessionFromProto(s *proto.PortForwardSession) *PortForwardSession
NewPortForwardSessionFromProto creates a PortForwardSession from a protobuf.
func (*PortForwardSession) ToProto ¶
func (s *PortForwardSession) ToProto() *proto.PortForwardSession
type PortForwardSessionEncryption ¶
type PortForwardSessionEncryption struct { Algorithm string `json:"algorithm"` Key string `json:"key"` Enabled bool `json:"enabled"` }
PortForwardSessionEncryption represents the options for a session encryption configuration.
func PortForwardSessionEncryptionFromProto ¶
func PortForwardSessionEncryptionFromProto( o *proto.PortForwardSessionEncryption, ) PortForwardSessionEncryption
func (*PortForwardSessionEncryption) ToProto ¶
func (o *PortForwardSessionEncryption) ToProto() *proto.PortForwardSessionEncryption
type PortForwardSessionOptions ¶
type PortForwardSessionOptions struct { Connection interface{} `json:"connection"` Labels map[string]string `json:"labels"` Params map[string]string `json:"params"` Protocol PortForwardProtocol `json:"protocol"` ConnectionType PortForwardConnectionType `json:"connection_type"` Encryption PortForwardSessionEncryption `json:"encryption"` SourcePort int `json:"source_port"` DestinationPort int `json:"destination_port"` }
PortForwardSessionOptions represents the options for creating a new forwarding session.
func NewPortForwardSessionOptionsFromProto ¶
func NewPortForwardSessionOptionsFromProto( o *proto.PortForwardSessionOptions, ) *PortForwardSessionOptions
func (*PortForwardSessionOptions) ToProto ¶
func (o *PortForwardSessionOptions) ToProto() *proto.PortForwardSessionOptions
type PortForwardStaticConnection ¶
type PortForwardStaticConnection struct {
Address string `json:"address"`
}
func PortForwardStaticConnectionFromProto ¶
func PortForwardStaticConnectionFromProto( o *proto.PortForwardStaticConnection, ) PortForwardStaticConnection
func (*PortForwardStaticConnection) ToProto ¶
func (c *PortForwardStaticConnection) ToProto() *proto.PortForwardStaticConnection
func (*PortForwardStaticConnection) ToSessionOptionsProto ¶
func (c *PortForwardStaticConnection) ToSessionOptionsProto() *proto.PortForwardSessionOptions_StaticConnection
func (*PortForwardStaticConnection) ToSessionProto ¶
func (c *PortForwardStaticConnection) ToSessionProto() *proto.PortForwardSession_StaticConnection
type Provider ¶
type Provider interface { PortForwardProvider }
Provider is the interface satisfied by the plugin server and client to provide the networker functionality.
type ResourcePortForwardHandlerOpts ¶
type ResourcePortForwardHandlerOpts struct { Resource PortForwardResourceConnection `json:"resource"` Options PortForwardSessionOptions `json:"options"` }
type ResourcePortForwarder ¶
type ResourcePortForwarder func(*types.PluginContext, ResourcePortForwardHandlerOpts) (string, error)
ResourcePortForwarder is responsible for initiating a port forwarding session given the options coming from the plugin describing a resource to start a port forwarding session for. It should return a UUID that uniquely identifies the session, or an error if any occurred.
The Context passed in via the plugin context will be canceled when the port forwarding session is meant to be terminated. This is the plugin's cue to stop the port forwarding session.
type SessionState ¶
type SessionState string
const ( SessionStateActive SessionState = "ACTIVE" SessionStatePaused SessionState = "PAUSED" SessionStateStopped SessionState = "STOPPED" SessionStateFailed SessionState = "FAILED" )
func (SessionState) String ¶
func (s SessionState) String() string
func (SessionState) ToProto ¶
func (s SessionState) ToProto() proto.PortForwardSession_SessionState
type StaticPortForwardHandlerOpts ¶
type StaticPortForwardHandlerOpts struct { Static PortForwardStaticConnection `json:"static"` Options PortForwardSessionOptions `json:"options"` }
type StaticPortForwarder ¶
type StaticPortForwarder func(*types.PluginContext, StaticPortForwardHandlerOpts) (string, error)
StaticPortForwarder is responsible for initiating a port forwarding session given the options coming from the plugin describing a static target to initiate a port forward for. It should return a UUID that uniquely identifies the session, or an error if any occurred.
The Context passed in via the plugin context will be canceled when the port forwarding session is meant to be terminated. This is the plugin's cue to stop the port forwarding session.