ifaces

package
v0.0.0-...-d81ffa1 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package ifaces contains interface definitions commonly shared amongst code in `types`.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Actor

type Actor interface {
	Run()

	Inbox() chan<- msgactor.ActorMessage

	// Cancel this actor's context.
	Cancel()

	// Close is called by the actor's Run loop when cancelled.
	Close()
}

type ControlCallbacks

type ControlCallbacks interface {
	// AddPeer has the server inform the client that it should observe another peer, with the following details.
	AddPeer(
		peer key.NodePublic,
		homeRelay int64, endpoints []netip.AddrPort, session key.SessionPublic,
		ip4, ip6 netip.Addr,
		prop msgcontrol.Properties,
	) error

	// UpdatePeer has the server inform of one of more updates to the client. All parameters other than peer are nullable.
	UpdatePeer(peer key.NodePublic, homeRelay *int64, endpoints []netip.AddrPort, session *key.SessionPublic, prop *msgcontrol.Properties) error

	// RemovePeer has the server inform the client to stop observing another peer.
	RemovePeer(peer key.NodePublic) error

	// UpdateRelays has the server inform the client of relay information, or updates.
	//
	// This is a set-add/update operation. (The client should not remove relays from its internal cache,
	// if it is not present in this list.)
	UpdateRelays(relay []relay.Information) error
}

ControlCallbacks are the possible updates that the control server wishes to inform the client about.

type ControlInterface

type ControlInterface interface {
	// ControlKey gets the public key of the current control server. Used for TOFU and debugging.
	ControlKey() key.ControlPublic
	// IPv4 gets the node's ipv4 address as assigned by the control server.
	//
	// As it is a netip.Prefix, it also includes the expected ipv4 range that all peers will be on.
	IPv4() netip.Prefix
	// IPv6 gets the node's ipv6 address as assigned by the control server.
	//
	// As it is a netip.Prefix, it also includes the expected ipv6 range that all peers will be on.
	IPv6() netip.Prefix
	// Expiry of the current control session, defaults to zero-value if there is no expiry,
	// or session is not connected.
	Expiry() time.Time

	// UpdateEndpoints informs the server of any changes in STUN-resolved endpoints. This is a set-replace operation.
	UpdateEndpoints([]netip.AddrPort) error
	// UpdateHomeRelay informs the server of the current client preferred home relay.
	UpdateHomeRelay(int64) error
}

ControlInterface are the methods that should be present on a control session, to inform the control server of updates, and get information about the current logged-in node.

type ControlSession

type ControlSession interface {
	ControlInterface

	Context() context.Context

	// InstallCallbacks installs the current session's callbacks to another interface.
	//
	// This interface will be informed of updates from the control server.
	InstallCallbacks(ControlCallbacks)
}

ControlSession is an interface representing an active control session.

type DirectManagerActor

type DirectManagerActor interface {
	Actor

	WriteTo(pkt []byte, addr netip.AddrPort)
}

type DirectRouterActor

type DirectRouterActor interface {
	Actor

	Push(frame DirectedPeerFrame)
}

type DirectedPeerFrame

type DirectedPeerFrame struct {
	SrcAddrPort netip.AddrPort

	Timestamp time.Time

	Pkt []byte
}

type EndpointManagerActor

type EndpointManagerActor interface {
	Actor
}

type RelayManagerActor

type RelayManagerActor interface {
	Actor

	WriteTo(pkt []byte, relay int64, dst key.NodePublic)
}

type RelayRouterActor

type RelayRouterActor interface {
	Actor

	Push(frame RelayedPeerFrame)
}

type RelayedPeerFrame

type RelayedPeerFrame struct {
	SrcRelay int64

	SrcPeer key.NodePublic

	Pkt []byte
}

type SessionManagerActor

type SessionManagerActor interface {
	Actor

	Session() key.SessionPublic
}

type Stage

type Stage interface {
	Start()

	ControlCallbacks

	UpdateHomeRelay(peer key.NodePublic, relay int64) error
	UpdateSessionKey(peer key.NodePublic, session key.SessionPublic) error
	SetEndpoints(peer key.NodePublic, endpoints []netip.AddrPort) error

	GetPeerInfo(peer key.NodePublic) *stage.PeerInfo
	GetEndpoints() []netip.AddrPort
}

Stage documents/iterates the functions a Stage should expose

type TrafficManagerActor

type TrafficManagerActor interface {
	Actor

	Poke()

	ValidKeys(nodeKey key.NodePublic, sess key.SessionPublic) bool
	SendMsgToDirect(ap netip.AddrPort, sess key.SessionPublic, m msgsess.SessionMessage)
	SendMsgToRelay(relay int64, node key.NodePublic, sess key.SessionPublic, m msgsess.SessionMessage)
	SendPingDirect(ap netip.AddrPort, peer key.NodePublic, session key.SessionPublic)

	OutConnUseAddrPort(peer key.NodePublic, ap netip.AddrPort)
	OutConnTrackHome(peer key.NodePublic)

	DManSetAKA(peer key.NodePublic, ap netip.AddrPort)
	DManClearAKA(peer key.NodePublic)

	Stage() Stage
	Pings() map[msgsess.TxID]*stage.SentPing

	ActiveIn() map[key.NodePublic]bool
	ActiveOut() map[key.NodePublic]bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳