backends

package
v1.4.5 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const UDPMaxPacketLen = 65507

UDPMaxPacketLen is the maximum size of a message that can be sent over UDP.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conner added in v1.4.3

type Conner interface {
	Close() error
	ReadMessage() (messageType int, p []byte, err error)
	WriteMessage(messageType int, data []byte) error
}

type GorillaDialWrapper added in v1.4.3

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

GorillaDialWrapper represents the real library.

func (GorillaDialWrapper) DialContext added in v1.4.3

func (g GorillaDialWrapper) DialContext(ctx context.Context, urlStr string, requestHeader http.Header) (Conner, *http.Response, error)

type GorillaUpgradeWrapper added in v1.4.3

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

GorillaDialWrapper represents the real library.

func (GorillaUpgradeWrapper) Upgrade added in v1.4.3

func (g GorillaUpgradeWrapper) Upgrade(w http.ResponseWriter, r *http.Request, responseHeader http.Header) (Conner, error)

type GorillaWebsocketDialerForDialer added in v1.4.3

type GorillaWebsocketDialerForDialer interface {
	DialContext(ctx context.Context, urlStr string, requestHeader http.Header) (Conner, *http.Response, error)
}

type GorillaWebsocketUpgraderForListener added in v1.4.3

type GorillaWebsocketUpgraderForListener interface {
	Upgrade(w http.ResponseWriter, r *http.Request, responseHeader http.Header) (Conner, error)
}

type HTTPServerForListener added in v1.4.3

type HTTPServerForListener interface {
	Serve(l net.Listener) error
	ServeTLS(l net.Listener, certFile string, keyFile string) error
	Close() error
	SetTLSConfig(tlscfg *tls.Config)
	SetHandeler(mux *http.ServeMux)
}

type HTTPServerWrapper added in v1.4.3

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

func (HTTPServerWrapper) Close added in v1.4.3

func (s HTTPServerWrapper) Close() error

func (HTTPServerWrapper) Serve added in v1.4.3

func (s HTTPServerWrapper) Serve(l net.Listener) error

func (HTTPServerWrapper) ServeTLS added in v1.4.3

func (s HTTPServerWrapper) ServeTLS(l net.Listener, certFile string, keyFile string) error

func (HTTPServerWrapper) SetHandeler added in v1.4.3

func (s HTTPServerWrapper) SetHandeler(mux *http.ServeMux)

func (HTTPServerWrapper) SetTLSConfig added in v1.4.3

func (s HTTPServerWrapper) SetTLSConfig(tlscfg *tls.Config)

type TCPDialer

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

TCPDialer implements Backend for outbound TCP.

func NewTCPDialer

func NewTCPDialer(address string, redial bool, tls *tls.Config, logger *logger.ReceptorLogger) (*TCPDialer, error)

NewTCPDialer instantiates a new TCP backend.

func (*TCPDialer) GetAddr added in v1.4.0

func (b *TCPDialer) GetAddr() string

func (*TCPDialer) GetTLS added in v1.4.0

func (b *TCPDialer) GetTLS() *tls.Config

func (*TCPDialer) Start

func (b *TCPDialer) Start(ctx context.Context, wg *sync.WaitGroup) (chan netceptor.BackendSession, error)

Start runs the given session function over this backend service.

type TCPDialerCfg added in v1.4.0

type TCPDialerCfg struct {
	Address      string   `description:"Remote address (Host:Port) to connect to" barevalue:"yes" required:"yes"`
	Redial       bool     `description:"Keep redialing on lost connection" default:"true"`
	TLS          string   `description:"Name of TLS client config"`
	Cost         float64  `description:"Connection cost (weight)" default:"1.0"`
	AllowedPeers []string `description:"Peer node IDs to allow via this connection"`
}

TODO make these fields private TCPDialerCfg is the cmdline configuration object for a TCP dialer.

func (TCPDialerCfg) PreReload added in v1.4.0

func (cfg TCPDialerCfg) PreReload() error

func (TCPDialerCfg) Prepare added in v1.4.0

func (cfg TCPDialerCfg) Prepare() error

Prepare verifies the parameters are correct.

func (TCPDialerCfg) Reload added in v1.4.0

func (cfg TCPDialerCfg) Reload() error

func (TCPDialerCfg) Run added in v1.4.0

func (cfg TCPDialerCfg) Run() error

Run runs the action.

type TCPListener

type TCPListener struct {
	TLS *tls.Config
	// contains filtered or unexported fields
}

TCPListener implements Backend for inbound TCP.

func NewTCPListener

func NewTCPListener(address string, tls *tls.Config, logger *logger.ReceptorLogger) (*TCPListener, error)

NewTCPListener instantiates a new TCPListener backend.

func (*TCPListener) GetAddr added in v1.4.0

func (b *TCPListener) GetAddr() string

Addr returns the network address the listener is listening on.

func (*TCPListener) GetCost added in v1.4.0

func (b *TCPListener) GetCost() string

func (*TCPListener) GetTLS added in v1.4.0

func (b *TCPListener) GetTLS() *tls.Config

func (*TCPListener) Start

Start runs the given session function over the TCPListener backend.

type TCPListenerCfg added in v1.4.0

type TCPListenerCfg struct {
	BindAddr     string             `description:"Local address to bind to" default:"0.0.0.0"`
	Port         int                `description:"Local TCP port to listen on" barevalue:"yes" required:"yes"`
	TLS          string             `description:"Name of TLS server config"`
	Cost         float64            `description:"Connection cost (weight)" default:"1.0"`
	NodeCost     map[string]float64 `description:"Per-node costs"`
	AllowedPeers []string           `description:"Peer node IDs to allow via this connection"`
}

TODO make these fields private TCPListenerCfg is the cmdline configuration object for a TCP listener.

func (TCPListenerCfg) GetAddr added in v1.4.0

func (cfg TCPListenerCfg) GetAddr() string

func (TCPListenerCfg) GetCost added in v1.4.0

func (cfg TCPListenerCfg) GetCost() float64

func (TCPListenerCfg) GetNodeCost added in v1.4.0

func (cfg TCPListenerCfg) GetNodeCost() map[string]float64

func (TCPListenerCfg) GetTLS added in v1.4.0

func (cfg TCPListenerCfg) GetTLS() string

func (TCPListenerCfg) PreReload added in v1.4.0

func (cfg TCPListenerCfg) PreReload() error

func (TCPListenerCfg) Prepare added in v1.4.0

func (cfg TCPListenerCfg) Prepare() error

Prepare verifies the parameters are correct.

func (TCPListenerCfg) Reload added in v1.4.0

func (cfg TCPListenerCfg) Reload() error

func (TCPListenerCfg) Run added in v1.4.0

func (cfg TCPListenerCfg) Run() error

Run runs the action.

type TCPSession

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

TCPSession implements BackendSession for TCP backend.

func (*TCPSession) Close

func (ns *TCPSession) Close() error

Close closes the session.

func (*TCPSession) Recv

func (ns *TCPSession) Recv(timeout time.Duration) ([]byte, error)

Recv receives data via the session.

func (*TCPSession) Send

func (ns *TCPSession) Send(data []byte) error

Send sends data over the session.

type UDPDialer

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

UDPDialer implements Backend for outbound UDP.

func NewUDPDialer

func NewUDPDialer(address string, redial bool, logger *logger.ReceptorLogger) (*UDPDialer, error)

NewUDPDialer instantiates a new UDPDialer backend.

func (*UDPDialer) GetAddr added in v1.4.0

func (b *UDPDialer) GetAddr() string

func (*UDPDialer) GetTLS added in v1.4.0

func (b *UDPDialer) GetTLS() *tls.Config

func (*UDPDialer) Start

func (b *UDPDialer) Start(ctx context.Context, wg *sync.WaitGroup) (chan netceptor.BackendSession, error)

Start runs the given session function over this backend service.

type UDPDialerSession

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

UDPDialerSession implements BackendSession for UDPDialer.

func (*UDPDialerSession) Close

func (ns *UDPDialerSession) Close() error

Close closes the session.

func (*UDPDialerSession) Recv

func (ns *UDPDialerSession) Recv(timeout time.Duration) ([]byte, error)

Recv receives data via the session.

func (*UDPDialerSession) Send

func (ns *UDPDialerSession) Send(data []byte) error

Send sends data over the session.

type UDPListener

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

UDPListener implements Backend for inbound UDP.

func NewUDPListener

func NewUDPListener(address string, logger *logger.ReceptorLogger) (*UDPListener, error)

NewUDPListener instantiates a new UDPListener backend.

func (*UDPListener) GetAddr added in v1.4.0

func (b *UDPListener) GetAddr() string

func (*UDPListener) GetTLS added in v1.4.0

func (b *UDPListener) GetTLS() *tls.Config

func (*UDPListener) LocalAddr

func (b *UDPListener) LocalAddr() net.Addr

LocalAddr returns the local address the listener is listening on.

func (*UDPListener) Start

Start runs the given session function over the UDPListener backend.

type UDPListenerCfg added in v1.4.0

type UDPListenerCfg struct {
	BindAddr     string             `description:"Local address to bind to" default:"0.0.0.0"`
	Port         int                `description:"Local UDP port to listen on" barevalue:"yes" required:"yes"`
	Cost         float64            `description:"Connection cost (weight)" default:"1.0"`
	NodeCost     map[string]float64 `description:"Per-node costs"`
	AllowedPeers []string           `description:"Peer node IDs to allow via this connection"`
}

TODO make these fields private UDPListenerCfg is the cmdline configuration object for a UDP listener.

func (UDPListenerCfg) GetAddr added in v1.4.0

func (cfg UDPListenerCfg) GetAddr() string

func (UDPListenerCfg) GetCost added in v1.4.0

func (cfg UDPListenerCfg) GetCost() float64

func (UDPListenerCfg) GetNodeCost added in v1.4.0

func (cfg UDPListenerCfg) GetNodeCost() map[string]float64

func (UDPListenerCfg) GetPort added in v1.4.0

func (cfg UDPListenerCfg) GetPort() int

func (UDPListenerCfg) GetTLS added in v1.4.0

func (cfg UDPListenerCfg) GetTLS() string

func (UDPListenerCfg) PreReload added in v1.4.0

func (cfg UDPListenerCfg) PreReload() error

func (UDPListenerCfg) Prepare added in v1.4.0

func (cfg UDPListenerCfg) Prepare() error

Prepare verifies the parameters are correct.

func (UDPListenerCfg) Reload added in v1.4.0

func (cfg UDPListenerCfg) Reload() error

func (UDPListenerCfg) Run added in v1.4.0

func (cfg UDPListenerCfg) Run() error

Run runs the action.

type UDPListenerSession

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

UDPListenerSession implements BackendSession for UDPListener.

func (*UDPListenerSession) Close

func (ns *UDPListenerSession) Close() error

Close closes the session.

func (*UDPListenerSession) Recv

func (ns *UDPListenerSession) Recv(timeout time.Duration) ([]byte, error)

Recv receives data from the session.

func (*UDPListenerSession) Send

func (ns *UDPListenerSession) Send(data []byte) error

Send sends data over the session.

type WebsocketDialer

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

WebsocketDialer implements Backend for outbound Websocket.

func NewWebsocketDialer

func NewWebsocketDialer(address string, tlscfg *tls.Config, extraHeader string, redial bool, logger *logger.ReceptorLogger, dialer GorillaWebsocketDialerForDialer) (*WebsocketDialer, error)

NewWebsocketDialer instantiates a new WebsocketDialer backend.

func (*WebsocketDialer) Dialer added in v1.4.3

func (*WebsocketDialer) GetAddr added in v1.4.0

func (b *WebsocketDialer) GetAddr() string

func (*WebsocketDialer) GetTLS added in v1.4.0

func (b *WebsocketDialer) GetTLS() *tls.Config

func (*WebsocketDialer) Start

Start runs the given session function over this backend service.

type WebsocketListener

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

WebsocketListener implements Backend for inbound Websocket.

func NewWebsocketListener

func NewWebsocketListener(address string, tlscfg *tls.Config, logger *logger.ReceptorLogger, upgrader GorillaWebsocketUpgraderForListener, server HTTPServerForListener) (*WebsocketListener, error)

NewWebsocketListener instantiates a new WebsocketListener backend.

func (*WebsocketListener) Addr

func (b *WebsocketListener) Addr() net.Addr

Addr returns the network address the listener is listening on.

func (*WebsocketListener) GetAddr added in v1.4.0

func (b *WebsocketListener) GetAddr() string

func (*WebsocketListener) GetTLS added in v1.4.0

func (b *WebsocketListener) GetTLS() *tls.Config

func (*WebsocketListener) Path

func (b *WebsocketListener) Path() string

Path returns the URI path the websocket is configured on.

func (*WebsocketListener) SetPath

func (b *WebsocketListener) SetPath(path string)

SetPath sets the URI path that the listener will be hosted on. It is only effective if used prior to calling Start.

func (*WebsocketListener) Start

Start runs the given session function over the WebsocketListener backend.

type WebsocketListenerCfg added in v1.4.0

type WebsocketListenerCfg struct {
	BindAddr     string             `description:"Local address to bind to" default:"0.0.0.0"`
	Port         int                `description:"Local TCP port to run http server on" barevalue:"yes" required:"yes"`
	Path         string             `description:"URI path to the websocket server" default:"/"`
	TLS          string             `description:"Name of TLS server config"`
	Cost         float64            `description:"Connection cost (weight)" default:"1.0"`
	NodeCost     map[string]float64 `description:"Per-node costs"`
	AllowedPeers []string           `description:"Peer node IDs to allow via this connection"`
}

TODO make fields private WebsocketListenerCfg is the cmdline configuration object for a websocket listener.

func (WebsocketListenerCfg) GetAddr added in v1.4.0

func (cfg WebsocketListenerCfg) GetAddr() string

func (WebsocketListenerCfg) GetCost added in v1.4.0

func (cfg WebsocketListenerCfg) GetCost() float64

func (WebsocketListenerCfg) GetNodeCost added in v1.4.0

func (cfg WebsocketListenerCfg) GetNodeCost() map[string]float64

func (WebsocketListenerCfg) GetTLS added in v1.4.0

func (cfg WebsocketListenerCfg) GetTLS() string

func (WebsocketListenerCfg) PreReload added in v1.4.0

func (cfg WebsocketListenerCfg) PreReload() error

func (WebsocketListenerCfg) Prepare added in v1.4.0

func (cfg WebsocketListenerCfg) Prepare() error

Prepare verifies the parameters are correct.

func (WebsocketListenerCfg) Reload added in v1.4.0

func (cfg WebsocketListenerCfg) Reload() error

func (WebsocketListenerCfg) Run added in v1.4.0

func (cfg WebsocketListenerCfg) Run() error

Run runs the action.

type WebsocketListenerForWebsocket added in v1.4.3

type WebsocketListenerForWebsocket interface {
	Addr() net.Addr
	GetAddr() string
	GetTLS() *tls.Config
	Path() string
	SetPath(path string)
	Start(ctx context.Context, wg *sync.WaitGroup) (chan netceptor.BackendSession, error)
}

type WebsocketSession

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

WebsocketSession implements BackendSession for WebsocketDialer and WebsocketListener.

func (*WebsocketSession) Close

func (ns *WebsocketSession) Close() error

Close closes the session.

func (*WebsocketSession) Recv

func (ns *WebsocketSession) Recv(timeout time.Duration) ([]byte, error)

Recv receives data via the session.

func (*WebsocketSession) Send

func (ns *WebsocketSession) Send(data []byte) error

Send sends data over the session.

Directories

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

Jump to

Keyboard shortcuts

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