dtls

package
v0.7.10 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInsufficientBuffer = errors.New("buffer too small to hold the received data")

Functions

func Client

func Client(conn net.Conn, config *Config) (net.Conn, error)

Client establishes a DTLS connection using an existing connection and a seed.

func ClientWithContext

func ClientWithContext(ctx context.Context, conn net.Conn, config *Config) (net.Conn, error)

DialWithContext creates a DTLS connection to the given network address using the given shared secret

func Dial

func Dial(remoteAddr *net.UDPAddr, config *Config) (net.Conn, error)

Dial creates a DTLS connection to the given network address using the given shared secret

func DialWithContext

func DialWithContext(ctx context.Context, remoteAddr *net.UDPAddr, config *Config) (net.Conn, error)

DialWithContext like Dial, but includes context for cancellation and timeouts.

func Server

func Server(conn net.Conn, config *Config) (net.Conn, error)

Server establishes DTLS connection on the given conn using the sharedSecert

func ServerWithContext

func ServerWithContext(ctx context.Context, conn net.Conn, config *Config) (net.Conn, error)

ServerWithContext establishes DTLS connection on the given conn using the sharedSecert and context

Types

type Config

type Config struct {
	PSK         []byte
	SCTP        SCTPType
	Unordered   bool
	LogAuthFail func(*net.IP)
	LogOther    func(*net.IP)
}

type Listener

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

Listener represents a DTLS Listener

func Listen

func Listen(network string, laddr *net.UDPAddr, config *Config) (*Listener, error)

Listen creates a listener and starts listening

func NewListener

func NewListener(inner net.Listener, config *Config) (*Listener, error)

NewListener creates a DTLS listener which accepts connections from an inner Listener.

func (*Listener) Accept

func (l *Listener) Accept(config *Config) (net.Conn, error)

Accept accepts a connection with shared secret

func (*Listener) AcceptWithContext

func (l *Listener) AcceptWithContext(ctx context.Context, config *Config) (net.Conn, error)

AcceptWithContext accepts a connection with shared secret, with a context

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 closes the listener. Any blocked Accept operations will be unblocked and return errors. Already Accepted connections are not closed.

type Not1Reader

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

func (*Not1Reader) Read

func (n1r *Not1Reader) Read(p []byte) (n int, err error)

type SCTPConn

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

SCTPConn implements the net.Conn interface using sctp stream and DTLS conn

SCTPConn buffers incoming SCTP messages, allowing the caller to use SCTPConn as a TCP-like bytes stream net.Conn, with reads smaller than individual message sizes.

func (*SCTPConn) Close

func (s *SCTPConn) Close() error

func (*SCTPConn) LocalAddr

func (s *SCTPConn) LocalAddr() net.Addr

func (*SCTPConn) Read

func (s *SCTPConn) Read(b []byte) (int, error)

func (*SCTPConn) RemoteAddr

func (s *SCTPConn) RemoteAddr() net.Addr

func (*SCTPConn) SetDeadline

func (s *SCTPConn) SetDeadline(t time.Time) error

func (*SCTPConn) SetReadDeadline

func (s *SCTPConn) SetReadDeadline(t time.Time) error

func (*SCTPConn) SetWriteDeadline

func (s *SCTPConn) SetWriteDeadline(t time.Time) error

func (*SCTPConn) Write

func (s *SCTPConn) Write(b []byte) (int, error)

type SCTPType

type SCTPType int
const (
	ServerAccept SCTPType = iota
	ClientOpen
)

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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