summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2023-05-11 21:20:52 +0200
committerxengineering <me@xengineering.eu>2023-05-11 21:24:14 +0200
commit35540f642a7ba21af0e3b58a36f0aefd353473c4 (patch)
tree01eb648ea3b4b58968940ab4298c3b4682d6b99f
parent5d62378683a516f9e12b0190b46dae475b83e0f5 (diff)
downloadlimox-35540f642a7ba21af0e3b58a36f0aefd353473c4.tar
limox-35540f642a7ba21af0e3b58a36f0aefd353473c4.tar.zst
limox-35540f642a7ba21af0e3b58a36f0aefd353473c4.zip
Add XML log for client to server stream
-rw-r--r--xmpp.go18
1 files changed, 13 insertions, 5 deletions
diff --git a/xmpp.go b/xmpp.go
index 81de122..d588f8d 100644
--- a/xmpp.go
+++ b/xmpp.go
@@ -33,8 +33,8 @@ func xmpp(rxChan chan GuiEvent, txChan chan any, jid string, pwd string) {
enc := xml.NewEncoder(conn)
dbg := xml.NewEncoder(os.Stdout)
- end := sendStreamStart(enc, jid)
- defer sendStreamEnd(enc, end)
+ end := sendStreamStart(enc, dbg, jid)
+ defer sendStreamEnd(enc, dbg, end)
txChan <- XmppConnect
@@ -73,7 +73,7 @@ func rxRoutine(conn *tls.Conn, tokens chan xml.Token, terminator chan bool) {
case <-terminator:
return
default:
- t, _ := dec.Token() // TODO error handling
+ t, _ := dec.Token() // TODO error handling
if t != nil {
tokens <- t
}
@@ -81,7 +81,7 @@ func rxRoutine(conn *tls.Conn, tokens chan xml.Token, terminator chan bool) {
}
}
-func sendStreamStart(enc *xml.Encoder, jid string) xml.EndElement {
+func sendStreamStart(enc *xml.Encoder, dbg *xml.Encoder, jid string) xml.EndElement {
start := xml.StartElement{
xml.Name{"jabber:client", "stream:stream"},
[]xml.Attr{
@@ -103,10 +103,14 @@ func sendStreamStart(enc *xml.Encoder, jid string) xml.EndElement {
log.Fatal("Could not flush XML encoder!")
}
+ dbg.Indent("C: ", " ")
+ dbg.EncodeToken(start)
+ dbg.Flush()
+
return start.End()
}
-func sendStreamEnd(enc *xml.Encoder, end xml.EndElement) {
+func sendStreamEnd(enc *xml.Encoder, dbg *xml.Encoder, end xml.EndElement) {
err := enc.EncodeToken(end)
if err != nil {
log.Fatal("Could not encode stream end!")
@@ -116,6 +120,10 @@ func sendStreamEnd(enc *xml.Encoder, end xml.EndElement) {
if err != nil {
log.Fatal("Could not flush XML encoder!")
}
+
+ dbg.Indent("C: ", " ")
+ dbg.EncodeToken(end)
+ dbg.Flush()
}
// domainpart extracts the domain name from a JID / XMPP address. See