turnc

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2019 License: MIT Imports: 11 Imported by: 1

README

Build Status codecov GoDoc

TURNc

Package turnc implements TURN [RFC5766] client. Based on pion/stun and gortc/turn packages.

Work in progress

Contributing

Check out the contributing wiki to join the group of amazing people making this project possible:

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAlreadyBound means that selected permission already has bound channel number.
	ErrAlreadyBound = errors.New("channel already bound")
	// ErrNotBound means that selected permission already has no channel number.
	ErrNotBound = errors.New("channel is not bound")
)
View Source
var ErrNotImplemented = errors.New("functionality not implemented")

ErrNotImplemented means that functionality is not currently implemented, but it will be (eventually).

Functions

This section is empty.

Types

type Allocation

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

Allocation reflects TURN Allocation.

func (*Allocation) Create

func (a *Allocation) Create(peer net.Addr) (*Permission, error)

Create creates new permission to peer.

func (*Allocation) CreateUDP

func (a *Allocation) CreateUDP(addr *net.UDPAddr) (*Permission, error)

CreateUDP creates new UDP Permission to peer with provided addr.

func (*Allocation) Relayed added in v0.0.3

func (a *Allocation) Relayed() turn.RelayedAddress

Relayed returns the relayed address for the allocation

type Client

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

Client for TURN server.

Provides transparent net.Conn interfaces to remote peers.

func New added in v0.0.2

func New(o Options) (*Client, error)

New creates and initializes new TURN client.

func (*Client) Allocate

func (c *Client) Allocate() (*Allocation, error)

Allocate creates an allocation for current 5-tuple. Currently there can be only one allocation per client, because client wraps one net.Conn.

func (*Client) Close added in v0.0.6

func (c *Client) Close() error

func (*Client) RefreshRate

func (c *Client) RefreshRate() time.Duration

RefreshRate returns current rate of refresh requests.

type Options added in v0.0.2

type Options struct {
	Conn net.Conn
	STUN STUNClient            // optional STUN client
	Log  logging.LeveledLogger // defaults to Nop

	// Long-term integrity.
	Username string
	Password string

	// STUN client options.
	RTO          time.Duration
	NoRetransmit bool

	// TURN options.
	RefreshRate     time.Duration
	RefreshDisabled bool

	// ConnManualClose disables connection automatic close on Close().
	ConnManualClose bool
}

Options contains available config for TURN client.

type Permission

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

Permission implements net.PacketConn.

func (*Permission) Bind

func (p *Permission) Bind() error

Bind performs binding transaction, allocating channel binding for the permission.

func (*Permission) Binding

func (p *Permission) Binding() turn.ChannelNumber

Binding returns current channel number or 0 if not bound.

func (*Permission) Bound

func (p *Permission) Bound() bool

Bound returns true if channel number is bound for current permission.

func (*Permission) Close

func (p *Permission) Close() error

Close stops all refreshing loops for permission and removes it from allocation.

func (*Permission) LocalAddr

func (p *Permission) LocalAddr() net.Addr

LocalAddr is relayed address from TURN server.

func (*Permission) Read

func (p *Permission) Read(b []byte) (n int, err error)

Read data from peer.

func (*Permission) RemoteAddr

func (p *Permission) RemoteAddr() net.Addr

RemoteAddr is peer address.

func (*Permission) SetDeadline

func (p *Permission) SetDeadline(t time.Time) error

SetDeadline implements net.Conn.

func (*Permission) SetReadDeadline

func (p *Permission) SetReadDeadline(t time.Time) error

SetReadDeadline implements net.Conn.

func (*Permission) SetWriteDeadline

func (p *Permission) SetWriteDeadline(t time.Time) error

SetWriteDeadline implements net.Conn.

func (*Permission) Write

func (p *Permission) Write(b []byte) (n int, err error)

Write sends buffer to peer.

If permission is bound, the ChannelData message will be used.

type STUNClient

type STUNClient interface {
	Indicate(m *stun.Message) error
	Do(m *stun.Message, f func(e stun.Event)) error
	Close() error
}

STUNClient abstracts STUN protocol interaction.

Directories

Path Synopsis
cmd
e2e
turn-client Module
internal

Jump to

Keyboard shortcuts

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