core: github.com/katzenpost/core/thwack Index | Files

package thwack

import "github.com/katzenpost/core/thwack"

Package thwack provides a trivial text based management protocol.

Index

Package Files

thwack.go

type CommandHandlerFn Uses

type CommandHandlerFn func(*Conn, string) error

CommandHandlerFn is a command handler hook function. Each handler function is responsible for fully handling a command and sending a response, and MUST NOT return an error unless the connection is to be closed immediately.

type Config Uses

type Config struct {
    // Net and Addr specify the network and address of the server instance.
    Net, Addr string

    // ServiceName is the service name to be displayed in the greeting banner.
    ServiceName string

    // LogModule is the module for the Server's Logger.
    LogModule string

    // NewLoggerFn is the function to call to construct per-connection Loggers.
    NewLoggerFn func(string) *logging.Logger
}

Config is a thwack Server configuration.

type Conn Uses

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

Conn is a thwack connection instance.

func (*Conn) Log Uses

func (c *Conn) Log() *logging.Logger

Log returns the per-connection logging.Logger.

func (*Conn) Reader Uses

func (c *Conn) Reader() *textproto.Reader

Reader returns the underlying textproto.Reader.

func (*Conn) SetState Uses

func (c *Conn) SetState(state interface{})

SetState sets the per-connection state.

func (*Conn) State Uses

func (c *Conn) State() interface{}

State returns the per-connection state.

func (*Conn) WriteReply Uses

func (c *Conn) WriteReply(status StatusCode) error

WriteReply is a convenience routine for sending a StatusCode and human readable reason to the peer.

func (*Conn) Writer Uses

func (c *Conn) Writer() *textproto.Writer

Writer returns the underlying textproto.Writer.

type Server Uses

type Server struct {
    sync.WaitGroup
    // contains filtered or unexported fields
}

Server is a thwack server instance.

func New Uses

func New(cfg *Config) (*Server, error)

New constructs a new Server, but does not start the listener.

func (*Server) Halt Uses

func (s *Server) Halt()

Halt halts the Server.

func (*Server) RegisterCommand Uses

func (s *Server) RegisterCommand(cmd string, fn CommandHandlerFn)

RegisterCommand sets the handler function for the specified command. This MUST NOT be called after the Server has been started with Start().

func (*Server) Start Uses

func (s *Server) Start() error

Start starts the Server's listener and starts accepting connections.

type StatusCode Uses

type StatusCode int

StatusCode is a thwack status code.

const (
    // StatusServiceReady is the status code that is always sent on a new
    // connection to signify that the management interface is ready.
    StatusServiceReady StatusCode = 220

    // StatusOk is the status code returned to signal successful completion
    // of a command.
    StatusOk StatusCode = 250

    // StatusUnknownCommand is the status code returned when a command is
    // unknown.
    StatusUnknownCommand StatusCode = 500

    // StatusSyntaxError is the status code returned when the syntax of a
    // command or it's argument(s) is invalid.
    StatusSyntaxError StatusCode = 501

    // StatusTransactionFailed is the status code returned when the command
    // has failed.
    StatusTransactionFailed StatusCode = 554
)

Package thwack imports 7 packages (graph) and is imported by 6 packages. Updated 2018-02-23. Refresh now. Tools for package owners.