dst

package
v0.0.0-...-198281b Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2019 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package dst implements the Datagram Stream Transfer protocol.

DST is a way to get reliable stream connections (like TCP) on top of UDP.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrClosedConn       = &Error{"operation on closed connection"}
	ErrClosedMux        = &Error{"operation on closed mux"}
	ErrHandshakeTimeout = &Error{"handshake timeout"}
	ErrNotDST           = &Error{"network is not dst"}
	ErrNotImplemented   = &Error{"not implemented"}
)

Functions

func SetLogger

func SetLogger(l *logger.Logger)

Types

type Conn

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

Conn is an SDT connection carried over a Mux.

func (*Conn) Close

func (c *Conn) Close() error

Close closes the connection. Any blocked Read or Write operations will be unblocked and return errors.

func (*Conn) GetStatistics

func (c *Conn) GetStatistics() Statistics

GetStatistics returns a snapsht of the current connection statistics.

func (*Conn) LocalAddr

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

LocalAddr returns the local network address.

func (*Conn) Read

func (c *Conn) Read(b []byte) (n int, err error)

Read reads data from the connection. Read can be made to time out and return a Error with Timeout() == true after a fixed time limit; see SetDeadline and SetReadDeadline.

func (*Conn) RemoteAddr

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

RemoteAddr returns the remote network address.

func (*Conn) SetDeadline

func (c *Conn) SetDeadline(t time.Time) error

SetDeadline sets the read and write deadlines associated with the connection. It is equivalent to calling both SetReadDeadline and SetWriteDeadline.

A deadline is an absolute time after which I/O operations fail with a timeout (see type Error) instead of blocking. The deadline applies to all future I/O, not just the immediately following call to Read or Write.

An idle timeout can be implemented by repeatedly extending the deadline after successful Read or Write calls.

A zero value for t means I/O operations will not time out.

BUG(jb): SetDeadline is not implemented.

func (*Conn) SetReadDeadline

func (c *Conn) SetReadDeadline(t time.Time) error

SetReadDeadline sets the deadline for future Read calls. A zero value for t means Read will not time out.

BUG(jb): SetReadDeadline is not implemented.

func (*Conn) SetWriteDeadline

func (c *Conn) SetWriteDeadline(t time.Time) error

SetWriteDeadline sets the deadline for future Write calls. Even if write times out, it may return n > 0, indicating that some of the data was successfully written. A zero value for t means Write will not time out.

BUG(jb): SetWriteDeadline is not implemented.

func (*Conn) String

func (c *Conn) String() string

String returns a string representation of the connection.

func (*Conn) Write

func (c *Conn) Write(b []byte) (n int, err error)

Write writes data to the connection. Write can be made to time out and return a Error with Timeout() == true after a fixed time limit; see SetDeadline and SetWriteDeadline.

type Error

type Error struct {
	Err string
}

Error represents the various dst-internal error conditions.

func (Error) Error

func (e Error) Error() string

Error returns a string representation of the error.

type Mux

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

Mux is a UDP multiplexer of DST connections.

func NewMux

func NewMux(conn net.PacketConn, packetSize int) *Mux

NewMux creates a new DST Mux on top of a packet connection.

func (*Mux) Accept

func (m *Mux) Accept() (net.Conn, error)

Accept waits for and returns the next connection to the listener.

func (*Mux) AcceptDST

func (m *Mux) AcceptDST() (*Conn, error)

AcceptDST waits for and returns the next connection to the listener.

func (*Mux) Addr

func (m *Mux) Addr() net.Addr

Addr returns the listener's network address.

func (*Mux) Close

func (m *Mux) Close() error

Close closes the listener. Any blocked Accept operations will be unblocked and return errors.

func (*Mux) Dial

func (m *Mux) Dial(network, addr string) (net.Conn, error)

Dial connects to the address on the named network.

Network must be "dst".

Addresses have the form host:port. If host is a literal IPv6 address or host name, it must be enclosed in square brackets as in "[::1]:80", "[ipv6-host]:http" or "[ipv6-host%zone]:80". The functions JoinHostPort and SplitHostPort manipulate addresses in this form.

Examples:

Dial("dst", "12.34.56.78:80")
Dial("dst", "google.com:http")
Dial("dst", "[2001:db8::1]:http")
Dial("dst", "[fe80::1%lo0]:80")

func (*Mux) DialDST

func (m *Mux) DialDST(network, addr string) (*Conn, error)

Dial connects to the address on the named network.

Network must be "dst".

Addresses have the form host:port. If host is a literal IPv6 address or host name, it must be enclosed in square brackets as in "[::1]:80", "[ipv6-host]:http" or "[ipv6-host%zone]:80". The functions JoinHostPort and SplitHostPort manipulate addresses in this form.

Examples:

Dial("dst", "12.34.56.78:80")
Dial("dst", "google.com:http")
Dial("dst", "[2001:db8::1]:http")
Dial("dst", "[fe80::1%lo0]:80")

func (*Mux) String

func (m *Mux) String() string

type Statistics

type Statistics struct {
	DataPacketsIn     int64
	DataPacketsOut    int64
	DataBytesIn       int64
	DataBytesOut      int64
	ResentPackets     int64
	DroppedPackets    int64
	OutOfOrderPackets int64
}

func (Statistics) String

func (s Statistics) String() string

String returns a printable represetnation of the Statistics.

Notes

Bugs

  • SetDeadline is not implemented.

  • SetReadDeadline is not implemented.

  • SetWriteDeadline is not implemented.

Jump to

Keyboard shortcuts

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