Documentation ¶
Index ¶
Constants ¶
View Source
const ( BindingRequest uint16 = 0x0001 BindingSuccessResponse uint16 = 0x0101 BindingErrorResponse uint16 = 0x0111 )
View Source
const ( MessageHeaderLength = 20 TransactionIDLength = 12 )
View Source
const ( AttributeXorMappedAddress uint16 = 0x0020 AttributeErrorCode uint16 = 0x0009 )
View Source
const ClazzBadRequest uint8 = 0x04
View Source
const ErrNumBadRequest uint8 = 0x00
View Source
const ErrorCodePadding uint16 = 0x0000
View Source
const FamilyV4 uint8 = 0x01
View Source
const FamilyV6 uint8 = 0x02
View Source
const MagicCookie uint32 = 0x2112A442
View Source
const Offset uint8 = 0x00
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
func NewClient ¶
serverAddr is STUN server address. If localAddr is nil, a local address is automatically chosen.
type ErrorResponse ¶
type ErrorResponse struct {
Header MessageHeader
}
type IPV4Attribute ¶
type IPV4Attribute struct { XorMappedAddressAttribute XAddress uint32 }
type IPV6Attribute ¶
type IPV6Attribute struct { XorMappedAddressAttribute XAddress [16]uint8 }
type MessageHeader ¶
type MessageHeader struct { Type uint16 Length uint16 MagicCookie uint32 TransactionID [TransactionIDLength]byte }
func NewMessage ¶
func NewMessage(buffer []byte) MessageHeader
func (*MessageHeader) CreateErrorResponse ¶
func (m *MessageHeader) CreateErrorResponse() []byte
func (*MessageHeader) CreateSuccessResponse ¶
func (m *MessageHeader) CreateSuccessResponse(port uint16, address net.IP) []byte
func (*MessageHeader) ValidateAsBindingRequest ¶
func (m *MessageHeader) ValidateAsBindingRequest() error
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) ListenAndServe ¶
type SuccessV4Response ¶
type SuccessV4Response struct { Header MessageHeader Attribute IPV4Attribute }
type SuccessV6Response ¶
type SuccessV6Response struct { Header MessageHeader Attribute IPV6Attribute }
Click to show internal directories.
Click to hide internal directories.