Documentation ¶
Index ¶
- func MaxNodeInfoSize() int
- type ConnFilterFunc
- type ErrCurrentlyDialingOrExistingAddress
- type ErrFilterTimeout
- type ErrNetAddressInvalid
- type ErrNetAddressLookup
- type ErrNetAddressNoID
- type ErrRejected
- func (e ErrRejected) Addr() p2p.NetAddress
- func (e ErrRejected) Error() string
- func (e ErrRejected) IsAuthFailure() bool
- func (e ErrRejected) IsDuplicate() bool
- func (e ErrRejected) IsFiltered() bool
- func (e ErrRejected) IsIncompatible() bool
- func (e ErrRejected) IsNodeInfoInvalid() bool
- func (e ErrRejected) IsSelf() bool
- type ErrSwitchAuthenticationFailure
- type ErrSwitchConnectToSelf
- type ErrSwitchDuplicatePeerID
- type ErrSwitchDuplicatePeerIP
- type ErrTransportClosed
- type IPResolver
- type MultiplexTransport
- func (mt *MultiplexTransport) Accept(cfg PeerConfig) (p2p.Peer, error)
- func (mt *MultiplexTransport) AddChannel(chID byte)
- func (mt *MultiplexTransport) Cleanup(p p2p.Peer)
- func (mt *MultiplexTransport) Close() error
- func (mt *MultiplexTransport) Dial(addr p2p.NetAddress, cfg PeerConfig) (p2p.Peer, error)
- func (mt *MultiplexTransport) Listen(addr p2p.NetAddress) error
- func (mt *MultiplexTransport) NetAddress() p2p.NetAddress
- type MultiplexTransportOption
- func MultiplexTransportConnFilters(filters ...ConnFilterFunc) MultiplexTransportOption
- func MultiplexTransportFilterTimeout(timeout time.Duration) MultiplexTransportOption
- func MultiplexTransportMaxIncomingConnections(n int) MultiplexTransportOption
- func MultiplexTransportResolver(resolver IPResolver) MultiplexTransportOption
- type PeerConfig
- type PeerOption
- type Transport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ConnFilterFunc ¶
ConnFilterFunc to be implemented by filter hooks after a new connection has been established. The set of exisiting connections is passed along together with all resolved IPs for the new connection.
type ErrCurrentlyDialingOrExistingAddress ¶
type ErrCurrentlyDialingOrExistingAddress struct {
Addr string
}
ErrCurrentlyDialingOrExistingAddress indicates that we're currently dialing this address or it belongs to an existing peer.
func (ErrCurrentlyDialingOrExistingAddress) Error ¶
func (e ErrCurrentlyDialingOrExistingAddress) Error() string
type ErrFilterTimeout ¶
type ErrFilterTimeout struct{}
ErrFilterTimeout indicates that a filter operation timed out.
func (ErrFilterTimeout) Error ¶
func (e ErrFilterTimeout) Error() string
type ErrNetAddressInvalid ¶
func (ErrNetAddressInvalid) Error ¶
func (e ErrNetAddressInvalid) Error() string
type ErrNetAddressLookup ¶
func (ErrNetAddressLookup) Error ¶
func (e ErrNetAddressLookup) Error() string
type ErrNetAddressNoID ¶
type ErrNetAddressNoID struct {
Addr string
}
func (ErrNetAddressNoID) Error ¶
func (e ErrNetAddressNoID) Error() string
type ErrRejected ¶
type ErrRejected struct {
// contains filtered or unexported fields
}
ErrRejected indicates that a Peer was rejected carrying additional information as to the reason.
func (ErrRejected) Addr ¶
func (e ErrRejected) Addr() p2p.NetAddress
Addr returns the NetAddress for the rejected Peer.
func (ErrRejected) Error ¶
func (e ErrRejected) Error() string
func (ErrRejected) IsAuthFailure ¶
func (e ErrRejected) IsAuthFailure() bool
IsAuthFailure when Peer authentication was unsuccessful.
func (ErrRejected) IsDuplicate ¶
func (e ErrRejected) IsDuplicate() bool
IsDuplicate when Peer ID or IP are present already.
func (ErrRejected) IsFiltered ¶
func (e ErrRejected) IsFiltered() bool
IsFiltered when Peer ID or IP was filtered.
func (ErrRejected) IsIncompatible ¶
func (e ErrRejected) IsIncompatible() bool
IsIncompatible when Peer NodeInfo is not compatible with our own.
func (ErrRejected) IsNodeInfoInvalid ¶
func (e ErrRejected) IsNodeInfoInvalid() bool
IsNodeInfoInvalid when the sent NodeInfo is not valid.
type ErrSwitchAuthenticationFailure ¶
type ErrSwitchAuthenticationFailure struct { Dialed *p2p.NetAddress Got p2p.ID }
func (ErrSwitchAuthenticationFailure) Error ¶
func (e ErrSwitchAuthenticationFailure) Error() string
type ErrSwitchConnectToSelf ¶
type ErrSwitchConnectToSelf struct {
Addr *p2p.NetAddress
}
ErrSwitchConnectToSelf to be raised when trying to connect to itself.
func (ErrSwitchConnectToSelf) Error ¶
func (e ErrSwitchConnectToSelf) Error() string
type ErrSwitchDuplicatePeerID ¶
ErrSwitchDuplicatePeerID to be raised when a peer is connecting with a known ID.
func (ErrSwitchDuplicatePeerID) Error ¶
func (e ErrSwitchDuplicatePeerID) Error() string
type ErrSwitchDuplicatePeerIP ¶
ErrSwitchDuplicatePeerIP to be raised whena a peer is connecting with a known IP.
func (ErrSwitchDuplicatePeerIP) Error ¶
func (e ErrSwitchDuplicatePeerIP) Error() string
type ErrTransportClosed ¶
type ErrTransportClosed struct{}
ErrTransportClosed is raised when the Transport has been closed.
func (ErrTransportClosed) Error ¶
func (e ErrTransportClosed) Error() string
type IPResolver ¶
IPResolver is a behaviour subset of net.Resolver.
type MultiplexTransport ¶
type MultiplexTransport struct {
// contains filtered or unexported fields
}
MultiplexTransport accepts and dials tcp connections and upgrades them to multiplexed peers.
func NewMultiplexTransport ¶
func NewMultiplexTransport( nodeInfo p2p.NodeInfo, nodeKey p2p.NodeKey, mConfig conn.MConnConfig, ) *MultiplexTransport
NewMultiplexTransport returns a tcp connected multiplexed peer.
func (*MultiplexTransport) Accept ¶
func (mt *MultiplexTransport) Accept(cfg PeerConfig) (p2p.Peer, error)
Accept implements Transport.
func (*MultiplexTransport) AddChannel ¶
func (mt *MultiplexTransport) AddChannel(chID byte)
AddChannel registers a channel to nodeInfo. NOTE: NodeInfo must be of type DefaultNodeInfo else channels won't be updated This is a bit messy at the moment but is cleaned up in the following version when NodeInfo changes from an interface to a concrete type
func (*MultiplexTransport) Cleanup ¶
func (mt *MultiplexTransport) Cleanup(p p2p.Peer)
Cleanup removes the given address from the connections set and closes the connection.
func (*MultiplexTransport) Close ¶
func (mt *MultiplexTransport) Close() error
Close implements transportLifecycle.
func (*MultiplexTransport) Dial ¶
func (mt *MultiplexTransport) Dial( addr p2p.NetAddress, cfg PeerConfig, ) (p2p.Peer, error)
Dial implements Transport.
func (*MultiplexTransport) Listen ¶
func (mt *MultiplexTransport) Listen(addr p2p.NetAddress) error
Listen implements transportLifecycle.
func (*MultiplexTransport) NetAddress ¶
func (mt *MultiplexTransport) NetAddress() p2p.NetAddress
NetAddress implements Transport.
type MultiplexTransportOption ¶
type MultiplexTransportOption func(*MultiplexTransport)
MultiplexTransportOption sets an optional parameter on the MultiplexTransport.
func MultiplexTransportConnFilters ¶
func MultiplexTransportConnFilters( filters ...ConnFilterFunc, ) MultiplexTransportOption
MultiplexTransportConnFilters sets the filters for rejection new connections.
func MultiplexTransportFilterTimeout ¶
func MultiplexTransportFilterTimeout( timeout time.Duration, ) MultiplexTransportOption
MultiplexTransportFilterTimeout sets the timeout waited for filter calls to return.
func MultiplexTransportMaxIncomingConnections ¶
func MultiplexTransportMaxIncomingConnections(n int) MultiplexTransportOption
MultiplexTransportMaxIncomingConnections sets the maximum number of simultaneous connections (incoming). Default: 0 (unlimited)
func MultiplexTransportResolver ¶
func MultiplexTransportResolver(resolver IPResolver) MultiplexTransportOption
MultiplexTransportResolver sets the Resolver used for ip lokkups, defaults to net.DefaultResolver.
type PeerConfig ¶
type PeerConfig struct {
// contains filtered or unexported fields
}
PeerConfig is used to bundle data we need to fully setup a Peer with an MConn, provided by the caller of Accept and Dial (currently the Switch). This a temporary measure until reactor setup is less dynamic and we introduce the concept of PeerBehaviour to communicate about significant Peer lifecycle events. TODO(xla): Refactor out with more static Reactor setup and PeerBehaviour.
type PeerOption ¶
type PeerOption func(*peer)
func PeerMetrics ¶
func PeerMetrics(metrics *p2p.Metrics) PeerOption
type Transport ¶
type Transport interface { // Listening address. NetAddress() p2p.NetAddress // Accept returns a newly connected Peer. Accept(PeerConfig) (p2p.Peer, error) // Dial connects to the Peer for the address. Dial(p2p.NetAddress, PeerConfig) (p2p.Peer, error) // Cleanup any resources associated with Peer. Cleanup(p2p.Peer) }
Transport emits and connects to Peers. The implementation of Peer is left to the transport. Each transport is also responsible to filter establishing peers specific to its domain.