network

package
v0.0.0-...-cdbfe9b Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MPL-2.0 Imports: 13 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Debug

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

func (*Debug) GetBlooms

func (d *Debug) GetBlooms() (infos []DebugBloomInfo)

func (*Debug) GetPaths

func (d *Debug) GetPaths() (infos []DebugPathInfo)

func (*Debug) GetPeers

func (d *Debug) GetPeers() (infos []DebugPeerInfo)

func (*Debug) GetSelf

func (d *Debug) GetSelf() (info DebugSelfInfo)

func (*Debug) GetTree

func (d *Debug) GetTree() (infos []DebugTreeInfo)

func (*Debug) SetDebugLookupLogger

func (d *Debug) SetDebugLookupLogger(logger func(DebugLookupInfo))

type DebugBloomInfo

type DebugBloomInfo struct {
	Key  ed25519.PublicKey
	Send [bloomFilterU]uint64
	Recv [bloomFilterU]uint64
}

type DebugLookupInfo

type DebugLookupInfo struct {
	Key    ed25519.PublicKey
	Path   []uint64
	Target ed25519.PublicKey
}

type DebugPathInfo

type DebugPathInfo struct {
	Key      ed25519.PublicKey
	Path     []uint64
	Sequence uint64
}

type DebugPeerInfo

type DebugPeerInfo struct {
	Key      ed25519.PublicKey
	Root     ed25519.PublicKey
	Port     uint64
	Priority uint8
	RX       uint64
	TX       uint64
	Updated  time.Time
	Conn     net.Conn
}

type DebugSelfInfo

type DebugSelfInfo struct {
	Key            ed25519.PublicKey
	RoutingEntries uint64
}

type DebugTreeInfo

type DebugTreeInfo struct {
	Key      ed25519.PublicKey
	Parent   ed25519.PublicKey
	Sequence uint64
}

type Option

type Option func(*config)

func WithBloomTransform

func WithBloomTransform(xform func(key ed25519.PublicKey) ed25519.PublicKey) Option

func WithPathNotify

func WithPathNotify(notify func(key ed25519.PublicKey)) Option

func WithPathThrottle

func WithPathThrottle(duration time.Duration) Option

func WithPathTimeout

func WithPathTimeout(duration time.Duration) Option

func WithPeerKeepAliveDelay

func WithPeerKeepAliveDelay(duration time.Duration) Option

func WithPeerMaxMessageSize

func WithPeerMaxMessageSize(size uint64) Option

func WithPeerTimeout

func WithPeerTimeout(duration time.Duration) Option

func WithRouterRefresh

func WithRouterRefresh(duration time.Duration) Option

func WithRouterTimeout

func WithRouterTimeout(duration time.Duration) Option

type PacketConn

type PacketConn struct {
	Debug Debug
	// contains filtered or unexported fields
}

func NewPacketConn

func NewPacketConn(secret ed25519.PrivateKey, options ...Option) (*PacketConn, error)

NewPacketConn returns a *PacketConn struct which implements the types.PacketConn interface.

func (*PacketConn) Close

func (pc *PacketConn) Close() error

Close shuts down the PacketConn.

func (*PacketConn) HandleConn

func (pc *PacketConn) HandleConn(key ed25519.PublicKey, conn net.Conn, prio uint8) error

HandleConn expects a peer's public key as its first argument, and a net.Conn with TCP-like semantics (reliable ordered delivery) as its second argument. This function blocks while the net.Conn is in use, and returns an error if any occurs. This function returns (almost) immediately if PacketConn.Close() is called. In all cases, the net.Conn is closed before returning.

func (*PacketConn) IsClosed

func (pc *PacketConn) IsClosed() bool

IsClosed returns true if and only if the connection is closed. This is to check if the PacketConn is closed without potentially being stuck on a blocking operation (e.g. a read or write).

func (*PacketConn) LocalAddr

func (pc *PacketConn) LocalAddr() net.Addr

LocalAddr returns a types.Addr of the ed25519.PublicKey for this PacketConn.

func (*PacketConn) MTU

func (pc *PacketConn) MTU() uint64

MTU returns the maximum transmission unit of the PacketConn, i.e. maximum safe message size to send over the network.

func (*PacketConn) PrivateKey

func (pc *PacketConn) PrivateKey() ed25519.PrivateKey

PrivateKey() returns the ed25519.PrivateKey used to initialize the PacketConn.

func (*PacketConn) ReadFrom

func (pc *PacketConn) ReadFrom(p []byte) (n int, from net.Addr, err error)

ReadFrom fulfills the net.PacketConn interface, with a types.Addr returned as the from address. Note that failing to call ReadFrom may cause the connection to block and/or leak memory.

func (*PacketConn) SendLookup

func (pc *PacketConn) SendLookup(key ed25519.PublicKey)

func (*PacketConn) SetDeadline

func (pc *PacketConn) SetDeadline(t time.Time) error

SetDeadline fulfills the net.PacketConn interface. Note that only read deadlines are affected.

func (*PacketConn) SetReadDeadline

func (pc *PacketConn) SetReadDeadline(t time.Time) error

SetReadDeadline fulfills the net.PacketConn interface.

func (*PacketConn) SetWriteDeadline

func (pc *PacketConn) SetWriteDeadline(t time.Time) error

SetWriteDeadline fulfills the net.PacketConn interface.

func (*PacketConn) WriteTo

func (pc *PacketConn) WriteTo(p []byte, addr net.Addr) (n int, err error)

WriteTo fulfills the net.PacketConn interface, with a types.Addr expected as the destination address.

Jump to

Keyboard shortcuts

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