turn

package
v0.0.0-...-8728e54 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AllocationTCP = uint8(6)
	AllocationUDP = uint8(17)
)
View Source
const (
	MethodAllocate         = uint16(0x3)
	MethodRefresh          = uint16(0x4)
	MethodSend             = uint16(0x6)
	MethodData             = uint16(0x7)
	MethodCreatePermission = uint16(0x8)
	MethodChannelBind      = uint16(0x9)
)

STUN methods introduced by the RFC 5766 Section 13.

View Source
const (
	AttrChannelNumber      = uint16(0x000c)
	AttrLifeTime           = uint16(0x000d)
	AttrXorPeerAddress     = uint16(0x0012)
	AttrData               = uint16(0x0013)
	AttrXorRelayedAddress  = uint16(0x0016)
	AttrEvenPort           = uint16(0x0018)
	AttrRequestedTransport = uint16(0x0019)
	AttrDontFragment       = uint16(0x001a)
	AttrReservationToken   = uint16(0x0022)
)

STUN attributes introduced by the RFC 5766 Section 14.

View Source
const (
	CodeForbidden                    = 403
	CodeAllocationMismatch           = 437
	CodeWrongCredentials             = 441
	CodeUnsupportedTransportProtocol = 442
	CodeAllocationQuotaReached       = 486
	CodeInsufficientCapacity         = 508
)

STUN errors introduced by the RFC 5766 Section 15.

Variables

View Source
var ErrNoAllocationResponse = errors.New("turn: no allocated address")
View Source
var ErrUnsupportedScheme = errors.New("turn: unsupported scheme")

Functions

func ErrorText

func ErrorText(code int) (r string)

ErrorText returns a reason phrase text for the STUN error code. It returns the empty string if the code is unknown.

func GetAttributeCodec

func GetAttributeCodec(at uint16) (c stun.AttrCodec)

GetAttributeCodec returns a STUN attribute codec for TURN.

func GetAttributeName

func GetAttributeName(at uint16) (n string)

GetAttributeName returns a STUN attribute name. It returns the empty string if the attribute is unknown.

func LongTermAuthKey

func LongTermAuthKey(username, password, realm string) func(attrs stun.Attributes) ([]byte, error)

Types

type Conn

type Conn struct {
	*stun.Client
	// contains filtered or unexported fields
}

func Allocate

func Allocate(uri, username, password string) (*Conn, error)

Allocate connects to the given TURN URI and makes the TURN allocation request. Returns the relayed transport address.

func NewConn

func NewConn(inner *stun.Client, addr *stun.Addr) *Conn

func (*Conn) RelayedAddr

func (c *Conn) RelayedAddr() *stun.Addr

type Server

type Server struct {
	*stun.Server
	LifeTime time.Duration
}

func NewServer

func NewServer() *Server

func (*Server) ServeSTUN

func (srv *Server) ServeSTUN(rw stun.ResponseWriter, r *stun.Message)

Jump to

Keyboard shortcuts

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