Version: v0.0.0-...-bcc58cb Latest Latest

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

Go to latest
Published: Sep 19, 2021 License: MIT Imports: 9 Imported by: 5



Package rudp implements the low-level Minetest protocol described at



View Source
const (
	ConnTimeout = 30 * time.Second
	PingTimeout = 5 * time.Second
View Source
const (
	MaxRelPktSize   = 32439825
	MaxUnrelPktSize = 32636430


View Source
var ErrOutOfPeerIDs = errors.New("out of peer ids")
View Source
var ErrPktTooBig = errors.New("can't send pkt: too big")
View Source
var ErrTimedOut = errors.New("timed out")


This section is empty.


type Channel

type Channel uint8

Reliable packets in a channel are be received in the order they are sent in. A Channel must be less than ChannelCount.

const ChannelCount Channel = 3

type Conn

type Conn struct {
	// contains filtered or unexported fields

A Conn is a connection to a client or server. All Conn's methods are safe for concurrent use.

func Connect

func Connect(conn net.Conn) *Conn

Connect returns a Conn connected to conn.

func (*Conn) Close

func (c *Conn) Close() error

Close closes the Conn. Any blocked Send or Recv calls will return net.ErrClosed.

func (*Conn) Closed

func (c *Conn) Closed() <-chan struct{}

Closed returns a channel which is closed when the Conn is closed.

func (*Conn) ID

func (c *Conn) ID() PeerID

ID returns the PeerID of the Conn.

func (*Conn) IsSrv

func (c *Conn) IsSrv() bool

IsSrv reports whether the Conn is a connection to a server.

func (*Conn) LocalAddr

func (c *Conn) LocalAddr() net.Addr

LocalAddr returns the local network address.

func (*Conn) Recv

func (c *Conn) Recv() (Pkt, error)

Recv receives a Pkt from the Conn.

func (*Conn) RemoteAddr

func (c *Conn) RemoteAddr() net.Addr

RemoteAddr returns the remote network address.

func (*Conn) Send

func (c *Conn) Send(pkt Pkt) (ack <-chan struct{}, err error)

Send sends a Pkt to the Conn. Ack is closed when the packet is acknowledged. Ack is nil if pkt.Unrel is true or err != nil.

func (*Conn) WhyClosed

func (c *Conn) WhyClosed() error

WhyClosed returns the error that caused the Conn to be closed or nil if the Conn was closed using the Close method or by the peer. WhyClosed returns nil if the Conn is not closed.

type Listener

type Listener struct {
	// contains filtered or unexported fields

All Listener's methods are safe for concurrent use.

func Listen

func Listen(pc net.PacketConn) *Listener

Listen listens for connections on pc, pc is closed once the returned Listener and all Conns connected through it are closed.

func (*Listener) Accept

func (l *Listener) Accept() (*Conn, error)

Accept waits for and returns the next incoming Conn or an error.

func (*Listener) Addr

func (l *Listener) Addr() net.Addr

Addr returns the Listener's network address.

func (*Listener) Close

func (l *Listener) Close() error

Close makes the Listener stop listening for new Conns. Blocked Accept calls will return net.ErrClosed. Already Accepted Conns are not closed.

type PeerID

type PeerID uint16

PeerIDs aren't actually used to identify peers, IP addresses and ports are, these just exist for backward compatibility.

const (
	// Used by clients before the server sets their ID.
	PeerIDNil PeerID = iota

	// The server always has this ID.

	// Lowest ID the server can assign to a client.

type Pkt

type Pkt struct {

type PktInfo

type PktInfo struct {

	// Unrel (unreliable) packets may be dropped, duplicated or reordered.
	Unrel bool

type TooBigChError

type TooBigChError Channel

A TooBigChError reports a Channel greater than or equal to ChannelCount.

func (TooBigChError) Error

func (e TooBigChError) Error() string

type TrailingDataError

type TrailingDataError []byte

A TrailingDataError reports trailing data after a packet.

func (TrailingDataError) Error

func (e TrailingDataError) Error() string


Path Synopsis
Proxy is a Minetest RUDP proxy server supporting multiple concurrent connections.
Proxy is a Minetest RUDP proxy server supporting multiple concurrent connections.

Jump to

Keyboard shortcuts

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