Reply to XEP-0092 software version requests.

v0.7
Martin Dosch 8 months ago
parent 291e6e3e2e
commit 268953a445

@ -1,6 +1,8 @@
# Changelog
## Unreleased
## Added
- Reply to XEP-0092 software version requests.
## [v0.6.2] 2023-09-29
### Changed

@ -36,6 +36,7 @@ const (
nsOxPubKeys = "urn:xmpp:openpgp:0:public-keys"
nsPubsub = "http://jabber.org/protocol/pubsub"
nsPubsubOwner = "http://jabber.org/protocol/pubsub#owner"
nsVersion = "jabber:iq:version"
nsXMPPStanzas = "urn:ietf:params:xml:ns:xmpp-stanzas"
// strings
oxAltBody = "This message is encrypted (XEP-0373: OpenPGP for XMPP)."

@ -8,6 +8,7 @@ import (
"context"
"fmt"
"log"
"runtime"
"github.com/beevik/etree" // BSD-2-clause
"github.com/mattn/go-xmpp" // BSD-3-Clause
@ -85,6 +86,31 @@ func rcvStanzas(client *xmpp.Client, iqc chan xmpp.IQ, msgc chan xmpp.Chat, ctx
identity.CreateAttr("name", "go-sendxmpp")
feat := replyQuery.CreateElement("feature")
feat.CreateAttr("var", nsDiscoInfo)
feat2 := replyQuery.CreateElement("feature")
feat2.CreateAttr("var", nsVersion)
xmlString, err := root.WriteToString()
if err == nil {
_, err = client.SendOrg(xmlString)
if err != nil {
log.Println(err)
}
}
case nsVersion:
root := etree.NewDocument()
root.WriteSettings.AttrSingleQuote = true
reply := root.CreateElement("iq")
reply.CreateAttr("type", "result")
reply.CreateAttr("from", client.JID())
reply.CreateAttr("to", v.From)
reply.CreateAttr("id", v.ID)
replyQuery := reply.CreateElement("query")
replyQuery.CreateAttr("xmlns", nsVersion)
rqName := replyQuery.CreateElement("name")
rqName.CreateText("go-sendxmpp")
rqVersion := replyQuery.CreateElement("version")
rqVersion.CreateText(version)
rqOS := replyQuery.CreateElement("os")
rqOS.CreateText(runtime.GOOS)
xmlString, err := root.WriteToString()
if err == nil {
_, err = client.SendOrg(xmlString)

Loading…
Cancel
Save