udpswarm

package
v0.0.0-...-d4b7e32 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2023 License: MPL-2.0 Imports: 5 Imported by: 2

Documentation

Index

Constants

View Source
const (
	IPv4MTU = 576
	IPv6MTU = 1280

	TheoreticalMTU = (1 << 16) - 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Addr

type Addr struct {
	IP   netip.Addr
	Port uint16
}

func FromNetAddr

func FromNetAddr(x net.UDPAddr) Addr

func ParseAddr

func ParseAddr(x []byte) (Addr, error)

func (Addr) AsNetAddr

func (a Addr) AsNetAddr() net.UDPAddr

func (Addr) GetIP

func (a Addr) GetIP() netip.Addr

func (Addr) Key

func (a Addr) Key() string

func (Addr) MapIP

func (a Addr) MapIP(fn func(netip.Addr) netip.Addr) Addr

func (Addr) MarshalText

func (a Addr) MarshalText() ([]byte, error)

func (Addr) Network

func (a Addr) Network() string

func (Addr) String

func (a Addr) String() string

func (*Addr) UnmarshalText

func (a *Addr) UnmarshalText(x []byte) error

type Swarm

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

Swarm implements p2p.Swarm using the User Datagram Protocol

WARNING: This implementation is not secure. It does not encrypt traffic, does not verify identity of peers, and (therefore) does not implement p2p.SecureSwarm.

It is included as a transport for secure swarms to be built on.

func New

func New(laddr string) (*Swarm, error)

func (*Swarm) Close

func (s *Swarm) Close() error

func (*Swarm) LocalAddrs

func (s *Swarm) LocalAddrs() []Addr

func (*Swarm) MTU

func (s *Swarm) MTU() int

func (*Swarm) ParseAddr

func (s *Swarm) ParseAddr(x []byte) (Addr, error)

func (*Swarm) Receive

func (s *Swarm) Receive(ctx context.Context, th func(p2p.Message[Addr])) error

func (*Swarm) Tell

func (s *Swarm) Tell(ctx context.Context, a Addr, data p2p.IOVec) error

Jump to

Keyboard shortcuts

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