netceptor

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Overview

Package netceptor is the networking layer of Receptor.

Index

Constants

View Source
const (
	// MsgTypeData is a normal data-containing message.
	MsgTypeData = 0
	// MsgTypeRoute is a routing update.
	MsgTypeRoute = 1
	// MsgTypeServiceAdvertisement is an advertisement for a service.
	MsgTypeServiceAdvertisement = 2
	// MsgTypeReject indicates a rejection (closure) of a backend connection.
	MsgTypeReject = 3
)
View Source
const (
	// ProblemServiceUnknown occurs when a message arrives for a non-listening service.
	ProblemServiceUnknown = "service unknown"
	// ProblemExpiredInTransit occurs when a message's HopsToLive expires in transit.
	ProblemExpiredInTransit = "message expired"
	// ProblemRejected occurs when a packet is rejected by a firewall rule.
	ProblemRejected = "blocked by firewall"
)
View Source
const (
	// ConnTypeDatagram indicates a packetconn (datagram) service listener.
	ConnTypeDatagram = 0
	// ConnTypeStream indicates a conn (stream) service listener, without a user-defined TLS.
	ConnTypeStream = 1
	// ConnTypeStreamTLS indicates the service listens on a packetconn connection, with a user-defined TLS.
	ConnTypeStreamTLS = 2
)

Variables

View Source
var ErrTimeout error = &TimeoutError{}

ErrTimeout is returned for an expired deadline.

View Source
var KeepAliveForQuicConnections = true

KeepAliveForQuicConnections is variablized to enable testing of the timeout. If you are doing a heartbeat your connection wont timeout without severing the connection i.e. firewall. Having this variablized allows the tests to set KeepAliveForQuicConnections = False so that things will properly fail.

View Source
var MaxIdleTimeoutForQuicConnections = 30 * time.Second

MaxIdleTimeoutForQuicConnections for quic connections. The default is 30 which we have replicated here. This value is set on both Dial and Listen connections as the quic library would take the smallest of either connection.

Functions

func BackendAllowedPeers

func BackendAllowedPeers(peers []string) func(*BackendInfo)

BackendAllowedPeers is a modifier for AddBackend, which sets the list of peers allowed to connect.

func BackendConnectionCost

func BackendConnectionCost(cost float64) func(*BackendInfo)

BackendConnectionCost is a modifier for AddBackend, which sets the global connection cost.

func BackendNodeCost

func BackendNodeCost(nodeCost map[string]float64) func(*BackendInfo)

BackendNodeCost is a modifier for AddBackend, which sets the per-node connection costs.

func CreateTraceroute added in v1.4.2

func CreateTraceroute(ctx context.Context, s NetcForTraceroute, target string) <-chan *TracerouteResult

CreateTraceroute returns a channel which will receive a series of hops between this node and the target.

func ReceptorVerifyFunc added in v1.2.0

func ReceptorVerifyFunc(tlscfg *tls.Config, pinnedFingerprints [][]byte, expectedHostname string,
	expectedHostnameType ExpectedHostnameType, verifyType VerifyType, logger *logger.ReceptorLogger,
) func(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error

ReceptorVerifyFunc generates a function that verifies a Receptor node ID.

func SendPing added in v1.4.2

func SendPing(ctx context.Context, s NetcForPing, target string, hopsToLive byte) (time.Duration, string, error)

SendPing creates Ping by sending a single test packet and waits for a replay or error.

Types

type Addr

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

Addr represents an endpoint address on the Netceptor network.

func (Addr) Network

func (a Addr) Network() string

Network returns the network name.

func (*Addr) SetNetwork added in v1.4.9

func (a *Addr) SetNetwork(network string)

SetNetwork sets the network variable.

func (*Addr) SetNode added in v1.4.9

func (a *Addr) SetNode(node string)

SetNetwork sets the node variable.

func (*Addr) SetService added in v1.4.9

func (a *Addr) SetService(service string)

SetNetwork sets the service variable.

func (Addr) String

func (a Addr) String() string

String formats this address as a string.

type Backend

type Backend interface {
	Start(context.Context, *sync.WaitGroup) (chan BackendSession, error)
}

Backend is the interface for back-ends that the Receptor network can run over.

type BackendInfo added in v1.4.0

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

type BackendSession

type BackendSession interface {
	Send([]byte) error
	Recv(time.Duration) ([]byte, error) // Must return netceptor.ErrTimeout if the timeout is exceeded
	Close() error
}

BackendSession is the interface for a single session of a back-end. Backends must be DATAGRAM ORIENTED, meaning that Recv() must return whole packets sent by Send(). If the underlying protocol is stream oriented, then the backend must deal with any required buffering.

type CompareFunc

type CompareFunc func(md *MessageData) bool

type Conn

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

Conn implements the net.Conn interface via the Receptor network.

func (*Conn) CancelRead

func (c *Conn) CancelRead()

CancelRead cancels a pending read operation.

func (*Conn) Close

func (c *Conn) Close() error

Close closes the writer side of the connection.

func (*Conn) CloseConnection

func (c *Conn) CloseConnection() error

func (*Conn) LocalAddr

func (c *Conn) LocalAddr() net.Addr

LocalAddr returns the local address of this connection.

func (*Conn) Read

func (c *Conn) Read(b []byte) (n int, err error)

Read reads data from the connection.

func (*Conn) RemoteAddr

func (c *Conn) RemoteAddr() net.Addr

RemoteAddr returns the remote address of this connection.

func (*Conn) SetDeadline

func (c *Conn) SetDeadline(t time.Time) error

SetDeadline sets both read and write deadlines.

func (*Conn) SetReadDeadline

func (c *Conn) SetReadDeadline(t time.Time) error

SetReadDeadline sets the read deadline.

func (*Conn) SetWriteDeadline

func (c *Conn) SetWriteDeadline(t time.Time) error

SetWriteDeadline sets the write deadline.

func (*Conn) Write

func (c *Conn) Write(b []byte) (n int, err error)

Write writes data to the connection.

type ConnStatus

type ConnStatus struct {
	NodeID string
	Cost   float64
}

ConnStatus holds information about a single connection in the Status struct.

type ErrorFunc

type ErrorFunc func(error, bool)

ErrorFunc is a function parameter used to process errors. The boolean parameter indicates whether the error is fatal (i.e. the associated process is going to exit).

type ExpectedHostnameType added in v1.2.0

type ExpectedHostnameType int

ExpectedHostnameType indicates whether we are connecting to a DNS hostname or a Receptor Node ID.

const (
	// ExpectedHostnameTypeDNS indicates we are expecting a DNS style hostname.
	ExpectedHostnameTypeDNS ExpectedHostnameType = 1
	// ExpectedHostnameTypeReceptor indicates we are expecting a Receptor node ID.
	ExpectedHostnameTypeReceptor = 2
)

type ExternalBackend

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

ExternalBackend is a backend implementation for the situation when non-Receptor code is initiating connections, outside the control of a Receptor-managed accept loop.

func NewExternalBackend

func NewExternalBackend() (*ExternalBackend, error)

NewExternalBackend initializes a new ExternalBackend object.

func (*ExternalBackend) NewConnection

func (b *ExternalBackend) NewConnection(conn MessageConn, closeConnWithSession bool) context.Context

NewConnection is called by the external code when a new connection is available. The connection will be closed when the session ends if closeConnWithSession is true. The returned context will be cancelled after the connection closes.

func (*ExternalBackend) Start

func (b *ExternalBackend) Start(ctx context.Context, _ *sync.WaitGroup) (chan BackendSession, error)

Start launches the backend from Receptor's point of view, and waits for connections to happen.

type ExternalSession

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

ExternalSession implements BackendSession for external backends.

func (*ExternalSession) Close

func (es *ExternalSession) Close() error

Close closes the session.

func (*ExternalSession) Recv

func (es *ExternalSession) Recv(timeout time.Duration) ([]byte, error)

Recv receives data via the session.

func (*ExternalSession) Send

func (es *ExternalSession) Send(data []byte) error

Send sends data over the session.

type FirewallResult

type FirewallResult int

FirewallResult enumerates the actions that can be taken as a result of a firewall rule.

const (
	// FirewallResultContinue continues processing further rules (no result).
	FirewallResultContinue FirewallResult = iota
	// FirewallResultAccept accepts the message for normal processing.
	FirewallResultAccept
	// FirewallResultReject denies the message, sending an unreachable message to the originator.
	FirewallResultReject
	// FirewallResultDrop denies the message silently, leaving the originator to time out.
	FirewallResultDrop
)

type FirewallRule

type FirewallRule struct {
	Action      string
	FromNode    string
	ToNode      string
	FromService string
	ToService   string
}

func (FirewallRule) BuildComps

func (fr FirewallRule) BuildComps() []CompareFunc

type FirewallRuleData

type FirewallRuleData map[interface{}]interface{}

func (FirewallRuleData) ParseFirewallRule

func (frd FirewallRuleData) ParseFirewallRule() (FirewallRuleFunc, error)

ParseFirewallRule takes a single string describing a firewall rule, and returns a FirewallRuleFunc function.

type FirewallRuleFunc

type FirewallRuleFunc func(*MessageData) FirewallResult

FirewallRuleFunc is a function that takes a message and returns a firewall decision.

func ParseFirewallRules

func ParseFirewallRules(rules []FirewallRuleData) ([]FirewallRuleFunc, error)

ParseFirewallRules takes a slice of string describing firewall rules, and returns a slice of FirewallRuleFunc functions.

type Listener

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

Listener implements the net.Listener interface via the Receptor network.

func (*Listener) Accept

func (li *Listener) Accept() (net.Conn, error)

Accept accepts a connection via the listener.

func (*Listener) Addr

func (li *Listener) Addr() net.Addr

Addr returns the local address of this listener.

func (*Listener) Close

func (li *Listener) Close() error

Close closes the listener.

type MessageConn

type MessageConn interface {
	WriteMessage(ctx context.Context, data []byte) error
	ReadMessage(ctx context.Context, timeout time.Duration) ([]byte, error)
	SetReadDeadline(t time.Time) error
	Close() error
}

MessageConn is an abstract connection that sends and receives whole messages (datagrams).

func MessageConnFromNetConn

func MessageConnFromNetConn(conn net.Conn) MessageConn

MessageConnFromNetConn returns a MessageConnection that wraps a net.Conn.

func MessageConnFromWebsocketConn

func MessageConnFromWebsocketConn(conn *websocket.Conn) MessageConn

MessageConnFromWebsocketConn returns a MessageConnection that wraps a Gorilla websocket.Conn.

type MessageData

type MessageData struct {
	FromNode    string
	FromService string
	ToNode      string
	ToService   string
	HopsToLive  byte
	Data        []byte
}

MessageData contains a single message packet from the network.

type NetcForPacketConn added in v1.4.2

type NetcForPacketConn interface {
	GetEphemeralService() string
	AddNameHash(name string) uint64
	AddLocalServiceAdvertisement(service string, connType byte, tags map[string]string)
	SendMessageWithHopsToLive(fromService string, toNode string, toService string, data []byte, hopsToLive byte) error
	RemoveLocalServiceAdvertisement(service string) error
	GetLogger() *logger.ReceptorLogger
	NodeID() string
	GetNetworkName() string
	GetListenerLock() *sync.RWMutex
	GetListenerRegistry() map[string]*PacketConn
	GetUnreachableBroker() *utils.Broker
	MaxForwardingHops() byte
	Context() context.Context
}

type NetcForPing added in v1.4.2

type NetcForPing interface {
	ListenPacket(service string) (PacketConner, error)
	NewAddr(target string, service string) Addr
	NodeID() string
	Context() context.Context
}

NetcForPing should include all methods of Netceptor needed by the Ping function.

type NetcForTraceroute added in v1.4.2

type NetcForTraceroute interface {
	MaxForwardingHops() byte
	Ping(ctx context.Context, target string, hopsToLive byte) (time.Duration, string, error)
	Context() context.Context
}

type Netceptor

type Netceptor struct {
	Logger *logger.ReceptorLogger
	// contains filtered or unexported fields
}

Netceptor is the main object of the Receptor mesh network protocol.

var MainInstance *Netceptor

MainInstance is the global instance of Netceptor instantiated by the command-line main() function.

func New

func New(ctx context.Context, nodeID string) *Netceptor

New constructs a new Receptor network protocol instance.

func NewWithConsts

func NewWithConsts(ctx context.Context, nodeID string,
	mtu int, routeUpdateTime time.Duration, serviceAdTime time.Duration, seenUpdateExpireTime time.Duration,
	maxForwardingHops byte, maxConnectionIdleTime time.Duration,
) *Netceptor

NewWithConsts constructs a new Receptor network protocol instance, specifying operational constants.

func (*Netceptor) AddBackend

func (s *Netceptor) AddBackend(backend Backend, modifiers ...func(*BackendInfo)) error

AddBackend adds a backend to the Netceptor system.

func (*Netceptor) AddFirewallRules

func (s *Netceptor) AddFirewallRules(rules []FirewallRuleFunc, clearExisting bool) error

AddFirewallRules adds firewall rules, optionally clearing existing rules first.

func (*Netceptor) AddLocalServiceAdvertisement added in v1.4.2

func (s *Netceptor) AddLocalServiceAdvertisement(service string, connType byte, tags map[string]string)

func (*Netceptor) AddNameHash added in v1.4.2

func (s *Netceptor) AddNameHash(name string) uint64

Hash a name and add it to the lookup table.

func (*Netceptor) AddWorkCommand

func (s *Netceptor) AddWorkCommand(command string, secure bool) error

AddWorkCommand records a work command so it can be included in service announcements.

func (*Netceptor) BackendCount

func (s *Netceptor) BackendCount() int

BackendCount returns the number of backends that ever registered with this Netceptor.

func (*Netceptor) BackendDone

func (s *Netceptor) BackendDone()

BackendDone calls Done on the backendWaitGroup.

func (*Netceptor) BackendWait

func (s *Netceptor) BackendWait()

BackendWait waits for the backend wait group.

func (*Netceptor) CancelBackends

func (s *Netceptor) CancelBackends()

CancelBackends stops all backends by calling a context cancel.

func (*Netceptor) Context

func (s *Netceptor) Context() context.Context

Context returns the context for this Netceptor instance.

func (*Netceptor) Dial

func (s *Netceptor) Dial(node string, service string, tlscfg *tls.Config) (*Conn, error)

Dial returns a stream connection compatible with Go's net.Conn.

func (*Netceptor) DialContext

func (s *Netceptor) DialContext(ctx context.Context, node string, service string, tlscfg *tls.Config) (*Conn, error)

DialContext is like Dial but uses a context to allow timeout or cancellation.

func (*Netceptor) GetClientTLSConfig

func (s *Netceptor) GetClientTLSConfig(name string, expectedHostName string, expectedHostNameType ExpectedHostnameType) (*tls.Config, error)

GetClientTLSConfig retrieves a client TLS config by name. Supported host name types are dns and receptor.

func (*Netceptor) GetEphemeralService added in v1.4.2

func (s *Netceptor) GetEphemeralService() string

Returns an unused random service name to use as the equivalent of a TCP/IP ephemeral port number.

func (*Netceptor) GetListenerLock added in v1.4.2

func (s *Netceptor) GetListenerLock() *sync.RWMutex

GetListenerLock returns listenerLock.

func (*Netceptor) GetListenerRegistry added in v1.4.2

func (s *Netceptor) GetListenerRegistry() map[string]*PacketConn

GetListenerRegistry returns listener registry map.

func (*Netceptor) GetLogger added in v1.4.2

func (s *Netceptor) GetLogger() *logger.ReceptorLogger

GetLogger returns the logger of this Netceptor instance.

func (*Netceptor) GetNameFromHash added in v1.4.2

func (s *Netceptor) GetNameFromHash(namehash uint64) (string, error)

Looks up a name given a hash received from the network.

func (*Netceptor) GetNetworkName added in v1.4.2

func (s *Netceptor) GetNetworkName() string

GetNetworkName returns networkName.

func (*Netceptor) GetServerTLSConfig

func (s *Netceptor) GetServerTLSConfig(name string) (*tls.Config, error)

GetServerTLSConfig retrieves a server TLS config by name.

func (*Netceptor) GetServiceInfo

func (s *Netceptor) GetServiceInfo(nodeID string, service string) (*ServiceAdvertisement, bool)

GetServiceInfo returns the advertising info, if any, for a service on a node.

func (*Netceptor) GetUnreachableBroker added in v1.4.2

func (s *Netceptor) GetUnreachableBroker() *utils.Broker

GetUnreachableBroker returns unreachableBroker.

func (*Netceptor) Listen

func (s *Netceptor) Listen(service string, tlscfg *tls.Config) (*Listener, error)

Listen returns a stream listener compatible with Go's net.Listener. If service is blank, generates and uses an ephemeral service name.

func (*Netceptor) ListenAndAdvertise

func (s *Netceptor) ListenAndAdvertise(service string, tlscfg *tls.Config, tags map[string]string) (*Listener, error)

ListenAndAdvertise listens for stream connections on a service and also advertises it via broadcasts.

func (*Netceptor) ListenPacket

func (s *Netceptor) ListenPacket(service string) (PacketConner, error)

ListenPacket returns a datagram connection compatible with Go's net.PacketConn. If service is blank, generates and uses an ephemeral service name.

func (*Netceptor) ListenPacketAndAdvertise

func (s *Netceptor) ListenPacketAndAdvertise(service string, tags map[string]string) (PacketConner, error)

ListenPacketAndAdvertise returns a datagram listener, and also broadcasts service advertisements to the Receptor network as long as the listener remains open.

func (*Netceptor) MTU

func (s *Netceptor) MTU() int

MTU returns the configured MTU of this Netceptor instance.

func (*Netceptor) MaxConnectionIdleTime

func (s *Netceptor) MaxConnectionIdleTime() time.Duration

MaxConnectionIdleTime returns the configured MaxConnectionIdleTime of this Netceptor instance.

func (*Netceptor) MaxForwardingHops

func (s *Netceptor) MaxForwardingHops() byte

MaxForwardingHops returns the configured MaxForwardingHops of this Netceptor instance.

func (*Netceptor) NetceptorDone

func (s *Netceptor) NetceptorDone() <-chan struct{}

NetceptorDone returns the channel for the netceptor context.

func (*Netceptor) NewAddr

func (s *Netceptor) NewAddr(node string, service string) Addr

NewAddr generates a Receptor network address from a node ID and service name.

func (*Netceptor) NodeID

func (s *Netceptor) NodeID() string

NodeID returns the local Node ID of this Netceptor instance.

func (*Netceptor) PathCost

func (s *Netceptor) PathCost(nodeID string) (float64, error)

PathCost returns the cost to a given remote node, or an error if the node doesn't exist.

func (*Netceptor) Ping added in v1.2.0

func (s *Netceptor) Ping(ctx context.Context, target string, hopsToLive byte) (time.Duration, string, error)

Ping calls SendPing to sends a single test packet and waits for a reply or error.

func (*Netceptor) RemoveLocalServiceAdvertisement added in v1.4.2

func (s *Netceptor) RemoveLocalServiceAdvertisement(service string) error

func (*Netceptor) RouteUpdateTime

func (s *Netceptor) RouteUpdateTime() time.Duration

RouteUpdateTime returns the configured RouteUpdateTime of this Netceptor instance.

func (*Netceptor) SeenUpdateExpireTime

func (s *Netceptor) SeenUpdateExpireTime() time.Duration

SeenUpdateExpireTime returns the configured SeenUpdateExpireTime of this Netceptor instance.

func (*Netceptor) SendMessageWithHopsToLive added in v1.4.2

func (s *Netceptor) SendMessageWithHopsToLive(fromService string, toNode string, toService string, data []byte, hopsToLive byte) error

Generates and sends a message over the Receptor network, specifying HopsToLive.

func (*Netceptor) ServiceAdTime

func (s *Netceptor) ServiceAdTime() time.Duration

ServiceAdTime returns the configured ServiceAdTime of this Netceptor instance.

func (*Netceptor) SetClientTLSConfig

func (s *Netceptor) SetClientTLSConfig(name string, config *tls.Config, pinnedFingerprints [][]byte) error

SetClientTLSConfig stores a client TLS config by name.

func (*Netceptor) SetMaxConnectionIdleTime added in v1.3.0

func (s *Netceptor) SetMaxConnectionIdleTime(userDefinedMaxIdleConnectionTimeout string) error

Sets the MaxConnectionIdleTime object on the Netceptor instance.

func (*Netceptor) SetServerTLSConfig

func (s *Netceptor) SetServerTLSConfig(name string, config *tls.Config) error

SetServerTLSConfig stores a server TLS config by name.

func (*Netceptor) Shutdown

func (s *Netceptor) Shutdown()

Shutdown shuts down a Netceptor instance.

func (*Netceptor) Status

func (s *Netceptor) Status() Status

Status returns the current state of the Netceptor object.

func (*Netceptor) SubscribeRoutingUpdates

func (s *Netceptor) SubscribeRoutingUpdates() chan map[string]string

SubscribeRoutingUpdates subscribes for messages when the routing table is changed.

func (*Netceptor) Traceroute added in v1.2.0

func (s *Netceptor) Traceroute(ctx context.Context, target string) <-chan *TracerouteResult

type PacketConn

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

PacketConn implements the net.PacketConn interface via the Receptor network.

func NewPacketConn added in v1.4.2

func NewPacketConn(s NetcForPacketConn, service string, connTypeDatagram byte) *PacketConn

func NewPacketConnWithConst added in v1.4.2

func NewPacketConnWithConst(s NetcForPacketConn, service string, advertise bool, adtags map[string]string, connTypeDatagram byte) *PacketConn

func (*PacketConn) Cancel added in v1.4.2

func (pc *PacketConn) Cancel() *context.CancelFunc

func (*PacketConn) Close

func (pc *PacketConn) Close() error

Close closes the connection.

func (*PacketConn) GetHopsToLive added in v1.4.2

func (pc *PacketConn) GetHopsToLive() byte

func (*PacketConn) GetLogger added in v1.4.2

func (pc *PacketConn) GetLogger() *logger.ReceptorLogger

func (*PacketConn) GetReadDeadline added in v1.4.4

func (pc *PacketConn) GetReadDeadline() time.Time

func (*PacketConn) LocalAddr

func (pc *PacketConn) LocalAddr() net.Addr

LocalAddr returns the local address the connection is bound to.

func (*PacketConn) LocalService

func (pc *PacketConn) LocalService() string

LocalService returns the local service name of the connection.

func (*PacketConn) ReadFrom

func (pc *PacketConn) ReadFrom(p []byte) (n int, addr net.Addr, err error)

ReadFrom reads a packet from the network and returns its data and address.

func (*PacketConn) SetDeadline

func (pc *PacketConn) SetDeadline(t time.Time) error

SetDeadline sets both the read and write deadlines.

func (*PacketConn) SetHopsToLive

func (pc *PacketConn) SetHopsToLive(hopsToLive byte)

SetHopsToLive sets the HopsToLive value for future outgoing packets on this connection.

func (*PacketConn) SetReadDeadline

func (pc *PacketConn) SetReadDeadline(t time.Time) error

SetReadDeadline sets the read deadline.

func (*PacketConn) SetWriteDeadline

func (pc *PacketConn) SetWriteDeadline(_ time.Time) error

SetWriteDeadline sets the write deadline.

func (*PacketConn) StartUnreachable added in v1.4.2

func (pc *PacketConn) StartUnreachable()

startUnreachable starts monitoring the netceptor unreachable channel and forwarding relevant messages.

func (*PacketConn) SubscribeUnreachable

func (pc *PacketConn) SubscribeUnreachable(doneChan chan struct{}) chan UnreachableNotification

SubscribeUnreachable subscribes for unreachable messages relevant to this PacketConn.

func (*PacketConn) WriteTo

func (pc *PacketConn) WriteTo(p []byte, addr net.Addr) (n int, err error)

WriteTo writes a packet to an address on the network.

type PacketConner added in v1.4.2

type PacketConner interface {
	SetHopsToLive(hopsToLive byte)
	GetHopsToLive() byte
	SubscribeUnreachable(doneChan chan struct{}) chan UnreachableNotification
	ReadFrom(p []byte) (int, net.Addr, error)
	WriteTo(p []byte, addr net.Addr) (n int, err error)
	LocalAddr() net.Addr
	Close() error
	SetDeadline(t time.Time) error
	SetReadDeadline(t time.Time) error
	GetReadDeadline() time.Time
	SetWriteDeadline(t time.Time) error
	Cancel() *context.CancelFunc
	LocalService() string
	GetLogger() *logger.ReceptorLogger
	StartUnreachable()
}

type ReceptorCertNameError

type ReceptorCertNameError struct {
	ValidNodes   []string
	ExpectedNode string
}

ReceptorCertNameError is the error produced when Receptor certificate name verification fails.

func (ReceptorCertNameError) Error

func (rce ReceptorCertNameError) Error() string

type ServiceAdvertisement

type ServiceAdvertisement struct {
	NodeID       string
	Service      string
	Time         time.Time
	ConnType     byte
	Tags         map[string]string
	WorkCommands []WorkCommand
}

ServiceAdvertisement is the data associated with a service advertisement.

type Status

type Status struct {
	NodeID               string
	Connections          []*ConnStatus
	RoutingTable         map[string]string
	Advertisements       []*ServiceAdvertisement
	KnownConnectionCosts map[string]map[string]float64
}

Status is the struct returned by Netceptor.Status(). It represents a public view of the internal status of the Netceptor object.

type TLSClientConfig added in v1.4.0

type TLSClientConfig struct {
	Name                   string   `required:"true" description:"Name of this TLS client configuration"`
	Cert                   string   `required:"true" description:"Client certificate filename"`
	Key                    string   `required:"true" description:"Client private key filename"`
	RootCAs                string   `required:"false" description:"Root CA bundle to use instead of system trust"`
	InsecureSkipVerify     bool     `required:"false" description:"Accept any server cert" default:"false"`
	PinnedServerCert       []string `required:"false" description:"Pinned fingerprint of required server certificate"`
	SkipReceptorNamesCheck bool     `required:"false" description:"if true, skip verifying ReceptorNames OIDs in certificate at startup"`
	MinTLS13               bool     `required:"false" description:"Set minimum TLS version to 1.3. Otherwise the minimum is 1.2" default:"false"`
}

TLSClientConfig stores the configuration options for a TLS client.

func (TLSClientConfig) Prepare added in v1.4.0

func (cfg TLSClientConfig) Prepare() error

Prepare creates the tls.config and stores it in the global map.

func (TLSClientConfig) PrepareTLSClientConfig added in v1.4.0

func (cfg TLSClientConfig) PrepareTLSClientConfig(n *Netceptor) (tlscfg *tls.Config, pinnedFingerprints [][]byte, err error)

type TLSServerConfig added in v1.4.0

type TLSServerConfig struct {
	Name                   string   `required:"true" description:"Name of this TLS server configuration"`
	Cert                   string   `required:"true" description:"Server certificate filename"`
	Key                    string   `required:"true" description:"Server private key filename"`
	RequireClientCert      bool     `required:"false" description:"Require client certificates" default:"false"`
	ClientCAs              string   `required:"false" description:"Filename of CA bundle to verify client certs with"`
	PinnedClientCert       []string `required:"false" description:"Pinned fingerprint of required client certificate"`
	SkipReceptorNamesCheck bool     `required:"false" description:"Skip verifying ReceptorNames OIDs in certificate at startup" default:"false"`
	MinTLS13               bool     `required:"false" description:"Set minimum TLS version to 1.3. Otherwise the minimum is 1.2" default:"false"`
}

TLSServerConfig stores the configuration options for a TLS server.

func (TLSServerConfig) Prepare added in v1.4.0

func (cfg TLSServerConfig) Prepare() error

Prepare creates the tls.config and stores it in the global map.

func (TLSServerConfig) PrepareTLSServerConfig added in v1.4.0

func (cfg TLSServerConfig) PrepareTLSServerConfig(n *Netceptor) (*tls.Config, error)

type TimeoutError

type TimeoutError struct{}

TimeoutError is returned for an expired deadline.

func (*TimeoutError) Error

func (e *TimeoutError) Error() string

Error returns a string describing the error.

func (*TimeoutError) Temporary

func (e *TimeoutError) Temporary() bool

Temporary returns true if a retry is likely a good idea.

func (*TimeoutError) Timeout

func (e *TimeoutError) Timeout() bool

Timeout returns true if this error was a timeout.

type TracerouteResult added in v1.2.0

type TracerouteResult struct {
	From string
	Time time.Duration
	Err  error
}

TracerouteResult is the result of one hop of a traceroute.

type UnreachableMessage

type UnreachableMessage struct {
	FromNode    string
	ToNode      string
	FromService string
	ToService   string
	Problem     string
}

UnreachableMessage is the on-the-wire data associated with an unreachable message.

type UnreachableNotification

type UnreachableNotification struct {
	UnreachableMessage
	ReceivedFromNode string
}

UnreachableNotification includes additional information returned from SubscribeUnreachable.

type VerifyType added in v1.2.0

type VerifyType int

VerifyType indicates whether we are verifying a server or client.

const (
	// VerifyServer indicates we are the client, verifying a server.
	VerifyServer VerifyType = 1
	// VerifyClient indicates we are the server, verifying a client.
	VerifyClient = 2
)

type WorkCommand

type WorkCommand struct {
	WorkType string
	// Secure true means receptor will verify the signature of the work submit payload
	Secure bool
}

WorkCommand tracks available work types and whether they verify work submissions.

Directories

Path Synopsis
Package mock_netceptor is a generated GoMock package.
Package mock_netceptor is a generated GoMock package.

Jump to

Keyboard shortcuts

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