Documentation ¶
Overview ¶
Package disco implements service discovery.
Index ¶
- Constants
- Variables
- func Handle() mux.Option
- func HandleCaps(f func(stanza.Presence, Caps)) mux.Option
- func StreamFeature() xmpp.StreamFeature
- func WalkItem(ctx context.Context, item items.Item, s *xmpp.Session, fn WalkItemFunc) error
- type Caps
- type Info
- type InfoQuery
- type ItemIter
- type ItemsQuery
- type WalkItemFunc
Constants ¶
const ( NSInfo = `http://jabber.org/protocol/disco#info` NSItems = `http://jabber.org/protocol/disco#items` NSCaps = `http://jabber.org/protocol/caps` )
Namespaces used by this package.
Variables ¶
var ( // Category: The "account" category is to be used by a server when responding to a disco request sent to the bare JID (user@host addresss) of an account hosted by the server. // Type: The user@host is an administrative account AccountAdmin = info.Identity{Category: "account", Type: "admin"} // Category: The "account" category is to be used by a server when responding to a disco request sent to the bare JID (user@host addresss) of an account hosted by the server. // Type: The user@host is a "guest" account that allows anonymous login by any user AccountAnonymous = info.Identity{Category: "account", Type: "anonymous"} // Category: The "account" category is to be used by a server when responding to a disco request sent to the bare JID (user@host addresss) of an account hosted by the server. // Type: The user@host is a registered or provisioned account associated with a particular non-administrative user AccountRegistered = info.Identity{Category: "account", Type: "registered"} // Category: The "auth" category consists of server components that provide authentication services within a server implementation. // Type: A server component that authenticates based on external certificates AuthCert = info.Identity{Category: "auth", Type: "cert"} // Category: The "auth" category consists of server components that provide authentication services within a server implementation. // Type: A server authentication component other than one of the registered types AuthGeneric = info.Identity{Category: "auth", Type: "generic"} // Category: The "auth" category consists of server components that provide authentication services within a server implementation. // Type: A server component that authenticates against an LDAP database AuthLDAP = info.Identity{Category: "auth", Type: "ldap"} // Category: The "auth" category consists of server components that provide authentication services within a server implementation. // Type: A server component that authenticates against an NT domain AuthNTLM = info.Identity{Category: "auth", Type: "ntlm"} // Category: The "auth" category consists of server components that provide authentication services within a server implementation. // Type: A server component that authenticates against a PAM system AuthPAM = info.Identity{Category: "auth", Type: "pam"} // Category: The "auth" category consists of server components that provide authentication services within a server implementation. // Type: A server component that authenticates against a Radius system AuthRadius = info.Identity{Category: "auth", Type: "radius"} // Category: The "automation" category consists of entities and nodes that provide automated or programmed interaction. // Type: The node for a list of commands; valid only for the node "http://jabber.org/protocol/commands" AutomationCommandList = info.Identity{Category: "automation", Type: "command-list"} // Category: The "automation" category consists of entities and nodes that provide automated or programmed interaction. // Type: A node for a specific command; the "node" attribute uniquely identifies the command AutomationCommandNode = info.Identity{Category: "automation", Type: "command-node"} // Category: The "automation" category consists of entities and nodes that provide automated or programmed interaction. // Type: An entity that supports Jabber-RPC. AutomationRpc = info.Identity{Category: "automation", Type: "rpc"} // Category: The "automation" category consists of entities and nodes that provide automated or programmed interaction. // Type: An entity that supports the SOAP XMPP Binding. AutomationSOAP = info.Identity{Category: "automation", Type: "soap"} // Category: The "automation" category consists of entities and nodes that provide automated or programmed interaction. // Type: An entity that provides automated translation services. AutomationTranslation = info.Identity{Category: "automation", Type: "translation"} // Category: The "client" category consists of different types of clients, mostly for instant messaging. // Type: An automated client that is not controlled by a human user ClientBot = info.Identity{Category: "client", Type: "bot"} // Category: The "client" category consists of different types of clients, mostly for instant messaging. // Type: Minimal non-GUI client used on dumb terminals or text-only screens ClientConsole = info.Identity{Category: "client", Type: "console"} // Category: The "client" category consists of different types of clients, mostly for instant messaging. // Type: A client running on a gaming console ClientGame = info.Identity{Category: "client", Type: "game"} // Category: The "client" category consists of different types of clients, mostly for instant messaging. // Type: A client running on a PDA, RIM device, or other handheld ClientHandheld = info.Identity{Category: "client", Type: "handheld"} // Category: The "client" category consists of different types of clients, mostly for instant messaging. // Type: Standard full-GUI client used on desktops and laptops ClientPC = info.Identity{Category: "client", Type: "pc"} // Category: The "client" category consists of different types of clients, mostly for instant messaging. // Type: A client running on a mobile phone or other telephony device ClientPhone = info.Identity{Category: "client", Type: "phone"} // Category: The "client" category consists of different types of clients, mostly for instant messaging. // Type: A client that is not actually using an instant messaging client; however, messages sent to this contact will be delivered as Short Message Service (SMS) messages ClientSMS = info.Identity{Category: "client", Type: "sms"} // Category: The "client" category consists of different types of clients, mostly for instant messaging. // Type: A client operated from within a web browser ClientWeb = info.Identity{Category: "client", Type: "web"} // Category: The "collaboration" category consists of services that enable multiple individuals to work together in real time. // Type: Multi-user whiteboarding service CollaborationWhiteboard = info.Identity{Category: "collaboration", Type: "whiteboard"} // Category: The "component" category consists of services that are internal to server implementations and not normally exposed outside a server. // Type: A server component that archives traffic ComponentArchive = info.Identity{Category: "component", Type: "archive"} // Category: The "component" category consists of services that are internal to server implementations and not normally exposed outside a server. // Type: A server component that handles client connections ComponentC2S = info.Identity{Category: "component", Type: "c2s"} // Category: The "component" category consists of services that are internal to server implementations and not normally exposed outside a server. // Type: A server component other than one of the registered types ComponentGeneric = info.Identity{Category: "component", Type: "generic"} // Category: The "component" category consists of services that are internal to server implementations and not normally exposed outside a server. // Type: A server component that handles load balancing ComponentLoad = info.Identity{Category: "component", Type: "load"} // Category: The "component" category consists of services that are internal to server implementations and not normally exposed outside a server. // Type: A server component that logs server information ComponentLog = info.Identity{Category: "component", Type: "log"} // Category: The "component" category consists of services that are internal to server implementations and not normally exposed outside a server. // Type: A server component that provides presence information ComponentPresence = info.Identity{Category: "component", Type: "presence"} // Category: The "component" category consists of services that are internal to server implementations and not normally exposed outside a server. // Type: A server component that handles core routing logic ComponentRouter = info.Identity{Category: "component", Type: "router"} // Category: The "component" category consists of services that are internal to server implementations and not normally exposed outside a server. // Type: A server component that handles server connections ComponentS2S = info.Identity{Category: "component", Type: "s2s"} // Category: The "component" category consists of services that are internal to server implementations and not normally exposed outside a server. // Type: A server component that manages user sessions ComponentSM = info.Identity{Category: "component", Type: "sm"} // Category: The "component" category consists of services that are internal to server implementations and not normally exposed outside a server. // Type: A server component that provides server statistics ComponentStats = info.Identity{Category: "component", Type: "stats"} // Category: The "conference" category consists of online conference services such as multi-user chatroom services. // Type: Internet Relay Chat service ConferenceIRC = info.Identity{Category: "conference", Type: "irc"} // Category: The "conference" category consists of online conference services such as multi-user chatroom services. // Type: Text conferencing service ConferenceText = info.Identity{Category: "conference", Type: "text"} // Category: The "directory" category consists of information retrieval services that enable users to search online directories or otherwise be informed about the existence of other XMPP entities. // Type: A directory of chatrooms DirectoryChatroom = info.Identity{Category: "directory", Type: "chatroom"} // Category: The "directory" category consists of information retrieval services that enable users to search online directories or otherwise be informed about the existence of other XMPP entities. // Type: A directory that provides shared roster groups DirectoryGroup = info.Identity{Category: "directory", Type: "group"} // Category: The "directory" category consists of information retrieval services that enable users to search online directories or otherwise be informed about the existence of other XMPP entities. // Type: A directory of end users (e.g., JUD) DirectoryUser = info.Identity{Category: "directory", Type: "user"} // Category: The "directory" category consists of information retrieval services that enable users to search online directories or otherwise be informed about the existence of other XMPP entities. // Type: A directory of waiting list entries DirectoryWaitinglist = info.Identity{Category: "directory", Type: "waitinglist"} // Category: The "gateway" category consists of translators between Jabber/XMPP services and non-XMPP services. // Type: Gateway to AOL Instant Messenger GatewayAIM = info.Identity{Category: "gateway", Type: "aim"} // Category: The "gateway" category consists of translators between Jabber/XMPP services and non-XMPP services. // Type: Gateway to the Facebook IM service GatewayFacebook = info.Identity{Category: "gateway", Type: "facebook"} // Category: The "gateway" category consists of translators between Jabber/XMPP services and non-XMPP services. // Type: Gateway to the Gadu-Gadu IM service GatewayGaduGadu = info.Identity{Category: "gateway", Type: "gadu-gadu"} // Category: The "gateway" category consists of translators between Jabber/XMPP services and non-XMPP services. // Type: Gateway that provides HTTP Web Services access GatewayHTTPWS = info.Identity{Category: "gateway", Type: "http-ws"} // Category: The "gateway" category consists of translators between Jabber/XMPP services and non-XMPP services. // Type: Gateway to ICQ GatewayICQ = info.Identity{Category: "gateway", Type: "icq"} // Category: The "gateway" category consists of translators between Jabber/XMPP services and non-XMPP services. // Type: Gateway to IRC GatewayIRC = info.Identity{Category: "gateway", Type: "irc"} // Category: The "gateway" category consists of translators between Jabber/XMPP services and non-XMPP services. // Type: Gateway to Microsoft Live Communications Server GatewayLCS = info.Identity{Category: "gateway", Type: "lcs"} // Category: The "gateway" category consists of translators between Jabber/XMPP services and non-XMPP services. // Type: Gateway to the mail.ru IM service GatewayMRIM = info.Identity{Category: "gateway", Type: "mrim"} // Category: The "gateway" category consists of translators between Jabber/XMPP services and non-XMPP services. // Type: Gateway to MSN Messenger GatewayMSN = info.Identity{Category: "gateway", Type: "msn"} // Category: The "gateway" category consists of translators between Jabber/XMPP services and non-XMPP services. // Type: Gateway to the MySpace IM service GatewayMyspaceim = info.Identity{Category: "gateway", Type: "myspaceim"} // Category: The "gateway" category consists of translators between Jabber/XMPP services and non-XMPP services. // Type: Gateway to Microsoft Office Communications Server GatewayOCS = info.Identity{Category: "gateway", Type: "ocs"} // Category: The "gateway" category consists of translators between Jabber/XMPP services and non-XMPP services. // Type: Gateway to the QQ IM service GatewayQQ = info.Identity{Category: "gateway", Type: "qq"} // Category: The "gateway" category consists of translators between Jabber/XMPP services and non-XMPP services. // Type: Gateway to IBM Lotus Sametime GatewaySametime = info.Identity{Category: "gateway", Type: "sametime"} // Category: The "gateway" category consists of translators between Jabber/XMPP services and non-XMPP services. // Type: Gateway to SIP for Instant Messaging and Presence Leveraging Extensions (SIMPLE) GatewaySimple = info.Identity{Category: "gateway", Type: "simple"} // Category: The "gateway" category consists of translators between Jabber/XMPP services and non-XMPP services. // Type: Gateway to the Skype service GatewaySkype = info.Identity{Category: "gateway", Type: "skype"} // Category: The "gateway" category consists of translators between Jabber/XMPP services and non-XMPP services. // Type: Gateway to Short Message Service GatewaySMS = info.Identity{Category: "gateway", Type: "sms"} // Category: The "gateway" category consists of translators between Jabber/XMPP services and non-XMPP services. // Type: Gateway to the SMTP (email) network GatewaySMTP = info.Identity{Category: "gateway", Type: "smtp"} // Category: The "gateway" category consists of translators between Jabber/XMPP services and non-XMPP services. // Type: Gateway to the Tlen IM service GatewayTlen = info.Identity{Category: "gateway", Type: "tlen"} // Category: The "gateway" category consists of translators between Jabber/XMPP services and non-XMPP services. // Type: Gateway to the Xfire gaming and IM service GatewayXfire = info.Identity{Category: "gateway", Type: "xfire"} // Category: The "gateway" category consists of translators between Jabber/XMPP services and non-XMPP services. // Type: Gateway to another XMPP service (NOT via native server-to-server communication) GatewayXMPP = info.Identity{Category: "gateway", Type: "xmpp"} // Category: The "gateway" category consists of translators between Jabber/XMPP services and non-XMPP services. // Type: Gateway to Yahoo! Instant Messenger GatewayYahoo = info.Identity{Category: "gateway", Type: "yahoo"} // Category: The "headline" category consists of services that provide real-time news or information (often but not necessarily in a message of type "headline"). // Type: Service that notifies a user of new email messages. HeadlineNewmail = info.Identity{Category: "headline", Type: "newmail"} // Category: The "headline" category consists of services that provide real-time news or information (often but not necessarily in a message of type "headline"). // Type: RSS notification service. HeadlineRSS = info.Identity{Category: "headline", Type: "rss"} // Category: The "headline" category consists of services that provide real-time news or information (often but not necessarily in a message of type "headline"). // Type: Service that provides weather alerts. HeadlineWeather = info.Identity{Category: "headline", Type: "weather"} // Category: The "hierarchy" category is used to describe nodes within a hierarchy of nodes; the "branch" and "leaf" types are exhaustive. // Type: A service discovery node that contains further nodes in the hierarchy. HierarchyBranch = info.Identity{Category: "hierarchy", Type: "branch"} // Category: The "hierarchy" category is used to describe nodes within a hierarchy of nodes; the "branch" and "leaf" types are exhaustive. // Type: A service discovery node that does not contain further nodes in the hierarchy. HierarchyLeaf = info.Identity{Category: "hierarchy", Type: "leaf"} // Category: The "proxy" category consists of servers or services that act as special-purpose proxies or intermediaries between two or more XMPP endpoints. // Type: SOCKS5 bytestreams proxy service ProxyBytestreams = info.Identity{Category: "proxy", Type: "bytestreams"} // Category: Services and nodes that adhere to XEP-0060. // Type: A pubsub node of the "collection" type. PubsubCollection = info.Identity{Category: "pubsub", Type: "collection"} // Category: Services and nodes that adhere to XEP-0060. // Type: A pubsub node of the "leaf" type. PubsubLeaf = info.Identity{Category: "pubsub", Type: "leaf"} // Category: Services and nodes that adhere to XEP-0060. // Type: A personal eventing service that supports the publish-subscribe subset defined in XEP-0163. PubsubPEP = info.Identity{Category: "pubsub", Type: "pep"} // Category: Services and nodes that adhere to XEP-0060. // Type: A pubsub service that supports the functionality defined in XEP-0060. PubsubService = info.Identity{Category: "pubsub", Type: "service"} // Category: The "server" category consists of any Jabber/XMPP server. // Type: Standard Jabber/XMPP server used for instant messaging and presence ServerIM = info.Identity{Category: "server", Type: "im"} // Category: The "store" category consists of internal server components that provide data storage and retrieval services. // Type: A server component that stores data in a Berkeley database StoreBerkeley = info.Identity{Category: "store", Type: "berkeley"} // Category: The "store" category consists of internal server components that provide data storage and retrieval services. // Type: A server component that stores data on the file system StoreFile = info.Identity{Category: "store", Type: "file"} // Category: The "store" category consists of internal server components that provide data storage and retrieval services. // Type: A server data storage component other than one of the registered types StoreGeneric = info.Identity{Category: "store", Type: "generic"} // Category: The "store" category consists of internal server components that provide data storage and retrieval services. // Type: A server component that stores data in an LDAP database StoreLDAP = info.Identity{Category: "store", Type: "ldap"} // Category: The "store" category consists of internal server components that provide data storage and retrieval services. // Type: A server component that stores data in a MySQL database StoreMysql = info.Identity{Category: "store", Type: "mysql"} // Category: The "store" category consists of internal server components that provide data storage and retrieval services. // Type: A server component that stores data in an Oracle database StoreOracle = info.Identity{Category: "store", Type: "oracle"} // Category: The "store" category consists of internal server components that provide data storage and retrieval services. // Type: A server component that stores data in a PostgreSQL database StorePostgres = info.Identity{Category: "store", Type: "postgres"} )
Predefined identities generated from the Service Discovery Identities Registry as registered with the XMPP Registrar.
var ErrSkipItem = errors.New("skip this item")
ErrSkipItem is used as a return value from WalkItemFuncs to indicate that the node named in the call is to be skipped. It is not returned as an error by any function.
var (
Feature = info.Feature{Var: NSInfo}
)
A list of service discovery features that are supported by this package.
Functions ¶
func Handle ¶ added in v0.20.0
Handle returns an option that configures a multiplexer to handle service discovery requests by iterating over its own handlers and checking if they implement info.FeatureIter, info.IdentityIter, form.Iter, or items.Iter.
func HandleCaps ¶ added in v0.21.2
HandleCaps calls f for each incoming presence containing entity capabilities information.
func StreamFeature ¶ added in v0.21.2
func StreamFeature() xmpp.StreamFeature
StreamFeature is an informational stream feature that saves any entity caps information that was published by the server during session negotiation. StreamFeature should not be used on the server side.
func WalkItem ¶
WalkItem walks the tree rooted at the JID, calling fn for each item in the tree, including root. To query the root, leave item.Node empty. The Name attribute of the query item is ignored.
All errors that arise visiting items are filtered by fn: see the WalkItemFunc documentation for details.
The items are walked in wire order which may make the output non-deterministic.
Types ¶
type Caps ¶ added in v0.21.2
type Caps struct { XMLName xml.Name `xml:"http://jabber.org/protocol/caps c"` Hash crypto.Hash `xml:"hash,attr"` Node string `xml:"node,attr"` Ver string `xml:"ver,attr"` }
Caps can be included in a presence stanza or in stream features to advertise entity capabilities. Node is a string that uniquely identifies your client (eg. https://example.com/myclient) and ver is the hash of an Info value.
func ServerCaps ¶ added in v0.21.2
ServerCaps returns any entity caps information advertised by the server when we first connected. If the ServerCaps feature was not used during session negotiation or no entity caps was advertised when connecting, ok will be false.
func (Caps) MarshalXML ¶ added in v0.21.2
MarshalXML implements xml.Marshaler.
func (Caps) TokenReader ¶ added in v0.21.2
func (c Caps) TokenReader() xml.TokenReader
TokenReader implements xmlstream.Marshaler.
func (*Caps) UnmarshalXML ¶ added in v0.21.2
UnmarshalXML implements xml.Unmarshaler
type Info ¶
type Info struct { InfoQuery Identity []info.Identity `xml:"identity"` Features []info.Feature `xml:"feature"` Form []form.Data `xml:"jabber:x:data x,omitempty"` }
Info is a response to a disco info query.
func GetInfo ¶
GetInfo discovers a set of features and identities associated with a JID and optional node. An empty Node means to query the root items for the JID. It blocks until a response is received.
func GetInfoIQ ¶
GetInfoIQ is like GetInfo but it allows you to customize the IQ. Changing the type of the provided IQ has no effect.
func (Info) AppendHash ¶ added in v0.21.2
AppendHash is like Hash except that it appends the output string to the provided byte slice.
func (Info) Hash ¶ added in v0.21.2
Hash generates the entity capabilities verification string. Its output is suitable for use as a cache key.
func (Info) MarshalXML ¶ added in v0.21.2
MarshalXML implements xml.Marshaler.
func (Info) TokenReader ¶
func (i Info) TokenReader() xml.TokenReader
TokenReader implements xmlstream.Marshaler.
type InfoQuery ¶
type InfoQuery struct { XMLName xml.Name `xml:"http://jabber.org/protocol/disco#info query"` Node string `xml:"node,attr,omitempty"` }
InfoQuery is the payload of a query for a node's identities and features.
func (InfoQuery) MarshalXML ¶ added in v0.21.2
MarshalXML implements xml.Marshaler.
func (InfoQuery) TokenReader ¶
func (q InfoQuery) TokenReader() xml.TokenReader
TokenReader implements xmlstream.Marshaler.
type ItemIter ¶
type ItemIter struct {
// contains filtered or unexported fields
}
ItemIter is an iterator over discovered items. It supports paging
func FetchItems ¶
FetchItems discovers a set of items associated with a JID and optional node of the provided item. The Name attribute of the query item is ignored. An empty Node means to query the root items for the JID. It blocks until a response is received.
The iterator must be closed before anything else is done on the session. Any errors encountered while creating the iter are deferred until the iter is used.
func FetchItemsIQ ¶
FetchItemsIQ is like FetchItems but it allows you to customize the IQ. Changing the type of the provided IQ has no effect.
func (*ItemIter) Close ¶
Close indicates that we are finished with the given iterator and processing the stream may continue. Calling it multiple times has no effect.
type ItemsQuery ¶
type ItemsQuery struct { XMLName xml.Name `xml:"http://jabber.org/protocol/disco#items query"` Node string `xml:"node,attr,omitempty"` }
ItemsQuery is the payload of a query for a node's items.
func (ItemsQuery) TokenReader ¶
func (q ItemsQuery) TokenReader() xml.TokenReader
TokenReader implements xmlstream.Marshaler.
func (ItemsQuery) WriteXML ¶
func (q ItemsQuery) WriteXML(w xmlstream.TokenWriter) (int, error)
WriteXML implements xmlstream.WriterTo.
type WalkItemFunc ¶
WalkItemFunc is the type of function called by WalkItem to visit each item in an item hierarchy. Item nodes are unique and absolute (in particular they should not be treated like paths, even if a particular implementation uses paths for node names).
The error result returned by the function controls how WalkItem continues. If the function returns the special value ErrSkipItem, WalkItem skips the current item. Otherwise, if the function returns a non-nil error, WalkItem stops entirely and returns that error.
The error reports an error related to the item, signaling that WalkItem will not walk into that item. The function may decide how to handle that error, including returning it to stop walking the entire tree.
The function is called before querying for an item to allow SkipItem to bypass the query entirely. If an error occurs while making the query, the function will be called again with the same item to report the error.