server

package
v0.0.0-...-7d94be6 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2016 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventServerStart   string = "server-start"
	EventServerStop           = "server-stop"
	EventServerStarted        = "server-started"
	EventServerStopped        = "server-stopped"
	EventReceiveSignal        = "receive-signal"
)

Event topics

View Source
const (
	TraceAuthentication                    string = "authentication"
	TracePasswordAuthentication                   = "password-authentication"
	TraceRSAAuthentication                        = "rsa-authentication"
	TraceKeyboardInteractiveAuthentication        = "keyboardinteractive-authentication"
	TraceHandshake                                = "handshake"
	TraceChannel                                  = "channel"
	TraceConnect                                  = "connect"
	TraceDisconnect                               = "disconnect"
)

Log topics

Variables

View Source
var (
	ErrUnauthentized = errors.Unauthorized(namespace, "authorization has been refused")
)

Error messages

Functions

This section is empty.

Types

type AuthenticationType

type AuthenticationType int8

AuthenticationType type

const (
	AuthenticationPassword AuthenticationType
	AuthenticationPublicKey
	AuthenticationKeyboardInteractive
)

Authentication types

func (AuthenticationType) String

func (v AuthenticationType) String() string

type Configs

type Configs struct {
	// contains filtered or unexported fields
}

Configs struct

func (*Configs) AuthLogCallback

func (v *Configs) AuthLogCallback(md ssh.ConnMetadata, method string, err error)

AuthLogCallback func

func (*Configs) PasswordCallback

func (v *Configs) PasswordCallback(md ssh.ConnMetadata, pass []byte) (*ssh.Permissions, error)

PasswordCallback func

func (*Configs) PublicKeyCallback

func (v *Configs) PublicKeyCallback(md ssh.ConnMetadata, key ssh.PublicKey) (*ssh.Permissions, error)

PublicKeyCallback func

type Context

type Context struct {
	// contains filtered or unexported fields
}

Context struct

func (*Context) LocalAddr

func (v *Context) LocalAddr() net.Addr

LocalAddr returns local address

func (*Context) RemoteAddr

func (v *Context) RemoteAddr() net.Addr

RemoteAddr returns remote address

func (*Context) T

func (v *Context) T() AuthenticationType

T returns context handle type

type DebugHandler

type DebugHandler func(md ssh.ConnMetadata, method string, err error)

DebugHandler logging handler

type Event

type Event interface {
	Topic() string
	Message() string
	String() string
}

Event interface for secure shell server

func ParseEvent

func ParseEvent(s string) Event

ParseEvent message and return trace object

type Handler

type Handler func(*Context) error

Handler for middleware

type Log

type Log interface {
	Topic() string
	Error() error
	Message() string
	String() string
}

Log interface

func ParseLog

func ParseLog(s string) Log

ParseLog message and return trace object

type Option

type Option func(*Options)

Option func

func ClientAuth

func ClientAuth(b bool) Option

ClientAuth option

func HostKey

func HostKey(k *crypto.PrivateKey) Option

HostKey option

func ID

func ID(s string) Option

ID option

func ListenAddr

func ListenAddr(s string) Option

ListenAddr option

func Metadata

func Metadata(m map[string]string) Option

Metadata option

func PasswordAuthentication

func PasswordAuthentication(b bool) Option

PasswordAuthentication option

func Protocol

func Protocol(v int) Option

Protocol option

func RSAAuthentication

func RSAAuthentication(b bool) Option

RSAAuthentication option

type Options

type Options struct {
	sync.RWMutex
	// Server Id
	ServerID string
	// NoClientAuth is true if clients are allowed to connect without
	// authenticating.
	NoClientAuth bool
	// Enable password authentication
	PasswordAuthentication bool
	// Enable rsa key authentication
	RSAAuthentication bool
	// Secure Shell server listen addr
	ListenAddr string
	// Secure Shell protocol version
	Protocol int
	// HostKeys
	HostKeys []*crypto.PrivateKey
	// Metadata
	Metadata map[string]string
	// Middlewares
	Middlewares []Handler
	// contains filtered or unexported fields
}

Options for Secure Shell

func (*Options) AddHostKey

func (v *Options) AddHostKey(k *crypto.PrivateKey) *Options

AddHostKey to set host private key

func (*Options) AddMiddleware

func (v *Options) AddMiddleware(fs ...Handler) *Options

AddMiddleware to add auth middleware

func (*Options) Changes

func (v *Options) Changes() <-chan struct{}

Changes observer

func (*Options) GetClientAuth

func (v *Options) GetClientAuth() bool

GetClientAuth to return client auth settings

func (*Options) GetHostKeys

func (v *Options) GetHostKeys() []*crypto.PrivateKey

GetHostKeys to return host private key

func (*Options) GetListenAddr

func (v *Options) GetListenAddr() string

GetListenAddr to return listen address

func (*Options) GetMetadata

func (v *Options) GetMetadata(k string) string

GetMetadata to return metadata data

func (*Options) GetMiddlewares

func (v *Options) GetMiddlewares() []Handler

GetMiddlewares to return middlewares

func (*Options) GetPasswordAuthentication

func (v *Options) GetPasswordAuthentication() bool

GetPasswordAuthentication to return password authentication setting

func (*Options) GetProtocol

func (v *Options) GetProtocol() int

GetProtocol to return protocol version

func (*Options) GetRSAAuthentication

func (v *Options) GetRSAAuthentication() bool

GetRSAAuthentication to return rsa authentication setting

func (*Options) GetServerID

func (v *Options) GetServerID() string

GetServerID to return server id

func (*Options) SetClientAuth

func (v *Options) SetClientAuth(enable bool) *Options

SetClientAuth to enable or disable client authentication [true => enable]

func (*Options) SetListenAddr

func (v *Options) SetListenAddr(addr string) *Options

SetListenAddr to set listen port

func (*Options) SetPasswordAuthentication

func (v *Options) SetPasswordAuthentication(enable bool) *Options

SetPasswordAuthentication to enable or disable password authentication

func (*Options) SetProtocol

func (v *Options) SetProtocol(protocol int) *Options

SetProtocol to set secure shell protocol

func (*Options) SetRSAAuthentication

func (v *Options) SetRSAAuthentication(enable bool) *Options

SetRSAAuthentication to enable or disable rsa key authentication

func (*Options) SetServerID

func (v *Options) SetServerID(s string) *Options

SetServerID to set server reference id

type Server

type Server interface {
	Use(...Handler)
	Run() error
	Stop() error
	Started() bool
	Option() *Options
	Subscribe() <-chan Event
	Logging() <-chan Log
}

Server daemon for Secure Shell

func New

func New(opts ...Option) Server

New create secure shell server

type Winsize

type Winsize struct {
	Height, Width uint16
	// contains filtered or unexported fields
}

Winsize

Jump to

Keyboard shortcuts

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