diff options
author | xengineering <me@xengineering.eu> | 2023-05-19 15:27:31 +0200 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2023-05-19 15:27:31 +0200 |
commit | 3b577ef35fd9c88677fd512e6312d3b431370bce (patch) | |
tree | 0d0bcec56268dea58f8e58a072a5da5d70b4f471 | |
parent | 7fc8ea8ca5efb6adf6fa7c54d1b39f010e17eb7b (diff) | |
download | limox-3b577ef35fd9c88677fd512e6312d3b431370bce.tar limox-3b577ef35fd9c88677fd512e6312d3b431370bce.tar.zst limox-3b577ef35fd9c88677fd512e6312d3b431370bce.zip |
Implement basic stream error detection
With this commit LimoX will cancel the connection to the server if it
receives an encoding/xml.EndElement with .Name.Local attribute set to
"error".
-rw-r--r-- | xmpp/xmpp.go | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/xmpp/xmpp.go b/xmpp/xmpp.go index 773ea44..5c6e3e9 100644 --- a/xmpp/xmpp.go +++ b/xmpp/xmpp.go @@ -45,8 +45,14 @@ func Run(ch chan Event, jid string, pwd string) { default: log.Printf("Unknown Event '%d'!\n", ev) } - case _ = <-decoder.data: - // do something with incoming tokens here + case token := <-decoder.data: + switch element := token.(type) { + case xml.EndElement: + if element.Name.Local == "error" { + log.Println("Received stream error!") + return + } + } } } } |