protocolproxy

package
v1.7.5 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2023 License: Apache-2.0, MIT Imports: 12 Imported by: 3

Documentation

Index

Constants

View Source
const ForwardingProtocolID protocol.ID = "/libp2p/balancer/forwarding/0.0.1"

ForwardingProtocolID identifies the protocol for requesting forwarding of a protocol for the libp2p load balancer

Variables

View Source
var ErrInboundRequestsAreSingleProtocol = errors.New("inbound requests are single protocol")

ErrInboundRequestsAreSingleProtocol is thrown by the service node when it receives and outbound request

View Source
var ErrNoInboundRequests = errors.New("inbound requests not accepted")

ErrNoInboundRequests is thrown by the load balancer when it receives and inbound request

View Source
var ErrNoOutboundRequests = errors.New("outbound requests not accepted")

ErrNoOutboundRequests is thrown by the service node when it receives and outbound request

Functions

func NewForwardingHost

func NewForwardingHost(h host.Host, proxy peer.AddrInfo) host.Host

NewForwardingHost node constructs a service node connected to the given proxy on the passed in host. A forwarding host behaves exactly like a host.Host but setting up new protocol handlers registers routes on the proxy node.

Types

type ErrNotRegistered

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

ErrNotRegistered indicates a peer has not registered a given protocol but is trying to extend or terminate the registration

func (ErrNotRegistered) Error

func (e ErrNotRegistered) Error() string

type ForwardingHost

type ForwardingHost struct {
	host.Host
	// contains filtered or unexported fields
}

ForwardingHost is a host that behaves as a service node connected to a proxy -- all traffic is routed through the proxy for each registered protocol

func (*ForwardingHost) Close

func (fh *ForwardingHost) Close() error

Close shuts down a service node host's forwarding

func (*ForwardingHost) Connect

func (fh *ForwardingHost) Connect(ctx context.Context, pi peer.AddrInfo) error

Connect for now does nothing

func (*ForwardingHost) NewStream

func (fh *ForwardingHost) NewStream(ctx context.Context, p peer.ID, protocols ...protocol.ID) (network.Stream, error)

Calls to "NewStream" open an outbound forwarding request to the proxy, that is then sent on the the specified peer

func (*ForwardingHost) RemoveStreamHandler

func (fh *ForwardingHost) RemoveStreamHandler(pid protocol.ID)

RemoveStreamHandler removes a stream handler by shutting down registered route with the original host

func (*ForwardingHost) SetStreamHandler

func (fh *ForwardingHost) SetStreamHandler(pid protocol.ID, handler network.StreamHandler)

SetStreamHandler interrupts the normal process of setting up stream handlers by also registering a route on the connected protocol proxy. All traffic on the forwarding protocol will go through the forwarding handshake with the proxy, then the native handler will be called

type ProtocolProxy

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

func NewProtocolProxy

func NewProtocolProxy(h host.Host, peerConfig map[peer.ID][]protocol.ID) (*ProtocolProxy, error)

func (*ProtocolProxy) Close

func (pp *ProtocolProxy) Close()

func (*ProtocolProxy) Connected

func (pp *ProtocolProxy) Connected(n network.Network, c network.Conn)

Connected checks the peersConfig and begins listening any time a service node connects

func (*ProtocolProxy) Disconnected

func (pp *ProtocolProxy) Disconnected(n network.Network, c network.Conn)

Disconnected checks the peersConfig and removes listening when a service node disconnects

func (*ProtocolProxy) Listen

func (pp *ProtocolProxy) Listen(network.Network, multiaddr.Multiaddr)

Listen satifies the network.Notifee interface but does nothing

func (*ProtocolProxy) ListenClose

func (pp *ProtocolProxy) ListenClose(network.Network, multiaddr.Multiaddr)

ListenClose satifies the network.Notifee interface but does nothing

func (*ProtocolProxy) Start

func (pp *ProtocolProxy) Start(ctx context.Context)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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