Documentation ¶
Overview ¶
stun-lib is a STUN (RFC 3489) libray.
Index ¶
- func Address2Array(address Address) []byte
- func DecodeAttributes(src []byte) (attributes map[AttributeType]Attribute, n int, err error)
- type Address
- type Attribute
- type AttributeType
- type BindingChange
- type ChangeRequest
- type ChangedAddress
- type ConnectionRequestBinding
- type MappedAddress
- type Password
- type ResponseAddress
- type SourceAddress
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Address2Array ¶
Address2Array an ipv4 address convert to 4 bytes
func DecodeAttributes ¶
func DecodeAttributes(src []byte) (attributes map[AttributeType]Attribute, n int, err error)
DecodeAttributes deode attribtues from bytes
Types ¶
type Address ¶
Address ip address
func Array2Address ¶
Array2Address 4 bytes convert to an ipv4 address
func String2Address ¶
String2Address ip(like 192.168.1.1) conver to an ipv4 address
type Attribute ¶
type Attribute interface { //getType() uint16 //getLength() uint16 //getVal() string //parse(buf []byte) Encode() ([]byte, error) Decode([]byte) (int, error) Type() AttributeType Length() int String() string }
Attribute stun msg attribute
type AttributeType ¶
type AttributeType uint16
AttributeType is the stun attribute types.
const ( //MAPPEDADDRESS MappedAddress MAPPEDADDRESS AttributeType = 0x0001 //RESPONSEADDRESS ResponseAddress RESPONSEADDRESS AttributeType = 0x0002 //CHANGEREQUEST ChangeRequest CHANGEREQUEST AttributeType = 0x0003 //SOURCEADDRESS SourceAddress SOURCEADDRESS AttributeType = 0x0004 //CHANGEDADDRESS ChangedAddress CHANGEDADDRESS AttributeType = 0x0005 //USERNAME Username USERNAME AttributeType = 0x0006 //PASSWORD Password PASSWORD AttributeType = 0x0007 //MESSAGEINTEGRITY MessageIntegrity MESSAGEINTEGRITY AttributeType = 0x0008 //ERRORCODE ErrorCode ERRORCODE AttributeType = 0x0009 //UNKNOWNATTRIBUTE UnknownAttribute UNKNOWNATTRIBUTE AttributeType = 0x000a //REFLECTEDFROM ReflectedFrom REFLECTEDFROM AttributeType = 0x000b //CONNECTIONREQUESTBINDING ConnectionRequestBinding CONNECTIONREQUESTBINDING AttributeType = 0xC001 //BINDINGCHANGE BindingChange BINDINGCHANGE AttributeType = 0xC002 //DUMMY Dummy DUMMY AttributeType = 0x0000 )
func (AttributeType) New ¶
func (a AttributeType) New() (Attribute, error)
New creates a new attribute based on the attribute type.
type BindingChange ¶
type BindingChange struct {
// contains filtered or unexported fields
}
BindingChange atrribute
func NewBindingChange ¶
func NewBindingChange() *BindingChange
NewBindingChange create a BindingChange attribute
func (*BindingChange) Decode ¶
func (a *BindingChange) Decode(src []byte) (int, error)
Decode decode BindingChange attribute
func (*BindingChange) Encode ¶
func (a *BindingChange) Encode() (buf []byte, err error)
Encode encode BindingChange message
func (*BindingChange) Length ¶
func (a *BindingChange) Length() int
Length get len of atrribute (tlv)
func (*BindingChange) String ¶
func (a *BindingChange) String() string
type ChangeRequest ¶
ChangeRequest atrribute
func NewChangeRequest ¶
func NewChangeRequest() *ChangeRequest
NewChangeRequest create a ChangeRequest attribute
func (*ChangeRequest) Decode ¶
func (a *ChangeRequest) Decode(src []byte) (int, error)
Decode decode ChangeRequest attribute
func (*ChangeRequest) Encode ¶
func (a *ChangeRequest) Encode() (buf []byte, err error)
Encode encode ChangeRequest message
func (*ChangeRequest) Length ¶
func (a *ChangeRequest) Length() int
Length get len of atrribute (tlv)
func (*ChangeRequest) String ¶
func (a *ChangeRequest) String() string
type ChangedAddress ¶
ChangedAddress atrribute
func NewChangedAddress ¶
func NewChangedAddress() *ChangedAddress
NewChangedAddress create a ChangedAddress attribute
func (*ChangedAddress) Decode ¶
func (a *ChangedAddress) Decode(src []byte) (int, error)
Decode decode ChangedAddress attribute
func (*ChangedAddress) Encode ¶
func (a *ChangedAddress) Encode() (buf []byte, err error)
Encode encode ChangedAddress message
func (*ChangedAddress) Length ¶
func (a *ChangedAddress) Length() int
Length get len of atrribute (tlv)
func (*ChangedAddress) String ¶
func (a *ChangedAddress) String() string
type ConnectionRequestBinding ¶
type ConnectionRequestBinding struct {
Value string
}
ConnectionRequestBinding atrribute
func NewConnectionRequestBinding ¶
func NewConnectionRequestBinding() *ConnectionRequestBinding
NewConnectionRequestBinding create a ConnectionRequestBinding attribute
func (*ConnectionRequestBinding) Decode ¶
func (a *ConnectionRequestBinding) Decode(src []byte) (int, error)
Decode decode ConnectionRequestBinding attribute
func (*ConnectionRequestBinding) Encode ¶
func (a *ConnectionRequestBinding) Encode() (buf []byte, err error)
Encode encode ConnectionRequestBinding message
func (*ConnectionRequestBinding) Length ¶
func (a *ConnectionRequestBinding) Length() int
Length get len of atrribute (tlv)
func (*ConnectionRequestBinding) String ¶
func (a *ConnectionRequestBinding) String() string
func (*ConnectionRequestBinding) Type ¶
func (a *ConnectionRequestBinding) Type() AttributeType
Type get attribute type
type MappedAddress ¶
MappedAddress atrribute
func NewMappedAddress ¶
func NewMappedAddress() *MappedAddress
NewMappedAddress create a MappedAddress attribute
func (*MappedAddress) Decode ¶
func (a *MappedAddress) Decode(src []byte) (int, error)
Decode decode MappedAddress attribute
func (*MappedAddress) Encode ¶
func (a *MappedAddress) Encode() (buf []byte, err error)
Encode encode MappedAddress message
func (*MappedAddress) Length ¶
func (a *MappedAddress) Length() int
Length get len of atrribute (tlv)
func (*MappedAddress) String ¶
func (a *MappedAddress) String() string
type Password ¶
type Password struct {
Password string
}
Password atrribute
type ResponseAddress ¶
ResponseAddress atrribute
func NewResponseAddress ¶
func NewResponseAddress() *ResponseAddress
NewResponseAddress create a ResponseAddress attribute
func (*ResponseAddress) Decode ¶
func (a *ResponseAddress) Decode(src []byte) (int, error)
Decode decode ResponseAddress attribute
func (*ResponseAddress) Encode ¶
func (a *ResponseAddress) Encode() (buf []byte, err error)
Encode encode ResponseAddress message
func (*ResponseAddress) Length ¶
func (a *ResponseAddress) Length() int
Length get len of atrribute (tlv)
func (*ResponseAddress) String ¶
func (a *ResponseAddress) String() string
func (*ResponseAddress) Type ¶
func (a *ResponseAddress) Type() AttributeType
Type get attribute type
type SourceAddress ¶
SourceAddress atrribute
func NewSourceAddress ¶
func NewSourceAddress() *SourceAddress
NewSourceAddress create a SourceAddress attribute
func (*SourceAddress) Decode ¶
func (a *SourceAddress) Decode(src []byte) (int, error)
Decode decode SourceAddress attribute
func (*SourceAddress) Encode ¶
func (a *SourceAddress) Encode() (buf []byte, err error)
Encode encode SourceAddress message
func (*SourceAddress) Length ¶
func (a *SourceAddress) Length() int
Length get len of atrribute (tlv)
func (*SourceAddress) String ¶
func (a *SourceAddress) String() string