peer

package
v0.76.1 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2026 License: BSD-3-Clause, AGPL-3.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPeerAlreadyRegistered = errors.New("peer already registered")
)

Functions

This section is empty.

Types

type Peer

type Peer struct {
	// a unique id of the Peer (e.g. sha256 fingerprint of the Wireguard public key)
	Id string

	StreamID int64

	// a gRpc connection stream to the Peer
	Stream proto.SignalExchange_ConnectStreamServer

	// registration time
	RegisteredAt time.Time

	Cancel context.CancelFunc
	// contains filtered or unexported fields
}

Peer representation of a connected Peer

func NewPeer

NewPeer creates a new instance of a connected Peer

func (*Peer) Send added in v0.73.0

func (p *Peer) Send(msg *proto.EncryptedMessage) error

Send writes a message to the peer's stream, serializing concurrent senders.

type Registry

type Registry struct {
	// Peer.key -> Peer
	Peers sync.Map
	// contains filtered or unexported fields
}

Registry that holds all currently connected Peers

func NewRegistry

func NewRegistry(metrics *metrics.AppMetrics) *Registry

NewRegistry creates a new connected Peer registry

func (*Registry) Deregister

func (registry *Registry) Deregister(peer *Peer)

Deregister Peer from the Registry (usually once it disconnects)

func (*Registry) Get

func (registry *Registry) Get(peerId string) (*Peer, bool)

Get gets a peer from the registry

func (*Registry) IsPeerRegistered

func (registry *Registry) IsPeerRegistered(peerId string) bool

func (*Registry) Register

func (registry *Registry) Register(peer *Peer) error

Register registers peer in the registry

Jump to

Keyboard shortcuts

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