sctp

package
v0.0.0-...-ffb35f4 Latest Latest
Warning

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

Go to latest
Published: May 27, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrHandshakeTimeout = errors.New("sctp handshake timed out")

ErrHandshakeTimeout if handshake failed.

Functions

func IsPrivateIP

func IsPrivateIP(ips string) bool

IsPrivateIP returns true if IP is in private range.

func SetLogger

func SetLogger(l Logger)

SetLogger sets logger for the package.

Types

type Addr

type Addr struct {
	IP   string
	Port int
}

Addr is an SCTP address.

func ParseAddr

func ParseAddr(s string) (*Addr, error)

ParseAddr creates an Addr from a string.

func (Addr) String

func (a Addr) String() string

func (Addr) UDPAddr

func (a Addr) UDPAddr() (*net.UDPAddr, error)

UDPAddr returns UDP address.

type Client

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

Client for SCTP.

func NewClient

func NewClient() *Client

NewClient creates SCTP client.

func (*Client) Close

func (c *Client) Close()

Close ...

func (*Client) Connect

func (c *Client) Connect(ctx context.Context, peerAddr *Addr) error

Connect to peer. Call this with address from STUN.

func (*Client) ListenForPeer

func (c *Client) ListenForPeer(ctx context.Context, peerAddr *Addr) error

ListenForPeer for connections from peer.

func (*Client) Local

func (c *Client) Local() (*Addr, error)

Local listens for UDP on local address. Use STUN instead for a remote address.

func (*Client) Read

func (c *Client) Read(ctx context.Context, b []byte) (int, error)

Read from stream (if connected).

func (*Client) STUN

func (c *Client) STUN(ctx context.Context, timeout time.Duration) (*Addr, error)

STUN initiates the stun requests and returns an address.

func (*Client) Write

func (c *Client) Write(ctx context.Context, b []byte) error

Write to stream (if connected).

type ContextLogger

type ContextLogger interface {
	Debugf(ctx context.Context, format string, args ...interface{})
	Infof(ctx context.Context, format string, args ...interface{})
	Warningf(ctx context.Context, format string, args ...interface{})
	Errorf(ctx context.Context, format string, args ...interface{})
}

ContextLogger interface used in this package with request context.

func NewContextLogger

func NewContextLogger(lev LogLevel) ContextLogger

NewContextLogger ...

type LogLevel

type LogLevel int

LogLevel ...

const (
	// DebugLevel ...
	DebugLevel LogLevel = 3
	// InfoLevel ...
	InfoLevel LogLevel = 2
	// WarnLevel ...
	WarnLevel LogLevel = 1
	// ErrLevel ...
	ErrLevel LogLevel = 0
)

func (LogLevel) String

func (l LogLevel) String() string

type Logger

type Logger interface {
	Debugf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Warningf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
	Fatalf(format string, args ...interface{})
}

Logger interface used in this package.

func NewLogger

func NewLogger(lev LogLevel) Logger

NewLogger ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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