herots

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2015 License: BSD-2-Clause Imports: 9 Imported by: 0

README

HEROTS

HERald Of The Swarm

Go (golang) package for fast TLS server creation.

go get -u github.com/SpiritOfStallman/herots

For more infomation, please read the doc and look at the examples.

Documentation

Overview

HEROTS HERald Of The Swarm

Package for fast TLS server creation.

Index

Constants

View Source
const (
	LoadKeyPairError      = "herots: load key pair error"
	LoadClientCaCertError = "herots srv: load client CA cert error"
	StartServerError      = "herots srv: start tls server error"
	NoKeyPairLoad         = "herots: no load key pair (use LoadKeyPair func)"
	AcceptConnError       = "herots srv: connection accept error"
)

predefined errors messages

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// Server host.
	// By default server use "127.0.0.1".
	Host string

	// Server port.
	// By default server use "9000".
	Port int

	// Message level provides the opportunity to choose
	// what print to the output.
	//   0 - no messages
	//   1 - errors
	//   2 - info messages
	//   3 - all ("1" + "2")
	// By default server use "2".
	MessageLevel int

	// See http://golang.org/pkg/crypto/tls/#ClientAuthType
	// By default server use tls.RequireAnyClientCert
	TLSAuthType tls.ClientAuthType
}

A Options structure is used to configure a TLS server.

type Server

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

func NewServer

func NewServer() *Server

Return Server struct with predefined options.

func (*Server) Accept

func (h *Server) Accept() (net.Conn, error)

Accept and return connection to server.

func (*Server) AddClientCACert

func (h *Server) AddClientCACert(cert []byte) error

Add client CA certificate to x509.CertPool (tls.Config.ClientCAs).

By default server add cert from server public/private key pair (LoadKeyPair) to cert pool.

func (*Server) Config

func (h *Server) Config(o *Options)

Set herots server options (*Options).

func (*Server) LoadKeyPair

func (h *Server) LoadKeyPair(cert, key []byte) error

Func for load certificate and private key pair.

Public/private key pair require as PEM encoded data.

func (*Server) SetMessagesDst

func (h *Server) SetMessagesDst(dst io.Writer)

Provides the opportunity to choose own destination for herots messages (errors, info, etc).

By default server use os.Stdout.

func (*Server) Start

func (h *Server) Start() error

Start server.

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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