Documentation ¶
Overview ¶
Package icepop is a router library for SSH applications. It is intended to be paired with the APIs provided by gliderlabs/ssh and charmbracelet/wish.
Index ¶
- func NewCommandRouter(opts ...CommandRouterOption) *commandRouter
- func NewRoute(h ssh.Handler, mw []wish.Middleware, opts ...RouteOption) *route
- func NewUsernameRouter(opts ...UsernameRouterOption) *usernameRouter
- type CommandRouterOption
- type RouteOption
- type Router
- type SessionHandler
- type UsernameRouterOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCommandRouter ¶
func NewCommandRouter(opts ...CommandRouterOption) *commandRouter
NewCommandRouter returns a ssh.Handler that routes to registered SessionHandlers based on the ssh.Session.Command value. Only the entrypoint, or the first entry of a given command is parsed. All other parameters are ignored.
If the command is not registered, then a configurable message is printed to the user and the session is closed.
func NewRoute ¶
func NewRoute(h ssh.Handler, mw []wish.Middleware, opts ...RouteOption) *route
NewRoute creates an instance of a route, representing a handler and its associated middleware.
func NewUsernameRouter ¶
func NewUsernameRouter(opts ...UsernameRouterOption) *usernameRouter
NewCommandRouter returns a ssh.Handler that routes to registered SessionHandlers based on the ssh.Session.Username value. If the username is not registered, then a configurable message is printed to the user and the session is closed.
Types ¶
type CommandRouterOption ¶
type CommandRouterOption func(r *commandRouter)
CommandRouterOption configures a CommandRouter
func OptCommandNotFoundMessage ¶
func OptCommandNotFoundMessage(msg string) CommandRouterOption
OptCommandNotFoundMessage configures the message sent to the user when the command provided was not registered.
func OptCommandNotProvidedMessage ¶
func OptCommandNotProvidedMessage(msg string) CommandRouterOption
OptCommandNotProvidedMessage configures the message sent to the user when no command was provided.
type RouteOption ¶
type RouteOption func(*route)
RouteOption configures a Route
func OptExecuteMiddlewareInReverse ¶
func OptExecuteMiddlewareInReverse() RouteOption
OptExecuteMiddlewareInReverse indicates that a Route should execute middleware in reverse order relative to how it was defined in source code.
This is a compatibility option for developers who are familiar with how charmbraclete/wish handles middleware.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router is basic Router structure. It can be embedded in custom routers to provide easy access to the Handle method. Custom routers will need to implement methods that use these routes.
func (*Router) Handle ¶
func (r *Router) Handle(path string, sh SessionHandler)
Handle binds a path to a SessionHandler. If a handler already exists, this panics.
func (*Router) HandleFunc ¶ added in v0.0.2
HandleFunc binds a ssh.Handler to a SessionHandler and binds it to path. If a handler already exists, this panics.
func (*Router) HandlerFor ¶
func (r *Router) HandlerFor(path string) (SessionHandler, error)
HandlerFor returns the handler for the given path value, or an error if it does not exist.
type SessionHandler ¶
SessionHandler ∂escribes a ssh.Handler implementation bound to a fixed/known method name.
func NewSessionHandlerFrom ¶
func NewSessionHandlerFrom(handler ssh.Handler) SessionHandler
NewSessionHandlerFrom returns a SessionHandler from an existing Handler. This has a narrow scope of responsibility, aiming to remain compatible with existing ssh.Handler definitions.
type UsernameRouterOption ¶
type UsernameRouterOption func(r *usernameRouter)
UsernameRouterOption configures a CommandRouter
func OptUsernameNotFoundMessage ¶
func OptUsernameNotFoundMessage(msg string) UsernameRouterOption
OptUsernameNotFoundMessage configures the message sent to the user when the username provided was not registered.
func OptUsernameNotProvidedMessage ¶
func OptUsernameNotProvidedMessage(msg string) UsernameRouterOption
OptUsernameNotProvidedMessage configures the message sent to the user when no command was provided.