kappa: github.com/pgrew/kappa/ssh Index | Files

package ssh

import "github.com/pgrew/kappa/ssh"

Index

Package Files

ascii.go codes.go executor.go handler.go messages.go server.go terminal.go writer.go

Constants

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

Variables

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"}
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

func GetMessage Uses

func GetMessage(w io.Writer, colors ColorCodes)

LoginMessage writes a message at login

type AuthConnectionHandler Uses

type AuthConnectionHandler func(*ssh.ServerConn) bool

AuthConnectionHandler validates connections against user accounts

type ColorCodes Uses

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 Uses

type Conversation struct {
    Quotes []Quote
}

Conversation displays a list of quotes

func (Conversation) Write Uses

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

Write actually writes the message to the terminal

type Executor Uses

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

Executor executes successfully parsed queries

func (*Executor) Execute Uses

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

Execute processes each statement

type Message Uses

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

type Quote Uses

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

Quote is a message with an author

func (Quote) Write Uses

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

type ResponseWriter Uses

type ResponseWriter struct {
    Colors ColorCodes
    Writer io.Writer
}

ResponseWriter writes data and status codes to the client

func (*ResponseWriter) Fail Uses

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

Fail writes the error status code to the Writer

func (*ResponseWriter) Success Uses

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

Success writes the status code to the Writer

func (*ResponseWriter) Write Uses

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

Write is a pass through function into the underlying Writer

type SSHServer Uses

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

func NewSSHServer Uses

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

func (*SSHServer) Run Uses

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

func (*SSHServer) Wait Uses

func (s *SSHServer) Wait()

type Session Uses

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

Session provides session and connection related information

type SimpleMessage Uses

type SimpleMessage struct {
    Text string
}

func (SimpleMessage) Write Uses

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

type StatusCode Uses

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 Uses

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 Uses

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

NewTerminal creates a new terminal wrapper

Package ssh imports 16 packages (graph). Updated 2017-04-29. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).