ssh

package
v0.0.0-...-45c0216 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2015 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SignInIdLength      = 4
	SignInSecretLength  = 16
	SessionIdLength     = 8
	SessionSecretLength = 40
	CsrfTokenLength     = 40
)

Variables

View Source
var ASCII = []string{"    d8b",
	"     ?88",
	"      88b",
	"      888  d88' d888b8b  ?88,.d88b,?88,.d88b, d888b8b",
	"      888bd8P' d8P' ?88   ?88'  ?88 ?88'  ?88d8P' ?88",
	"     d88888b   88b  ,88b   88b  d8P  88b  d8P88b  ,88b",
	"    d88'  ?88b, ?88P' 88b  888888P'  888888P' ?88P' 88b",
	"                           88P'      88P'",
	"                          d88       d88",
	"                          ?8P       ?8P"}
View Source
var DefaultColorCodes = ColorCodes{
	Black:   []byte{keyEscape, '[', '3', '0', 'm'},
	Red:     []byte{keyEscape, '[', '3', '1', 'm'},
	Green:   []byte{keyEscape, '[', '3', '2', 'm'},
	Yellow:  []byte{keyEscape, '[', '3', '3', 'm'},
	Blue:    []byte{keyEscape, '[', '3', '4', 'm'},
	Magenta: []byte{keyEscape, '[', '3', '5', 'm'},
	Cyan:    []byte{keyEscape, '[', '3', '6', 'm'},
	White:   []byte{keyEscape, '[', '3', '7', 'm'},

	LightGrey:    []byte{keyEscape, '[', '9', '0', 'm'},
	LightRed:     []byte{keyEscape, '[', '9', '1', 'm'},
	LightGreen:   []byte{keyEscape, '[', '9', '2', 'm'},
	LightYellow:  []byte{keyEscape, '[', '9', '3', 'm'},
	LightBlue:    []byte{keyEscape, '[', '9', '4', 'm'},
	LightMagenta: []byte{keyEscape, '[', '9', '5', 'm'},
	LightCyan:    []byte{keyEscape, '[', '9', '6', 'm'},
	LightWhite:   []byte{keyEscape, '[', '9', '7', 'm'},
	Reset:        []byte{keyEscape, '[', '0', 'm'},
}

ANSI colors

Functions

func GetMessage

func GetMessage(w io.Writer, colors ColorCodes)

LoginMessage writes a message at login

Types

type AuthConnectionHandler

type AuthConnectionHandler func(*ssh.ServerConn) bool

AuthConnectionHandler validates connections against user accounts

type ColorCodes

type ColorCodes struct {
	// Foreground colors
	Black, Red, Green, Yellow, Blue, Magenta, Cyan, White []byte

	// Light Foreground colors
	LightGrey, LightRed, LightGreen, LightYellow, LightBlue, LightMagenta, LightCyan, LightWhite []byte

	// Reset all attributes
	Reset []byte
}

type Conversation

type Conversation struct {
	Quotes []Quote
}

Conversation displays a list of quotes

func (Conversation) Write

func (c Conversation) Write(w io.Writer, colors ColorCodes)

Write actually writes the message to the terminal

type Executor

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

Executor executes successfully parsed queries

func (*Executor) Execute

func (e *Executor) Execute(w *ResponseWriter, stmt skl.Statement)

Execute processes each statement

type Message

type Message interface {
	Write(w io.Writer, colors ColorCodes)
}

type Quote

type Quote struct {
	Color  []byte
	Author string
	Text   string
}

Quote is a message with an author

func (Quote) Write

func (q Quote) Write(w io.Writer, colors ColorCodes)

type ResponseWriter

type ResponseWriter struct {
	Colors ColorCodes
	Writer io.Writer
}

ResponseWriter writes data and status codes to the client

func (*ResponseWriter) Fail

func (r *ResponseWriter) Fail(code StatusCode, format string, args ...interface{})

Fail writes the error status code to the Writer

func (*ResponseWriter) Success

func (r *ResponseWriter) Success(code StatusCode, format string, args ...interface{})

Success writes the status code to the Writer

func (*ResponseWriter) Write

func (r *ResponseWriter) Write(data []byte) (int, error)

Write is a pass through function into the underlying Writer

type SSHServer

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

func NewSSHServer

func NewSSHServer(logger log.Logger, sys datamodel.System, privateKey ssh.Signer, roots *x509.CertPool) (server SSHServer, err error)

func (*SSHServer) Run

func (s *SSHServer) Run(logger log.Logger, closer chan<- bool)

func (*SSHServer) Wait

func (s *SSHServer) Wait()

type Session

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

Session provides session and connection related information

type SimpleMessage

type SimpleMessage struct {
	Text string
}

func (SimpleMessage) Write

func (s SimpleMessage) Write(w io.Writer, colors ColorCodes)

type StatusCode

type StatusCode int
const (
	OK StatusCode = iota + 2000
	NamespaceAlreadyExists
	UserAlreadyExists
)

Success codes

const (
	InternalServerError StatusCode = iota + 5000
	InvalidStatementType
	NamespaceDoesNotExist
	UserDoesNotExist
	CreateNamespaceError
)

Error codes

const (
	Unauthorized StatusCode = iota + 4000
)

Authentication related error codes

type Terminal

type Terminal interface {
	GetPrompt() string
	ResetPrompt()
	SetPrompt(p string)
}

Terminal wraps an ssh.Terminal in order to supply an interface for easy mocking

func NewTerminal

func NewTerminal(term *terminal.Terminal, prompt string) Terminal

NewTerminal creates a new terminal wrapper

Jump to

Keyboard shortcuts

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