types

package
v0.0.0-...-064b279 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Addr

type Addr ed25519.PublicKey

Addr implements the `net.Addr` interface for `ed25519.PublicKey` values.

func (Addr) Network

func (a Addr) Network() string

Network returns "ed25519.PublicKey" as a string, but is otherwise unused.

func (Addr) String

func (a Addr) String() string

String returns the ed25519.PublicKey as a hexidecimal string, but is otherwise unused.

type Error

type Error uint

Error is any error generated by the PacketConn. Note that other errors may still be returned, if e.g. HandleConn returns due to a network error. An Error may be wrapped to provide additional context.

const (
	ErrUndefined Error = iota
	ErrEncode
	ErrDecode
	ErrClosed
	ErrTimeout
	ErrBadMessage
	ErrEmptyMessage
	ErrOversizedMessage
	ErrUnrecognizedMessage
	ErrPeerNotFound
	ErrBadAddress
	ErrBadKey
)

func (Error) Error

func (e Error) Error() string

func (Error) String

func (i Error) String() string

type PacketConn

type PacketConn interface {
	net.PacketConn
	// 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.
	HandleConn(key ed25519.PublicKey, conn net.Conn, prio uint8) error

	// 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).
	IsClosed() bool

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

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

	// SendLookup sends a lookup for a given (possibly partial) key.
	SendLookup(target ed25519.PublicKey)
}

Jump to

Keyboard shortcuts

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