turn

package module
v0.0.0-...-e3e78e3 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2018 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AttributeMappedAddress      = "MAPPED-ADDRESS"
	AttributeSourceAddress      = "SOURCE-ADDRESS"
	AttributeUsername           = "USERNAME"
	AttributeMessageIntegrity   = "MESSAGE-INTEGRITY"
	AttributeErrorCode          = "ERROR-CODE"
	AttributeUnknown            = "UNKNOWN"
	AttributeChannelNumber      = "CHANNEL-NUMBER"
	AttributeLifetime           = "LIFETIME"
	AttributeXorPeerAddress     = "XOR-PEER-ADDRESS"
	AttributeData               = "DATA"
	AttributeRealm              = "REALM"
	AttributeNonce              = "NONCE"
	AttributeXorRelayedAddress  = "XOR-RELAYED-ADDRESS"
	AttributeRequestedTransport = "REQUESTED-TRANSPORT"
	AttributeDontFragment       = "DONT-FRAGMENT"
	AttributeXorMappedAddress   = "XOR-MAPPED-ADDRESS"
	AttributeReservationToken   = "RESERVATION-TOKEN"
	AttributeSoftware           = "SOFTWARE"
)
View Source
const (
	AddressFamilyV4 = 1 + iota
	AddressFamilyV6
)
View Source
const (
	MethodAllocate          = "Allocate"
	MethodRefreshAllocation = "Refresh"
	MethodSend              = "Send"
	MethodData              = "Data"
	MethodCreatePermission  = "CreatePermission"
	MethodChannelBind       = "CHannelBind"
)
View Source
const (
	ErrorUnauthorized = 401
)
View Source
const (
	ReadBufferLength = 1500
)

Variables

View Source
var AttributeRegistry = map[string][]byte{
	AttributeMappedAddress:      {0x00, 0x01},
	AttributeSourceAddress:      {0x00, 0x04},
	AttributeUsername:           {0x00, 0x06},
	AttributeMessageIntegrity:   {0x00, 0x08},
	AttributeErrorCode:          {0x00, 0x09},
	AttributeUnknown:            {0x00, 0x0a},
	AttributeChannelNumber:      {0x00, 0x0c},
	AttributeLifetime:           {0x00, 0x0d},
	AttributeXorPeerAddress:     {0x00, 0x12},
	AttributeData:               {0x00, 0x13},
	AttributeRealm:              {0x00, 0x14},
	AttributeNonce:              {0x00, 0x15},
	AttributeXorRelayedAddress:  {0x00, 0x16},
	AttributeRequestedTransport: {0x00, 0x19},
	AttributeDontFragment:       {0x00, 0x1a},
	AttributeXorMappedAddress:   {0x00, 0x20},
	AttributeReservationToken:   {0x00, 0x22},
	AttributeSoftware:           {0x80, 0x22},
}
View Source
var (
	ErrInvalidPacket = errors.New("invalid packet")
)
View Source
var MessageCookie = []byte{0x21, 0x12, 0xA4, 0x42}
View Source
var MethodRegistry = map[string][]byte{
	MethodAllocate:          {0x00, 0x03},
	MethodRefreshAllocation: {0x00, 0x04},
	MethodSend:              {0x00, 0x16},
	MethodData:              {0x00, 0x07},
	MethodCreatePermission:  {0x00, 0x08},
	MethodChannelBind:       {0x00, 0x09},
}
View Source
var (
	TransportUDP = []byte{0x11, 0x00, 0x00, 0x00}
)

Functions

This section is empty.

Types

type AddressFamily

type AddressFamily int

type Attribute

type Attribute interface {
	Key() AttributeKey
	Value() []byte
}

type AttributeKey

type AttributeKey []byte

func (AttributeKey) String

func (k AttributeKey) String() string

func (AttributeKey) TypeString

func (k AttributeKey) TypeString() string

type Attributes

type Attributes []Attribute

func ParseAttributes

func ParseAttributes(buf []byte) (Attributes, error)

func (Attributes) Encode

func (attrs Attributes) Encode() []byte

type BaseAttribute

type BaseAttribute struct {
	RawKey   AttributeKey
	RawValue []byte
}

func NewBaseAttribute

func NewBaseAttribute(key string, value []byte) *BaseAttribute

func (BaseAttribute) Key

func (attr BaseAttribute) Key() AttributeKey

func (BaseAttribute) String

func (attr BaseAttribute) String() string

func (BaseAttribute) Value

func (attr BaseAttribute) Value() []byte

type Client

type Client struct {
	Username []byte
	Password []byte
	// contains filtered or unexported fields
}

func Dial

func Dial(addr string, opt ...DialOption) *Client

func (*Client) Allocate

func (client *Client) Allocate() (net.IP, int, error)

func (*Client) ChannelBind

func (client *Client) ChannelBind(channelNumber int, peerIp net.IP, peerPort int) error

channelNumber in the range 16384 through 32766

func (*Client) CreatePermission

func (client *Client) CreatePermission(peer net.IP) error

func (*Client) Read

func (client *Client) Read() ([]byte, error)

func (*Client) RefreshAllocation

func (client *Client) RefreshAllocation() error

func (*Client) Send

func (client *Client) Send(peer net.IP, port int, body []byte)

func (*Client) Shutdown

func (client *Client) Shutdown() error

type DialOption

type DialOption func(*Client)

func WithLongTermCredential

func WithLongTermCredential(username, password string) DialOption

type STUNErrorMessage

type STUNErrorMessage STUNMessage

func (STUNErrorMessage) Code

func (message STUNErrorMessage) Code() int

func (STUNErrorMessage) ErrorMessage

func (message STUNErrorMessage) ErrorMessage() string

type STUNMessage

type STUNMessage struct {
	Type          string
	TransactionId []byte
	Attrs         Attributes
	// contains filtered or unexported fields
}

func NewSTUNMessage

func NewSTUNMessage(t string) *STUNMessage

func ParseSTUNMessage

func ParseSTUNMessage(buf []byte) (*STUNMessage, error)

func (*STUNMessage) Attributes

func (message *STUNMessage) Attributes() (Attributes, error)

func (*STUNMessage) Encode

func (message *STUNMessage) Encode() []byte

func (*STUNMessage) EncodeWithLength

func (message *STUNMessage) EncodeWithLength(length int) []byte

func (*STUNMessage) IsError

func (message *STUNMessage) IsError() bool

func (*STUNMessage) MessageIntegrity

func (message *STUNMessage) MessageIntegrity(realm, username, password []byte) []byte

func (*STUNMessage) String

func (message *STUNMessage) String() string

type TwoBytesTree

type TwoBytesTree map[byte]map[byte]string
var TreeAttribute TwoBytesTree
var TreeMethod TwoBytesTree

func (TwoBytesTree) Find

func (t TwoBytesTree) Find(v []byte) (string, error)

type XorAddressAttribute

type XorAddressAttribute struct {
	Family  AddressFamily
	Port    int
	Address net.IP
	// contains filtered or unexported fields
}

func NewXorAddressAttribute

func NewXorAddressAttribute(key string) *XorAddressAttribute

func ParseXorAddressAttribute

func ParseXorAddressAttribute(key, value []byte) XorAddressAttribute

func (XorAddressAttribute) Key

func (attr XorAddressAttribute) Key() AttributeKey

func (XorAddressAttribute) String

func (attr XorAddressAttribute) String() string

func (XorAddressAttribute) Value

func (attr XorAddressAttribute) Value() []byte

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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