attributes

package
v0.0.0-...-e01d51a Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2016 License: Apache-2.0 Imports: 4 Imported by: 0

README

##stun attributes Build Status GoDoc

stun-lib is a STUN (RFC 3489) library.

Documentation

Overview

stun-lib is a STUN (RFC 3489) libray.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Address2Array

func Address2Array(address Address) []byte

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

type Address struct {
	FirstOctet   int
	SencondOctet int
	ThirdOctet   int
	FourthOctet  int
}

Address ip address

func Array2Address

func Array2Address(ip []byte) Address

Array2Address 4 bytes convert to an ipv4 address

func String2Address

func String2Address(addr string) Address

String2Address ip(like 192.168.1.1) conver to an ipv4 address

func (Address) String

func (a Address) String() string

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

func (*BindingChange) Type

func (a *BindingChange) Type() AttributeType

Type get attribute type

type ChangeRequest

type ChangeRequest struct {
	ChangeIP   bool
	ChangePort bool
}

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

func (*ChangeRequest) Type

func (a *ChangeRequest) Type() AttributeType

Type get attribute type

type ChangedAddress

type ChangedAddress struct {
	Port    int
	Address Address
}

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

func (*ChangedAddress) Type

func (a *ChangedAddress) Type() AttributeType

Type get attribute type

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

Type get attribute type

type MappedAddress

type MappedAddress struct {
	Port    int
	Address Address
}

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

func (*MappedAddress) Type

func (a *MappedAddress) Type() AttributeType

Type get attribute type

type Password

type Password struct {
	Password string
}

Password atrribute

func NewPassword

func NewPassword() *Password

NewPassword create a Password attribute

func (*Password) Decode

func (a *Password) Decode(src []byte) (int, error)

Decode decode Password attribute

func (*Password) Encode

func (a *Password) Encode() (buf []byte, err error)

Encode encode Password message

func (*Password) Length

func (a *Password) Length() int

Length get len of atrribute (tlv)

func (*Password) String

func (a *Password) String() string

func (*Password) Type

func (a *Password) Type() AttributeType

Type get attribute type

type ResponseAddress

type ResponseAddress struct {
	Port    int
	Address Address
}

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

type SourceAddress struct {
	Port    int
	Address Address
}

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

func (*SourceAddress) Type

func (a *SourceAddress) Type() AttributeType

Type get attribute type

Jump to

Keyboard shortcuts

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