Versions in this module Expand all Collapse all v0 v0.3.4 May 22, 2020 Changes in this version + const CodeUnauthorised + const DefaultPort + const DefaultTLSPort + const TransactionIDSize + var BindingError = NewType(MethodBinding, ClassErrorResponse) + var BindingRequest = NewType(MethodBinding, ClassRequest) + var BindingSuccess = NewType(MethodBinding, ClassSuccessResponse) + var ErrAgentClosed = errors.New("agent is closed") + var ErrAttributeNotFound = errors.New("attribute not found") + var ErrAttributeSizeInvalid = errors.New("attribute size is invalid") + var ErrAttributeSizeOverflow = errors.New("attribute size overflow") + var ErrBadIPLength = errors.New("invalid length of IP value") + var ErrBadUnknownAttrsSize = errors.New("bad UNKNOWN-ATTRIBUTES size") + var ErrClientClosed = errors.New("client is closed") + var ErrClientNotInitialized = errors.New("client not initialized") + var ErrDecodeToNil = errors.New("attempt to decode to nil message") + var ErrFingerprintBeforeIntegrity = errors.New("FINGERPRINT before MESSAGE-INTEGRITY attribute") + var ErrFingerprintMismatch = errors.New("fingerprint check failed") + var ErrIntegrityMismatch = errors.New("integrity check failed") + var ErrNoConnection = errors.New("no connection provided") + var ErrNoDefaultReason = errors.New("no default reason for ErrorCode") + var ErrTransactionExists = errors.New("transaction exists with same id") + var ErrTransactionNotExists = errors.New("transaction not exists") + var ErrTransactionStopped = errors.New("transaction is stopped") + var ErrTransactionTimeOut = errors.New("transaction is timed out") + var ErrUnexpectedHeaderEOF = errors.New("unexpected EOF: not enough bytes to read header") + func CheckOverflow(_ AttrType, got, max int) error + func CheckSize(_ AttrType, got, expected int) error + func Decode(data []byte, m *Message) error + func FingerprintValue(b []byte) uint32 + func IsAttrSizeInvalid(err error) bool + func IsAttrSizeOverflow(err error) bool + func IsMessage(b []byte) bool + func NewTransactionID() (b [TransactionIDSize]byte) + func WithNoRetransmit(c *Client) + type Agent struct + func NewAgent(h Handler) *Agent + func (a *Agent) Close() error + func (a *Agent) Collect(gcTime time.Time) error + func (a *Agent) Process(m *Message) error + func (a *Agent) SetHandler(h Handler) error + func (a *Agent) Start(id [TransactionIDSize]byte, deadline time.Time) error + func (a *Agent) Stop(id [TransactionIDSize]byte) error + func (a *Agent) StopWithError(id [TransactionIDSize]byte, err error) error + type AlternateServer struct + IP net.IP + Port int + func (s *AlternateServer) AddTo(m *Message) error + func (s *AlternateServer) GetFrom(m *Message) error + type AttrType uint16 + const AttrAlternateServer + const AttrChangeRequest + const AttrChannelNumber + const AttrConnectionID + const AttrData + const AttrDontFragment + const AttrErrorCode + const AttrEvenPort + const AttrFingerprint + const AttrICEControlled + const AttrICEControlling + const AttrLifetime + const AttrMappedAddress + const AttrMessageIntegrity + const AttrNonce + const AttrOrigin + const AttrOtherAddress + const AttrPriority + const AttrRealm + const AttrRequestedAddressFamily + const AttrRequestedTransport + const AttrReservationToken + const AttrSoftware + const AttrUnknownAttributes + const AttrUseCandidate + const AttrUsername + const AttrXORMappedAddress + const AttrXORPeerAddress + const AttrXORRelayedAddress + func (t AttrType) Optional() bool + func (t AttrType) Required() bool + func (t AttrType) String() string + func (t AttrType) Value() uint16 + type Attributes []RawAttribute + func (a Attributes) Get(t AttrType) (RawAttribute, bool) + type Checker interface + Check func(m *Message) error + type Client struct + func Dial(network, address string) (*Client, error) + func NewClient(conn Connection, options ...ClientOption) (*Client, error) + func (c *Client) Close() error + func (c *Client) Do(m *Message, f func(Event)) error + func (c *Client) Indicate(m *Message) error + func (c *Client) SetRTO(rto time.Duration) + func (c *Client) Start(m *Message, h Handler) error + type ClientAgent interface + Close func() error + Collect func(time.Time) error + Process func(*Message) error + SetHandler func(h Handler) error + Start func(id [TransactionIDSize]byte, deadline time.Time) error + Stop func(id [TransactionIDSize]byte) error + type ClientOption func(c *Client) + var WithNoConnClose ClientOption = func(c *Client) { ... } + func WithAgent(a ClientAgent) ClientOption + func WithClock(clock Clock) ClientOption + func WithCollector(coll Collector) ClientOption + func WithHandler(h Handler) ClientOption + func WithRTO(rto time.Duration) ClientOption + func WithTimeoutRate(d time.Duration) ClientOption + type Clock interface + Now func() time.Time + type CloseErr struct + AgentErr error + ConnectionErr error + func (c CloseErr) Error() string + type Collector interface + Close func() error + Start func(rate time.Duration, f func(now time.Time)) error + type Connection interface + type DecodeErr struct + Message string + Place DecodeErrPlace + func (e DecodeErr) Error() string + func (e DecodeErr) IsInvalidCookie() bool + func (e DecodeErr) IsPlace(p DecodeErrPlace) bool + func (e DecodeErr) IsPlaceChildren(c string) bool + func (e DecodeErr) IsPlaceParent(p string) bool + type DecodeErrPlace struct + Children string + Parent string + func (p DecodeErrPlace) String() string + type ErrorCode int + const CodeAddrFamilyNotSupported + const CodeAllocMismatch + const CodeAllocQuotaReached + const CodeBadRequest + const CodeConnAlreadyExists + const CodeConnTimeoutOrFailure + const CodeForbidden + const CodeInsufficientCapacity + const CodePeerAddrFamilyMismatch + const CodeRoleConflict + const CodeServerError + const CodeStaleNonce + const CodeTryAlternate + const CodeUnauthorized + const CodeUnknownAttribute + const CodeUnsupportedTransProto + const CodeWrongCredentials + func (c ErrorCode) AddTo(m *Message) error + type ErrorCodeAttribute struct + Code ErrorCode + Reason []byte + func (c *ErrorCodeAttribute) GetFrom(m *Message) error + func (c ErrorCodeAttribute) AddTo(m *Message) error + func (c ErrorCodeAttribute) String() string + type Event struct + Error error + Message *Message + TransactionID [TransactionIDSize]byte + type FingerprintAttr struct + var Fingerprint FingerprintAttr + func (FingerprintAttr) AddTo(m *Message) error + func (FingerprintAttr) Check(m *Message) error + type Getter interface + GetFrom func(m *Message) error + type Handler func(e Event) + var NoopHandler Handler = func(e Event) { ... } + type MappedAddress struct + IP net.IP + Port int + func (a *MappedAddress) AddTo(m *Message) error + func (a *MappedAddress) GetFrom(m *Message) error + func (a MappedAddress) String() string + type Message struct + Attributes Attributes + Length uint32 + Raw []byte + TransactionID [TransactionIDSize]byte + Type MessageType + func Build(setters ...Setter) (*Message, error) + func MustBuild(setters ...Setter) *Message + func New() *Message + func (m *Message) Add(t AttrType, v []byte) + func (m *Message) AddTo(b *Message) error + func (m *Message) Build(setters ...Setter) error + func (m *Message) Check(checkers ...Checker) error + func (m *Message) CloneTo(b *Message) error + func (m *Message) Contains(t AttrType) bool + func (m *Message) Decode() error + func (m *Message) Encode() + func (m *Message) Equal(b *Message) bool + func (m *Message) ForEach(t AttrType, f func(m *Message) error) error + func (m *Message) Get(t AttrType) ([]byte, error) + func (m *Message) NewTransactionID() error + func (m *Message) Parse(getters ...Getter) error + func (m *Message) ReadFrom(r io.Reader) (int64, error) + func (m *Message) Reset() + func (m *Message) SetType(t MessageType) + func (m *Message) String() string + func (m *Message) Write(tBuf []byte) (int, error) + func (m *Message) WriteAttributes() + func (m *Message) WriteHeader() + func (m *Message) WriteLength() + func (m *Message) WriteTo(w io.Writer) (int64, error) + func (m *Message) WriteTransactionID() + func (m *Message) WriteType() + type MessageClass byte + const ClassErrorResponse + const ClassIndication + const ClassRequest + const ClassSuccessResponse + func (c MessageClass) String() string + type MessageIntegrity []byte + func NewLongTermIntegrity(username, realm, password string) MessageIntegrity + func NewShortTermIntegrity(password string) MessageIntegrity + func (i MessageIntegrity) AddTo(m *Message) error + func (i MessageIntegrity) Check(m *Message) error + func (i MessageIntegrity) String() string + type MessageType struct + Class MessageClass + Method Method + func NewType(method Method, class MessageClass) MessageType + func (t *MessageType) ReadValue(v uint16) + func (t MessageType) AddTo(m *Message) error + func (t MessageType) String() string + func (t MessageType) Value() uint16 + type Method uint16 + const MethodAllocate + const MethodBinding + const MethodChannelBind + const MethodConnect + const MethodConnectionAttempt + const MethodConnectionBind + const MethodCreatePermission + const MethodData + const MethodRefresh + const MethodSend + func (m Method) String() string + type Nonce []byte + func NewNonce(nonce string) Nonce + func (n *Nonce) GetFrom(m *Message) error + func (n Nonce) AddTo(m *Message) error + func (n Nonce) String() string + type OtherAddress struct + IP net.IP + Port int + func (a OtherAddress) String() string + func (s *OtherAddress) AddTo(m *Message) error + func (s *OtherAddress) GetFrom(m *Message) error + type RawAttribute struct + Length uint16 + Type AttrType + Value []byte + func (a RawAttribute) AddTo(m *Message) error + func (a RawAttribute) Equal(b RawAttribute) bool + func (a RawAttribute) String() string + type Realm []byte + func NewRealm(realm string) Realm + func (n *Realm) GetFrom(m *Message) error + func (n Realm) AddTo(m *Message) error + func (n Realm) String() string + type Setter interface + AddTo func(m *Message) error + var TransactionID Setter = transactionIDSetter{} + func NewTransactionIDSetter(value [TransactionIDSize]byte) Setter + type Software []byte + func NewSoftware(software string) Software + func (s *Software) GetFrom(m *Message) error + func (s Software) AddTo(m *Message) error + func (s Software) String() string + type StopErr struct + Cause error + Err error + func (e StopErr) Error() string + type TextAttribute []byte + func (v *TextAttribute) GetFromAs(m *Message, t AttrType) error + func (v TextAttribute) AddToAs(m *Message, t AttrType, maxLen int) error + type UnknownAttributes []AttrType + func (a *UnknownAttributes) GetFrom(m *Message) error + func (a UnknownAttributes) AddTo(m *Message) error + func (a UnknownAttributes) String() string + type Username []byte + func NewUsername(username string) Username + func (u *Username) GetFrom(m *Message) error + func (u Username) AddTo(m *Message) error + func (u Username) String() string + type XORMappedAddress struct + IP net.IP + Port int + func (a *XORMappedAddress) GetFrom(m *Message) error + func (a *XORMappedAddress) GetFromAs(m *Message, t AttrType) error + func (a XORMappedAddress) AddTo(m *Message) error + func (a XORMappedAddress) AddToAs(m *Message, t AttrType) error + func (a XORMappedAddress) String() string