handshake

package
v1.1.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2021 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ProtocolName is the text of the name of the handshake protocol.
	ProtocolName = "handshake"
	// ProtocolVersion is the current handshake protocol version.
	ProtocolVersion = "4.0.0"
	// StreamName is the name of the stream used for handshake purposes.
	StreamName = "handshake"
	// MaxWelcomeMessageLength is maximum number of characters allowed in the welcome message.
	MaxWelcomeMessageLength = 140
)
View Source
const (
	FullNode = iota
	LightNode
)

Variables

View Source
var (
	// ErrNetworkIDIncompatible is returned if response from the other peer does not have valid networkID.
	ErrNetworkIDIncompatible = errors.New("incompatible network ID")

	// ErrHandshakeDuplicate is returned  if the handshake response has been received by an already processed peer.
	ErrHandshakeDuplicate = errors.New("duplicate handshake")

	// ErrInvalidAck is returned if data in received in ack is not valid (invalid signature for example).
	ErrInvalidAck = errors.New("invalid ack")

	// ErrInvalidSyn is returned if observable address in ack is not a valid..
	ErrInvalidSyn = errors.New("invalid syn")

	// ErrWelcomeMessageLength is returned if the welcome message is longer than the maximum length
	ErrWelcomeMessageLength = fmt.Errorf("handshake welcome message longer than maximum of %d characters", MaxWelcomeMessageLength)

	// ErrPicker is returned if the picker (kademlia) rejects the peer
	ErrPicker = fmt.Errorf("picker rejection")

	ErrPickerLight = fmt.Errorf("picker rejection light")
)

Functions

This section is empty.

Types

type AdvertisableAddressResolver

type AdvertisableAddressResolver interface {
	Resolve(observedAddress ma.Multiaddr) (ma.Multiaddr, error)
}

AdvertisableAddressResolver can Resolve a Multiaddress.

type Info

type Info struct {
	BzzAddress *aurora.Address
	NodeMode   Model
}

Info contains the information received from the handshake.

func (*Info) LightString

func (i *Info) LightString() string

type Model

type Model struct {
	Bv *bitvector.BitVector
}

func (Model) IsFull

func (m Model) IsFull() bool

func (Model) IsLight

func (m Model) IsLight() bool

type Service

type Service struct {
	network.Notifiee // handshake service can be the receiver for network.Notify
	// contains filtered or unexported fields
}

Service can perform initiate or handle a handshake between peers.

func New

func New(signer crypto.Signer, advertisableAddresser AdvertisableAddressResolver, overlay boson.Address, networkID uint64, fullNode bool, welcomeMessage string, ownPeerID libp2ppeer.ID, logger logging.Logger, lightNodes *lightnode.Container, lightLimit int) (*Service, error)

New creates a new handshake Service.

func (*Service) Disconnected

func (s *Service) Disconnected(_ network.Network, c network.Conn)

Disconnected is called when the peer disconnects.

func (*Service) GetWelcomeMessage

func (s *Service) GetWelcomeMessage() string

GetWelcomeMessage returns the the current handshake welcome message.

func (*Service) Handle

func (s *Service) Handle(ctx context.Context, stream p2p.Stream, remoteMultiaddr ma.Multiaddr, remotePeerID libp2ppeer.ID) (i *Info, err error)

Handle handles an incoming handshake from a peer.

func (*Service) Handshake

func (s *Service) Handshake(ctx context.Context, stream p2p.Stream, peerMultiaddr ma.Multiaddr, peerID libp2ppeer.ID) (i *Info, err error)

Handshake initiates a handshake with a peer.

func (*Service) Metrics added in v1.0.12

func (s *Service) Metrics() []prometheus.Collector

Metrics returns set of prometheus collectors.

func (*Service) SetPicker added in v1.0.12

func (s *Service) SetPicker(n p2p.Picker)

func (*Service) SetWelcomeMessage

func (s *Service) SetWelcomeMessage(msg string) (err error)

SetWelcomeMessage sets the new handshake welcome message.

Directories

Path Synopsis
Package pb holds only Protocol Buffer definitions and generated code.
Package pb holds only Protocol Buffer definitions and generated code.

Jump to

Keyboard shortcuts

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