backends

package
v0.0.0-...-b2ae87a Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2023 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

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

type GorillaDialWrapper

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

GorillaDialWrapper represents the real library.

func (GorillaDialWrapper) DialContext

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

type GorillaUpgradeWrapper

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

GorillaDialWrapper represents the real library.

func (GorillaUpgradeWrapper) Upgrade

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

type GorillaWebsocketDialerForDialer

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

type GorillaWebsocketUpgraderForListener

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

type HTTPServerForListener

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

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

func (HTTPServerWrapper) Close

func (s HTTPServerWrapper) Close() error

func (HTTPServerWrapper) Serve

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

func (HTTPServerWrapper) ServeTLS

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

func (HTTPServerWrapper) SetHandeler

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

func (HTTPServerWrapper) SetTLSConfig

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

func (b *TCPDialer) GetAddr() string

func (*TCPDialer) GetTLS

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

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

func (cfg TCPDialerCfg) PreReload() error

func (TCPDialerCfg) Prepare

func (cfg TCPDialerCfg) Prepare() error

Prepare verifies the parameters are correct.

func (TCPDialerCfg) Reload

func (cfg TCPDialerCfg) Reload() error

func (TCPDialerCfg) Run

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

func (b *TCPListener) GetAddr() string

Addr returns the network address the listener is listening on.

func (*TCPListener) GetCost

func (b *TCPListener) GetCost() string

func (*TCPListener) GetTLS

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

func (*TCPListener) Start

Start runs the given session function over the TCPListener backend.

type TCPListenerCfg

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

func (cfg TCPListenerCfg) GetAddr() string

func (TCPListenerCfg) GetCost

func (cfg TCPListenerCfg) GetCost() float64

func (TCPListenerCfg) GetNodeCost

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

func (TCPListenerCfg) GetTLS

func (cfg TCPListenerCfg) GetTLS() string

func (TCPListenerCfg) PreReload

func (cfg TCPListenerCfg) PreReload() error

func (TCPListenerCfg) Prepare

func (cfg TCPListenerCfg) Prepare() error

Prepare verifies the parameters are correct.

func (TCPListenerCfg) Reload

func (cfg TCPListenerCfg) Reload() error

func (TCPListenerCfg) Run

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

func (b *UDPDialer) GetAddr() string

func (*UDPDialer) GetTLS

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

func (b *UDPListener) GetAddr() string

func (*UDPListener) GetTLS

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

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

func (cfg UDPListenerCfg) GetAddr() string

func (UDPListenerCfg) GetCost

func (cfg UDPListenerCfg) GetCost() float64

func (UDPListenerCfg) GetNodeCost

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

func (UDPListenerCfg) GetPort

func (cfg UDPListenerCfg) GetPort() int

func (UDPListenerCfg) GetTLS

func (cfg UDPListenerCfg) GetTLS() string

func (UDPListenerCfg) PreReload

func (cfg UDPListenerCfg) PreReload() error

func (UDPListenerCfg) Prepare

func (cfg UDPListenerCfg) Prepare() error

Prepare verifies the parameters are correct.

func (UDPListenerCfg) Reload

func (cfg UDPListenerCfg) Reload() error

func (UDPListenerCfg) Run

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) GetAddr

func (b *WebsocketDialer) GetAddr() string

func (*WebsocketDialer) GetTLS

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

func (b *WebsocketListener) GetAddr() string

func (*WebsocketListener) GetTLS

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

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

func (cfg WebsocketListenerCfg) GetAddr() string

func (WebsocketListenerCfg) GetCost

func (cfg WebsocketListenerCfg) GetCost() float64

func (WebsocketListenerCfg) GetNodeCost

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

func (WebsocketListenerCfg) GetTLS

func (cfg WebsocketListenerCfg) GetTLS() string

func (WebsocketListenerCfg) PreReload

func (cfg WebsocketListenerCfg) PreReload() error

func (WebsocketListenerCfg) Prepare

func (cfg WebsocketListenerCfg) Prepare() error

Prepare verifies the parameters are correct.

func (WebsocketListenerCfg) Reload

func (cfg WebsocketListenerCfg) Reload() error

func (WebsocketListenerCfg) Run

func (cfg WebsocketListenerCfg) Run() error

Run runs the action.

type WebsocketListenerForWebsocket

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