summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2023-07-05 22:34:13 +0200
committerxengineering <me@xengineering.eu>2023-07-05 22:34:13 +0200
commit4cc9ea5cd439a1f5306f38838774b46d2b145d9a (patch)
treef1baf8010d7be8ee298e605d6308c345d4d17606
parent57845892dbfc6db0648b18e418a6b15218d8526c (diff)
downloadlimox-4cc9ea5cd439a1f5306f38838774b46d2b145d9a.tar
limox-4cc9ea5cd439a1f5306f38838774b46d2b145d9a.tar.zst
limox-4cc9ea5cd439a1f5306f38838774b46d2b145d9a.zip
Migrate bind sending to new generic iq struct
This makes the code way less complex.
-rw-r--r--xmpp/iq.go28
1 files changed, 6 insertions, 22 deletions
diff --git a/xmpp/iq.go b/xmpp/iq.go
index cd96384..2fe7c94 100644
--- a/xmpp/iq.go
+++ b/xmpp/iq.go
@@ -13,35 +13,19 @@ type iq struct {
Id string `xml:"id,attr,omitempty"`
Bind struct{
Jid string `xml:"jid,omitempty"`
+ Resource string `xml:"resource,omitempty"`
} `xml:"urn:ietf:params:xml:ns:xmpp-bind bind,omitempty"`
}
-type bindRequest struct {
- Bind struct {
- Xmlns string `xml:"xmlns,attr"`
- Resource struct {
- Content string `xml:",chardata"`
- } `xml:"resource"`
- } `xml:"bind"`
-}
-
func (s *session) sendBind() {
-
s.resourceReq = fmt.Sprintf("%016x", rand.Uint64())
- start := xml.StartElement{
- xml.Name{"jabber:client", "iq"},
- []xml.Attr{
- xml.Attr{xml.Name{"", "id"}, s.resourceReq},
- xml.Attr{xml.Name{"", "type"}, "set"},
- },
- }
-
- inner := bindRequest{}
- inner.Bind.Xmlns = "urn:ietf:params:xml:ns:xmpp-bind"
- inner.Bind.Resource.Content = "limox-" + fmt.Sprintf("%08x", rand.Uint32())
+ req := iq{}
+ req.Id = s.resourceReq
+ req.Type = "set"
+ req.Bind.Resource = "limox-" + fmt.Sprintf("%08x", rand.Uint32())
- err := s.tx.EncodeElement(inner, start)
+ err := s.tx.Encode(req)
if err != nil {
log.Println("Could not encode ressource binding!")
}