Documentation ¶
Index ¶
- Constants
- Variables
- type AddressFamily
- type Attribute
- type AttributeKey
- type Attributes
- type BaseAttribute
- type Client
- func (client *Client) Allocate() (net.IP, int, error)
- func (client *Client) ChannelBind(channelNumber int, peerIp net.IP, peerPort int) error
- func (client *Client) CreatePermission(peer net.IP) error
- func (client *Client) Read() ([]byte, error)
- func (client *Client) RefreshAllocation() error
- func (client *Client) Send(peer net.IP, port int, body []byte)
- func (client *Client) Shutdown() error
- type DialOption
- type STUNErrorMessage
- type STUNMessage
- func (message *STUNMessage) Attributes() (Attributes, error)
- func (message *STUNMessage) Encode() []byte
- func (message *STUNMessage) EncodeWithLength(length int) []byte
- func (message *STUNMessage) IsError() bool
- func (message *STUNMessage) MessageIntegrity(realm, username, password []byte) []byte
- func (message *STUNMessage) String() string
- type TwoBytesTree
- type XorAddressAttribute
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 (
)
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 ¶
func Dial ¶
func Dial(addr string, opt ...DialOption) *Client
func (*Client) ChannelBind ¶
channelNumber in the range 16384 through 32766
func (*Client) RefreshAllocation ¶
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 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
Click to show internal directories.
Click to hide internal directories.