tcp

package
v8.23.4 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package tcp provides the internode communication network layer.

Index

Constants

View Source
const (
	// DefaultTimeout is the default length of time to wait for first byte.
	DefaultTimeout = 30 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	Addr string `json:"address"`
}

Address is a struct for holding network addresses

type Dialer

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

Dialer supports dialing a cluster service.

func NewDialer

func NewDialer(header byte, tlsConfig *tls.Config) *Dialer

NewDialer returns an initialized Dialer.

func (*Dialer) Dial

func (d *Dialer) Dial(addr string, timeout time.Duration) (conn net.Conn, retErr error)

Dial dials the cluster service at the given addr and returns a connection.

type InterfaceDetail

type InterfaceDetail struct {
	Flags           string    `json:"flags"`
	HardwareAddress string    `json:"hardware_address"`
	Addresses       []Address `json:"addresses"`
}

InterfaceDetail is a struct for holding network interface details

type InterfaceStats

type InterfaceStats map[string]InterfaceDetail

InterfaceStats is a map of network interface names to InterfaceDetail

type Layer

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

Layer represents the connection between nodes. It can be both used to make connections to other nodes (client), and receive connections from other nodes (server)

func NewLayer added in v8.13.3

func NewLayer(ln net.Listener, dialer *Dialer) *Layer

NewLayer returns a new instance of Layer.

func (*Layer) Accept

func (l *Layer) Accept() (net.Conn, error)

Accept waits for the next connection.

func (*Layer) Addr

func (l *Layer) Addr() net.Addr

Addr returns the local address for the layer.

func (*Layer) Close

func (l *Layer) Close() error

Close closes the layer.

func (*Layer) Dial

func (l *Layer) Dial(addr string, timeout time.Duration) (net.Conn, error)

Dial creates a new network connection.

type Mux

type Mux struct {

	// The amount of time to wait for the first header byte.
	Timeout time.Duration

	// Out-of-band error logger
	Logger *log.Logger
	// contains filtered or unexported fields
}

Mux multiplexes a network connection.

func NewMutualTLSMux added in v8.13.3

func NewMutualTLSMux(ln net.Listener, adv net.Addr, cert, key, caCert string) (*Mux, error)

NewMutualTLSMux returns a new instance of Mux for ln, and encrypts all traffic using TLS. The server will also verify the client's certificate.

func NewMux

func NewMux(ln net.Listener, adv net.Addr) (*Mux, error)

NewMux returns a new instance of Mux for ln. If adv is nil, then the addr of ln is used.

func NewTLSMux

func NewTLSMux(ln net.Listener, adv net.Addr, cert, key, caCert string, insecure, mutual bool) (*Mux, error)

NewTLSMux returns a new instance of Mux for ln, and encrypts all traffic using TLS. If adv is nil, then the addr of ln is used. If insecure is true, then the server will not verify the client's certificate. If mutual is true, then the server will require the client to present a trusted certificate.

func (*Mux) Listen

func (mux *Mux) Listen(header byte) net.Listener

Listen returns a Listener associated with the given header. Any connection accepted by mux is multiplexed based on the initial header byte.

func (*Mux) Serve

func (mux *Mux) Serve() error

Serve handles connections from ln and multiplexes then across registered listener.

func (*Mux) Stats

func (mux *Mux) Stats() (interface{}, error)

Stats returns status of the mux.

type NameAddress

type NameAddress struct {
	Address string
}

NameAddress wraps a string and implements the net.Listener interface.

func (NameAddress) Network

func (n NameAddress) Network() string

Network returns the network type. Always returns "tcp".

func (NameAddress) String

func (n NameAddress) String() string

String returns the address.

type NetworkReporter

type NetworkReporter struct{}

NetworkReporter is a reporter for network information

func (NetworkReporter) Stats

func (n NetworkReporter) Stats() (map[string]interface{}, error)

Stats returns network interface details

Directories

Path Synopsis
Package pool implements a pool of net.Conn interfaces to manage and reuse them.
Package pool implements a pool of net.Conn interfaces to manage and reuse them.

Jump to

Keyboard shortcuts

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