Documentation
¶
Index ¶
- Constants
- Variables
- func CompareAddrs(a, b Addr) int
- func DiscardAsks[A Addr](ctx context.Context, a AskServer[A]) error
- func DiscardTells[A Addr](ctx context.Context, t Receiver[A]) error
- func ExpandUnspecifiedIPs[A hasIP2[A]](xs []A) (ys []A)
- func ExtractIP(x Addr) (netip.Addr, bool)
- func ExtractTCP(x Addr) *net.TCPAddr
- func ExtractUDP(x Addr) *net.UDPAddr
- func IsErrClosed(err error) bool
- func IsErrMTUExceeded(err error) bool
- func IsErrPublicKeyNotFound(err error) bool
- func LookupPublicKeyInHandler[A Addr, PublicKey any](s Secure[A, PublicKey], target A) PublicKey
- func NoLinkLocal(x net.IP) bool
- func NoLoopback(x net.IP) bool
- func NoOpAskHandler[A Addr](ctx context.Context, resp []byte, req Message[A]) int
- func OnlyGlobal(x net.IP) bool
- func Receive[A Addr](ctx context.Context, t Receiver[A], m *Message[A]) error
- func VecBytes(out []byte, v IOVec) []byte
- func VecSize(v IOVec) int
- type Addr
- type AddrParser
- type AskServer
- type AskSwarm
- type Asker
- type ComparableAddr
- type Fingerprinter
- type HasIP
- type HasPeerID
- type HasTCP
- type HasUDP
- type IOVec
- type Message
- type PeerID
- type Receiver
- type Secure
- type SecureAskSwarm
- type SecureSwarm
- type Swarm
- type Teller
- type UnwrapAddr
Constants ¶
const ( // PeerIDSize is the size of a PeerID in bytes PeerIDSize = 32 // Base64Alphabet is used when encoding IDs as base64 strings. // It is a URL and filepath safe encoding, which maintains ordering. Base64Alphabet = "-0123456789" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "_" + "abcdefghijklmnopqrstuvwxyz" )
Variables ¶
Functions ¶
func CompareAddrs ¶
func ExpandUnspecifiedIPs ¶
func ExpandUnspecifiedIPs[A hasIP2[A]](xs []A) (ys []A)
ExpandUnspecifiedIPs will expand 0.0.0.0 into all of IPs on the host.
func ExtractTCP ¶
func ExtractUDP ¶
func IsErrClosed ¶
func IsErrMTUExceeded ¶
func IsErrPublicKeyNotFound ¶
func LookupPublicKeyInHandler ¶
LookupPublicKeyInHandler calls LookupPublicKey with an expired context, and panics on an error. SecureSwarms must be able to return a PublicKey retrieved from memory, during the execution of an AskHandler or TellHandler. to lookup a public key outside a handler, use the swarms LookupPublicKey method
func NoLinkLocal ¶
func NoLoopback ¶
func NoOpAskHandler ¶
func OnlyGlobal ¶
func Receive ¶
Receive is convenience function which sets m to be a message received from t. m must be non-nil. m.Payload will be truncated (x = x[:0]), and then the message payload will be appended (x = append(x, payload...)) This is useful if the caller wants their own copy of the message, instead of borrowing the swarm's temporarily.
Types ¶
type Addr ¶
type AddrParser ¶
AddrParser is the type of functions which parse []byte into Addrs
type AskServer ¶
type AskServer[A Addr] interface { // ServeAsk calls fn to serve a single ask request, it returns an error if anything went wrong. // Return values < 0 from fn will not result in an error returned from ServeAsk ServeAsk(ctx context.Context, ah func(ctx context.Context, resp []byte, req Message[A]) int) error }
type AskSwarm ¶
func ComposeAskSwarm ¶
type ComparableAddr ¶
type ComparableAddr interface { Addr comparable }
ComparableAddr is an Addr which also satisfies comparable
type Fingerprinter ¶
Fingerprinter is the type of functions which create PeerIDs from PublicKeys
type PeerID ¶
type PeerID [32]byte
PeerID is a identifier cryptographically related to a public key
func ExtractPeerID ¶
func (PeerID) Base64String ¶
func (PeerID) MarshalText ¶
func (*PeerID) UnmarshalText ¶
type Receiver ¶
type Receiver[A Addr] interface { // Recv blocks until the context is cancelled or 1 message is recieved. // fn is called with the message, which may be used until fn returns. // None of the message's fields may be accessed outside of fn. // All of the message's fields may be modified inside fn. A message is only ever delivered to one place, // so the message will never be accessed concurrently or after the call to fn. Receive(ctx context.Context, fn func(Message[A])) error }
type SecureAskSwarm ¶
func ComposeSecureAskSwarm ¶
func ComposeSecureAskSwarm[A Addr, Pub any](swarm Swarm[A], ask askBidi[A], sec Secure[A, Pub]) SecureAskSwarm[A, Pub]
type SecureSwarm ¶
func ComposeSecureSwarm ¶
func ComposeSecureSwarm[A Addr, Pub any](swarm Swarm[A], sec Secure[A, Pub]) SecureSwarm[A, Pub]
type Swarm ¶
type Swarm[A Addr] interface { Teller[A] Receiver[A] // LocalAddrs returns all the addresses that can be used to contact this Swarm LocalAddrs() []A // MTU returns the maximum transmission unit for the Swarm. // This is the maxiumum size of messages incoming and outgoing. MTU() int // Close releases all resources held by the swarm. // It should be called when the swarm is no longer in use. Close() error // ParseAddr attempts to parse an address from data ParseAddr(data []byte) (A, error) }
Swarm represents a single node's view of an address space for nodes. Nodes have their own position(s) or address(es) in the swarm. Nodes can send and receive messages to and from other nodes in the Swarm.
type Teller ¶
type Teller[A Addr] interface { // Tell sends a message containing data to dst // Tell returns an error if the message cannot be set in flight. // A nil error does not guarentee delivery of the message. // None of the buffers in v will be modified, but v may be modified. // After the call to Tell, v must not be retained. Tell(ctx context.Context, dst A, v IOVec) error }
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
cmd
|
|
f
|
|
x509
package x509 implements Public Key Infrastructure X.509 formats.
|
package x509 implements Public Key Infrastructure X.509 formats. |
p
|
|
s
|
|
vswarm
package vswarm implements a virtual swarm which is capable of emulating other types of swarms.
|
package vswarm implements a virtual swarm which is capable of emulating other types of swarms. |