stream

package
v0.0.0-...-abf550e Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2020 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoTLS           = errors.New("no valid tls configuration")
	ErrNotTCP          = errors.New("no tcp address")
	ErrNotAdvertisable = errors.New("address not advertisable")
)

common errors

Functions

This section is empty.

Types

type Config

type Config struct {

	// CAPath is a path to the current certificate authority file, used to verify others on the TLS connections.
	CAPath string

	// CertPath is a path to the current TLS certificate.
	CertPath string

	// KeyPath is a path to the current TLS key.
	KeyPath string
}

Config is the config used to create a tls.Config It will use mutual auth and will verify server hostname

func (*Config) KeyPair

func (c *Config) KeyPair() (*tls.Certificate, error)

KeyPair is used to open and parse a certificate and key pair.

type GRPCServiceRegister

type GRPCServiceRegister func(*grpc.Server)

GRPCServiceRegister is a registering function for GRPC services.

type TLSConfigurator

type TLSConfigurator struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

TLSConfigurator holds a config and is responsible for generating all *tls.Config.

func NewTCPTransport

func NewTCPTransport(addr string, maxPool int, timeout time.Duration, logger *logging.Logging, cert, key, ca string, grpcServiceRegister GRPCServiceRegister) (*raft.NetworkTransport, *TLSConfigurator, error)

NewTCPTransport returns a TLSStreamer for TLS node communications

func NewTLSConfigurator

func NewTLSConfigurator(config *Config) *TLSConfigurator

NewTLSConfigurator creates a new TLSConfigurator with the provided configuration.

func (*TLSConfigurator) AppendCAToPool

func (c *TLSConfigurator) AppendCAToPool(pool *x509.CertPool) error

AppendCAToPool adds a new CA certificate to the pool

func (*TLSConfigurator) IncomingTLSConfig

func (c *TLSConfigurator) IncomingTLSConfig() (config *tls.Config, err error)

IncomingTLSConfig generates a TLS configuration for incoming requests.

func (*TLSConfigurator) OutgoingTLSConfig

func (c *TLSConfigurator) OutgoingTLSConfig() (config *tls.Config, err error)

OutgoingTLSConfig is the TLS configuration for outgoing requests.

type TLSStreamer

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

TLSStreamer is a custom transport raft.StreamLayer for node communications using TLS

func NewTCPStream

func NewTCPStream(addr string, tlsConfigurator *TLSConfigurator, logger *logging.Logging, grpcServiceRegister GRPCServiceRegister) (*TLSStreamer, error)

NewTCPStream returns a custom transport layer for TLS communications

func (*TLSStreamer) Accept

func (t *TLSStreamer) Accept() (c net.Conn, err error)

Accept implements the net.Listener interface

func (*TLSStreamer) Addr

func (t *TLSStreamer) Addr() net.Addr

Addr implements the net.Listener interface.

func (*TLSStreamer) Close

func (t *TLSStreamer) Close() (err error)

Close implements the net.Listener interface

func (*TLSStreamer) Dial

func (t *TLSStreamer) Dial(address raft.ServerAddress, timeout time.Duration) (net.Conn, error)

Dial implements the StreamLayer interface.

Jump to

Keyboard shortcuts

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