data

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2016 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BadFormat              StreamErrorCondition = "bad-format"
	BadNamespacePrefix                          = "bad-namespace-prefix"
	Conflict                                    = "conflict"
	ConnectionTimeout                           = "connection-timeout"
	HostGone                                    = "host-gone"
	HostUnknown                                 = "host-unknown"
	ImproperAddressing                          = "improper-addressing"
	InternalServerError                         = "internal-server-error"
	InvalidFrom                                 = "invalid-from"
	InvalidNamespace                            = "invalid-namespace"
	InvalidXML                                  = "invalid-xml"
	NotAuthorized                               = "not-authorized"
	NotWellFormed                               = "not-well-formed"
	PolicyViolation                             = "policy-violation"
	RemoteConnectionFailed                      = "remote-connection-failed"
	Reset                                       = "reset"
	ResourceConstraint                          = "resource-constraint"
	RestrictedXML                               = "restricted-xml"
	SeeOtherHost                                = "see-other-host"
	SystemShutdown                              = "system-shutdown"
	UndefinedCondition                          = "undefined-condition"
	UnsupportedEncoding                         = "unsupported-encoding"
	UnsupportedFeature                          = "unsupported-feature"
	UnsupportedStanzaType                       = "unsupported-stanza-type"
	UnsupportedVersion                          = "unsupported-version"
)

Stream error conditions as defined in RFC 6120, section 4.9.3

View Source
const (
	SASLAborted              SASLErrorCondition = "aborted"
	SASLAccountDisabled                         = "account-disabled"
	SASLCredentialsExpired                      = "credentials-expired"
	SASLEncryptionRequired                      = "encryption-required"
	SASLIncorrectEncoding                       = "incorrect-encoding"
	SASLInvalidAuthzid                          = "invalid-authzid"
	SASLInvalidMechanism                        = "invalid-mechanism"
	SASLMalformedRequest                        = "malformed-request"
	SASLMechanismTooWeak                        = "mechanism-too-weak"
	SASLNotAuthorized                           = "not-authorized"
	SASLTemporaryAuthFailure                    = "temporary-auth-failure"
)

SASL error conditions as defined in RFC 6120, section 6.5

Variables

This section is empty.

Functions

This section is empty.

Types

type Any

type Any struct {
	XMLName xml.Name
	Body    string `xml:",innerxml"`
}

Any provides a convenient way to debug any child element

type BindBind

type BindBind struct {
	XMLName  xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-bind bind"`
	Resource string   `xml:"resource"`
	Jid      string   `xml:"jid"`
}

BindBind represents a bind RFC 6120, section 7

type BobData

type BobData struct {
	XMLName  xml.Name `xml:"urn:xmpp:bob data"`
	CID      string   `xml:"cid,attr"`
	MIMEType string   `xml:"type,attr"`
	Base64   string   `xml:",chardata"`
}

BobData is a data element from http://xmpp.org/extensions/xep-0231.html.

type BooleanFormField

type BooleanFormField struct {
	FormField

	Result bool
}

BooleanFormField is for a yes/no answer. The Result member should be set to the user's answer.

type ClientCaps

type ClientCaps struct {
	XMLName xml.Name `xml:"http://jabber.org/protocol/caps c"`
	Ext     string   `xml:"ext,attr"`
	Hash    string   `xml:"hash,attr"`
	Node    string   `xml:"node,attr"`
	Ver     string   `xml:"ver,attr"`
}

ClientCaps contains information about client capabilities

type ClientError

type ClientError struct {
	XMLName xml.Name `xml:"jabber:client error"`
	Code    string   `xml:"code,attr"`
	Type    string   `xml:"type,attr"`
	Any     xml.Name `xml:",any"`
	Text    string   `xml:"text"`
}

ClientError represents a client error

type ClientIQ

type ClientIQ struct {
	XMLName xml.Name    `xml:"jabber:client iq"`
	From    string      `xml:"from,attr"`
	ID      string      `xml:"id,attr"`
	To      string      `xml:"to,attr"`
	Type    string      `xml:"type,attr"` // error, get, result, set
	Error   ClientError `xml:"error"`
	Bind    BindBind    `xml:"bind"`
	Query   []byte      `xml:",innerxml"`
}

ClientIQ contains a specific information query request

type ClientMessage

type ClientMessage struct {
	XMLName xml.Name `xml:"jabber:client message"`
	From    string   `xml:"from,attr"`
	ID      string   `xml:"id,attr"`
	To      string   `xml:"to,attr"`
	Type    string   `xml:"type,attr"` // chat, error, groupchat, headline, or normal

	// These should technically be []clientText,
	// but string is much more convenient.
	Subject string `xml:"subject"`
	Body    string `xml:"body"`
	Thread  string `xml:"thread"`
	Delay   *Delay `xml:"delay,omitempty"`

	Error *StanzaError `xml:"error"`

	Extensions `xml:",any,omitempty"`
}

ClientMessage implements RFC 3921 B.1 jabber:client

type ClientPresence

type ClientPresence struct {
	XMLName xml.Name `xml:"jabber:client presence"`
	From    string   `xml:"from,attr,omitempty"`
	ID      string   `xml:"id,attr,omitempty"`
	To      string   `xml:"to,attr,omitempty"`
	Type    string   `xml:"type,attr,omitempty"` // error, probe, subscribe, subscribed, unavailable, unsubscribe, unsubscribed
	Lang    string   `xml:"lang,attr,omitempty"`

	Show     string       `xml:"show,omitempty"`   // away, chat, dnd, xa
	Status   string       `xml:"status,omitempty"` // sb []clientText
	Priority string       `xml:"priority,omitempty"`
	Caps     *ClientCaps  `xml:"c"`
	Error    *ClientError `xml:"error"`
	Delay    Delay        `xml:"delay"`
}

ClientPresence contains XMPP information about a presence update

type Config

type Config struct {
	// InLog is an optional Writer which receives the raw contents of the
	// XML from the server.
	InLog io.Writer
	// OutLog is an optional Writer which receives the raw XML sent to the
	// server.
	OutLog io.Writer
	// Log is an optional Writer which receives human readable log messages
	// during the connection.
	Log io.Writer
	// CreateCallback, if not nil, causes a new account to be created on
	// the server. The callback is needed in order to be able to handle
	// XMPP forms.
	CreateCallback FormCallback
	// Archive determines whether we disable archiving for messages. If
	// false, XML is sent with each message to disable recording on the
	// server.
	Archive bool
	// SkipTLS, if true, causes the TLS handshake to be skipped.
	// WARNING: this should only be used if Conn is already secure.
	SkipTLS bool
	// TLSConfig contains the configuration to be used by the TLS
	// handshake. If nil, sensible defaults will be used.
	TLSConfig *tls.Config
	// SkipSRVLookup skips SRV lookup during resolution of fully qualified domain
	// names. RFC 6120 section 3.2.3 recomends to skip the SRV lookup when the
	// initiating entity has a hardcoded FQDN associated with the origin domain.
	SkipSRVLookup bool
}

Config contains options for an XMPP connection.

func (*Config) GetLog

func (c *Config) GetLog() io.Writer

GetLog returns the log to use for logging, either a discard or a real log

type Cookie uint64

Cookie is used to give a unique identifier to each request.

type Delay

type Delay struct {
	XMLName xml.Name `xml:"urn:xmpp:delay delay"`
	From    string   `xml:"from,attr,omitempty"`
	Stamp   string   `xml:"stamp,attr"`

	Body string `xml:",chardata"`
}

Delay represents XEP-0203: Delayed Delivery of <message/> and <presence/> stanzas.

type DiscoveryFeature

type DiscoveryFeature struct {
	XMLName xml.Name `xml:"http://jabber.org/protocol/disco#info feature"`
	Var     string   `xml:"var,attr"`
}

DiscoveryFeature contains information about a specific discovery feature

type DiscoveryIdentity

type DiscoveryIdentity struct {
	XMLName  xml.Name `xml:"http://jabber.org/protocol/disco#info identity"`
	Lang     string   `xml:"lang,attr,omitempty"`
	Category string   `xml:"category,attr"`
	Type     string   `xml:"type,attr"`
	Name     string   `xml:"name,attr"`
}

DiscoveryIdentity contains identity information for a specific discovery

type DiscoveryReply

type DiscoveryReply struct {
	XMLName    xml.Name            `xml:"http://jabber.org/protocol/disco#info query"`
	Node       string              `xml:"node"`
	Identities []DiscoveryIdentity `xml:"identity"`
	Features   []DiscoveryFeature  `xml:"feature"`
	Forms      []Form              `xml:"jabber:x:data x"`
}

DiscoveryReply contains the deserialized information about a discovery reply

type EmptyReply

type EmptyReply struct {
}

An EmptyReply results in in no XML.

type ErrorBadRequest

type ErrorBadRequest struct {
	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-stanzas bad-request"`
}

ErrorBadRequest reflects a bad-request stanza. See http://xmpp.org/rfcs/rfc6120.html#stanzas-error-conditions-bad-request

type ErrorReply

type ErrorReply struct {
	XMLName xml.Name    `xml:"error"`
	Type    string      `xml:"type,attr"`
	Error   interface{} `xml:"error"`
}

ErrorReply reflects an XMPP error stanza. See http://xmpp.org/rfcs/rfc6120.html#stanzas-error-syntax

type Extension

type Extension Any

Extension represents any XML node not included in the Stanza definition

type Extensions

type Extensions []*Extension

Extensions implements generic XEPs.

type FailureTLS

type FailureTLS struct {
	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-tls failure"`
}

FailureTLS represents a TLS failure

type FixedFormField

type FixedFormField struct {
	FormField

	Text string
}

FixedFormField is used to indicate a section heading. It's for the form to send data to the user rather than the other way around.

type Form

type Form struct {
	XMLName      xml.Name     `xml:"jabber:x:data x"`
	Type         string       `xml:"type,attr"`
	Title        string       `xml:"title,omitempty"`
	Instructions string       `xml:"instructions,omitempty"`
	Fields       []FormFieldX `xml:"field"`
}

Form contains the definition for a data submission

type FormCallback

type FormCallback func(title, instructions string, fields []interface{}) error

FormCallback is the type of a function called to process a form. The argument is a list of pointers to FormField types. The function should type cast the elements, prompt the user and fill in the result field in each struct.

type FormField

type FormField struct {
	// Label is a human readable label for this field.
	Label string
	// Type is the XMPP-internal type of this field. One should type cast
	// rather than inspect this.
	Type string
	// Name gives the internal name of the field.
	Name     string
	Required bool
	// Media contains one of more items of media associated with this
	// field and, for each item, one or more representations of it.
	Media [][]Media
}

FormField is the type of a generic form field. One should type cast to a specific type of field before processing.

type FormFieldMediaX

type FormFieldMediaX struct {
	XMLName xml.Name    `xml:"urn:xmpp:media-element media"`
	URIs    []MediaURIX `xml:"uri"`
}

FormFieldMediaX contains form field media information

type FormFieldOptionX

type FormFieldOptionX struct {
	Label string `xml:"var,attr,omitempty"`
	Value string `xml:"value"`
}

FormFieldOptionX contains a form field option

type FormFieldRequiredX

type FormFieldRequiredX struct {
	XMLName xml.Name `xml:"required"`
}

FormFieldRequiredX contains information about whether a form field is required

type FormFieldX

type FormFieldX struct {
	XMLName  xml.Name            `xml:"field"`
	Desc     string              `xml:"desc,omitempty"`
	Var      string              `xml:"var,attr"`
	Type     string              `xml:"type,attr,omitempty"`
	Label    string              `xml:"label,attr,omitempty"`
	Required *FormFieldRequiredX `xml:"required"`
	Values   []string            `xml:"value"`
	Options  []FormFieldOptionX  `xml:"option"`
	Media    []FormFieldMediaX   `xml:"media"`
}

FormFieldX contains form field information

type InBandRegistration

type InBandRegistration struct {
	XMLName xml.Name `xml:"http://jabber.org/features/iq-register register,omitempty"`
}

InBandRegistration represents an inband registration

type Media

type Media struct {
	MIMEType string
	// URI contains a URI to the data. It may be empty if Data is not.
	URI string
	// Data contains the raw data itself. It may be empty if URI is not.
	Data []byte
}

Media contains a specific media uri and data

type MediaURIX

type MediaURIX struct {
	XMLName  xml.Name `xml:"urn:xmpp:media-element uri"`
	MIMEType string   `xml:"type,attr,omitempty"`
	URI      string   `xml:",chardata"`
}

MediaURIX contains information about a Media URI

type MultiSelectionFormField

type MultiSelectionFormField struct {
	FormField

	Values  []string
	Ids     []string
	Results []int
}

MultiSelectionFormField asks the user to pick a subset of possible choices. The Result member should be set to a series of indexes of the Results array.

type MultiTextFormField

type MultiTextFormField struct {
	FormField

	Defaults []string
	Results  []string
}

MultiTextFormField is for the entry of a several textual items. The Results member should be set to the data entered.

type PingRequest

type PingRequest struct {
	XMLName xml.Name `xml:"urn:xmpp:ping ping"`
}

PingRequest represents a Ping IQ as defined by XEP-0199

type ProceedTLS

type ProceedTLS struct {
	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-tls proceed"`
}

ProceedTLS represents a TLS proceed

type RegisterQuery

type RegisterQuery struct {
	XMLName  xml.Name  `xml:"jabber:iq:register query"`
	Username *xml.Name `xml:"username"`
	Password *xml.Name `xml:"password"`
	Form     Form      `xml:"x"`
	Datas    []BobData `xml:"data"`
}

RegisterQuery contains register query information for creating a new account

type Roster

type Roster struct {
	XMLName xml.Name      `xml:"jabber:iq:roster query"`
	Item    []RosterEntry `xml:"item"`
}

Roster contains a list of roster entries

type RosterEntry

type RosterEntry struct {
	Jid          string   `xml:"jid,attr"`
	Subscription string   `xml:"subscription,attr"`
	Name         string   `xml:"name,attr"`
	Group        []string `xml:"group"`
	Ask          string   `xml:"ask,attr"`
}

RosterEntry contains one roster entry

func ParseRoster

func ParseRoster(reply Stanza) ([]RosterEntry, error)

ParseRoster extracts roster information from the given Stanza.

type RosterRequest

type RosterRequest struct {
	XMLName xml.Name          `xml:"jabber:iq:roster query"`
	Item    RosterRequestItem `xml:"item"`
}

RosterRequest is used to request that the server update the user's roster. See RFC 6121, section 2.3.

type RosterRequestItem

type RosterRequestItem struct {
	Jid          string   `xml:"jid,attr"`
	Subscription string   `xml:"subscription,attr"`
	Name         string   `xml:"name,attr"`
	Group        []string `xml:"group"`
}

RosterRequestItem contains one specific entry

type SASLErrorCondition

type SASLErrorCondition string

SASLErrorCondition represents a defined SASL-related error conditions as defined in RFC 6120, section 6.5

type SaslAbort

type SaslAbort struct {
	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-sasl abort"`
}

SaslAbort signifies a SASL abort

type SaslFailure

type SaslFailure struct {
	XMLName          xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-sasl failure"`
	Text             string   `xml:"text,omitempty"`
	DefinedCondition Any      `xml:",any"`
}

SaslFailure signifies a SASL Failure

func (SaslFailure) Condition

func (f SaslFailure) Condition() SASLErrorCondition

Condition returns a SASL-related error condition

func (SaslFailure) String

func (f SaslFailure) String() string

type SaslMechanisms

type SaslMechanisms struct {
	XMLName   xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-sasl mechanisms"`
	Mechanism []string `xml:"mechanism"`
}

SaslMechanisms contains information about SASL mechanisms RFC 3920 C.4 SASL name space TODO RFC 6120 obsoletes RFC 3920

type SaslSuccess

type SaslSuccess struct {
	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-sasl success"`
	Content []byte   `xml:",innerxml"`
}

SaslSuccess signifies a SASL Success

type SelectionFormField

type SelectionFormField struct {
	FormField

	Values []string
	Ids    []string
	Result int
}

SelectionFormField asks the user to pick a single element from a set of choices. The Result member should be set to an index of the Values array.

type Stanza

type Stanza struct {
	Name  xml.Name
	Value interface{}
}

Stanza represents a message from the XMPP server.

type StanzaError

type StanzaError struct {
	// cancel -- do not retry (the error is unrecoverable)
	// continue -- proceed (the condition was only a warning)
	// modify -- retry after changing the data sent
	// auth -- retry after providing credentials
	// wait -- retry after waiting (the error is temporary)
	Type string `xml:"type,attr"`

	Condition struct {
		XMLName xml.Name
		Body    string `xml:",innerxml"`
	} `xml:",any"`
}

StanzaError implements RFC 3920, section 9.3. TODO RFC 6120 obsoletes RFC 3920

type StartTLS

type StartTLS struct {
	XMLName  xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-tls starttls"`
	Required xml.Name `xml:"required"`
}

StartTLS represents a TLS start RFC 6120, section 5

type StreamClose

type StreamClose struct{}

StreamClose represents a request to close the stream

type StreamError

type StreamError struct {
	XMLName              xml.Name `xml:"http://etherx.jabber.org/streams error"`
	Text                 string   `xml:"text,omitempty"`
	AppSpecificCondition *Any     `xml:",any,omitempty"`

	DefinedCondition StreamErrorCondition
}

StreamError represents an XMPP Stream Error as defined in RFC 6120, section 4.9

func (*StreamError) String

func (s *StreamError) String() string

type StreamErrorCondition

type StreamErrorCondition string

StreamErrorCondition represents a defined stream error condition as defined in RFC 6120, section 4.9.3

func (StreamErrorCondition) MarshalXML

func (c StreamErrorCondition) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML implements xml.Marshaler interface

type StreamFeatures

type StreamFeatures struct {
	XMLName            xml.Name `xml:"http://etherx.jabber.org/streams features"`
	StartTLS           StartTLS
	Mechanisms         SaslMechanisms
	Bind               BindBind
	InBandRegistration *InBandRegistration

	// This is a hack for now to get around the fact that the new encoding/xml
	// doesn't unmarshal to XMLName elements.
	Session *string `xml:"session"`
	// contains filtered or unexported fields
}

StreamFeatures contain information about the features this stream supports RFC 3920 C.1 Streams name space TODO RFC 6120 obsoletes RFC 3920

type TextFormField

type TextFormField struct {
	FormField

	Default string
	Result  string
	// Private is true if this is a password or other sensitive entry.
	Private bool
}

TextFormField is for the entry of a single textual item. The Result member should be set to the data entered.

type VCard added in v0.3.6

type VCard struct {
	XMLName xml.Name `xml:"vcard-temp vCard"`

	FullName string `xml:"FN"`
	Nickname string `xml:"NICKNAME"`
}

VCard contains vcard

func ParseVCard added in v0.3.6

func ParseVCard(reply Stanza) (VCard, error)

ParseVCard extracts vcard information from the given Stanza.

type VersionQuery

type VersionQuery struct {
	XMLName xml.Name `xml:"jabber:iq:version query"`
}

VersionQuery represents a version query

type VersionReply

type VersionReply struct {
	XMLName xml.Name `xml:"jabber:iq:version query"`
	Name    string   `xml:"name"`
	Version string   `xml:"version"`
	OS      string   `xml:"os"`
}

VersionReply contains a version reply

Jump to

Keyboard shortcuts

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