sshh

package module
v0.0.0-...-bfd235e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2015 License: Apache-2.0 Imports: 11 Imported by: 2

README

sshh Build Status Coverage Status

An SSH Handler library which makes it easy to implement SSH servers

Documentation

Index

Constants

View Source
const (
	ChannelAcceptError ssh.RejectionReason = 1000
	InvalidChannelType ssh.RejectionReason = 1001
	InvalidQueryParams ssh.RejectionReason = 1002
	HostNotSupported   ssh.RejectionReason = 1003
	SchemeNotSupported ssh.RejectionReason = 1004
	UserNotSupported   ssh.RejectionReason = 1005
	ChannelHandleError ssh.RejectionReason = 1006
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	sync.Mutex

	// Context allows for lifecycle management of the server.
	Context context.Context

	// Deadline is the maximum time the listener will block
	// between connections. As a consequence, this duration
	// also sets the max length of time the SSH server will
	// be unresponsive before shutting down.
	Deadline time.Duration

	// Dispatcher handles all open channel requests and dispatches them to a handler.
	Dispatcher Dispatcher

	// Consumer processes all global ssh.Requests for the life of the connection.
	Consumer RequestConsumer

	// Logger logs errors and debug output for the SSH server.
	Logger log.Logger

	// Bind specifies the Bind address the SSH server will listen on.
	Bind string

	// PrivateKey is added to the SSH config as a host key.
	PrivateKey ssh.Signer

	// AuthLogCallback, if non-nil, is called to log all authentication
	// attempts.
	AuthLogCallback func(conn ssh.ConnMetadata, method string, err error)

	// PasswordCallback, if non-nil, is called when a user
	// attempts to authenticate using a password.
	PasswordCallback func(conn ssh.ConnMetadata, password []byte) (*ssh.Permissions, error)

	// PublicKeyCallback, if non-nil, is called when a client attempts public
	// key authentication. It must return true if the given public key is
	// valid for the given user. For example, see CertChecker.Authenticate.
	PublicKeyCallback func(ssh.ConnMetadata, ssh.PublicKey) (*ssh.Permissions, error)
	// contains filtered or unexported fields
}

Config is used to setup the SSHServer, including the server config and the SSHHandlers.

func (*Config) SSHConfig

func (c *Config) SSHConfig() *ssh.ServerConfig

SSHConfig returns an SSH server configuration. If the AuthLogCallback is nil at the time this method is called, the default function will be used.

type Context

type Context struct {
	ChannelType string
	Context     context.Context
	Channel     ssh.Channel
	Requests    <-chan *ssh.Request
}

type Dispatcher

type Dispatcher interface {
	Dispatch(context.Context, *ssh.ServerConn, ssh.NewChannel)
}

type Handler

type Handler interface {
	Handle(*Context) error
}

type HandlerFunc

type HandlerFunc func(*Context) error

type PanicHandler

type PanicHandler interface {
	Handle(*Context, interface{})
}

type RequestConsumer

type RequestConsumer interface {
	Consume(<-chan *ssh.Request)
}

type SSHServer

type SSHServer struct {
	Addr *net.TCPAddr
	// contains filtered or unexported fields
}

SSHServer handles all the incoming connections as well as handler dispatch.

func New

func New(cfg *Config) (server SSHServer, err error)

New creates a new server with the given config. The server will call `cfg.SSHConfig()` to setup the server. If an error occurs it will be returned. If the Bind address is empty or invalid an error will be returned. If there is an error starting the TCP server, the error will be returned.

func (*SSHServer) Start

func (s *SSHServer) Start()

Start starts accepting client connections. This method is non-blocking.

func (*SSHServer) Stop

func (s *SSHServer) Stop()

Stop stops the server and kills all goroutines. This method is blocking.

type SimpleDispatcher

type SimpleDispatcher struct {
	Logger       log.Logger
	Handlers     map[string]Handler
	PanicHandler PanicHandler
	NotFound     Handler
}

func (*SimpleDispatcher) Dispatch

func (u *SimpleDispatcher) Dispatch(c context.Context, conn *ssh.ServerConn, ch ssh.NewChannel)

type UrlDispatcher

type UrlDispatcher struct {
	Logger log.Logger
	Router *router.Router
}

func (*UrlDispatcher) Dispatch

func (u *UrlDispatcher) Dispatch(c context.Context, conn *ssh.ServerConn, ch ssh.NewChannel)

Directories

Path Synopsis
Godeps
_workspace/src/github.com/mattn/go-isatty
Package isatty implements interface to isatty
Package isatty implements interface to isatty
_workspace/src/github.com/mgutz/ansi
Package ansi is a small, fast library to create ANSI colored strings and codes.
Package ansi is a small, fast library to create ANSI colored strings and codes.
_workspace/src/github.com/stretchr/objx
objx - Go package for dealing with maps, slices, JSON and other data.
objx - Go package for dealing with maps, slices, JSON and other data.
_workspace/src/github.com/stretchr/testify/assert
A set of comprehensive testing tools for use with the normal Go testing system.
A set of comprehensive testing tools for use with the normal Go testing system.
_workspace/src/github.com/stretchr/testify/mock
Provides a system by which it is possible to mock your objects and verify calls are happening as expected.
Provides a system by which it is possible to mock your objects and verify calls are happening as expected.
_workspace/src/github.com/stretchr/testify/suite
The suite package contains logic for creating testing suite structs and running the methods on those structs as tests.
The suite package contains logic for creating testing suite structs and running the methods on those structs as tests.
_workspace/src/golang.org/x/crypto/ssh
Package ssh implements an SSH client and server.
Package ssh implements an SSH client and server.
_workspace/src/golang.org/x/crypto/ssh/agent
Package agent implements a client to an ssh-agent daemon.
Package agent implements a client to an ssh-agent daemon.
_workspace/src/golang.org/x/crypto/ssh/terminal
Package terminal provides support functions for dealing with terminals, as commonly found on UNIX systems.
Package terminal provides support functions for dealing with terminals, as commonly found on UNIX systems.
_workspace/src/golang.org/x/crypto/ssh/test
This package contains integration tests for the golang.org/x/crypto/ssh package.
This package contains integration tests for the golang.org/x/crypto/ssh package.
_workspace/src/golang.org/x/net/context
Package context defines the Context type, which carries deadlines, cancelation signals, and other request-scoped values across API boundaries and between processes.
Package context defines the Context type, which carries deadlines, cancelation signals, and other request-scoped values across API boundaries and between processes.
_workspace/src/gopkg.in/tomb.v2
The tomb package handles clean goroutine tracking and termination.
The tomb package handles clean goroutine tracking and termination.
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL