From 4d4a201b1a88cac4f29801083fd10225e578f67a Mon Sep 17 00:00:00 2001 From: Martin/Geno Date: Mon, 12 Feb 2018 07:05:39 +0100 Subject: [PATCH] some bug fixes --- daemon/tester/bot.go | 2 +- daemon/tester/status.go | 1 + messages/error.go | 36 ++++++++++++++++++++++++++++++++---- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/daemon/tester/bot.go b/daemon/tester/bot.go index 2307c02..198d970 100644 --- a/daemon/tester/bot.go +++ b/daemon/tester/bot.go @@ -28,7 +28,7 @@ func (t *Tester) StartBot(status *Status) { errMSG := &messages.StreamError{} err = status.client.Decode(errMSG, element) if err == nil { - status.Disconnect(fmt.Sprintf("recv stream error: %s: %s", errMSG.Text, messages.XMLChildrenString(errMSG.Any))) + status.Disconnect(fmt.Sprintf("recv stream error: %s: %s -> %s", errMSG.Text, messages.XMLChildrenString(errMSG.StreamErrorGroup), messages.XMLChildrenString(errMSG.Other))) return } diff --git a/daemon/tester/status.go b/daemon/tester/status.go index afdb313..2524e29 100644 --- a/daemon/tester/status.go +++ b/daemon/tester/status.go @@ -37,6 +37,7 @@ func NewStatus(backupClient *client.Client, acc *Account) *Status { func (s *Status) Disconnect(reason string) { if s.Login { msg := &messages.MessageClient{ + Type: messages.MessageTypeChat, Body: fmt.Sprintf("you recieve a notify that '%s' disconnect: %s", s.JID.Full(), reason), } for jid, _ := range s.account.Admins { diff --git a/messages/error.go b/messages/error.go index 3fb73a5..9414be6 100644 --- a/messages/error.go +++ b/messages/error.go @@ -2,11 +2,39 @@ package messages import "encoding/xml" -type StreamError struct { - XMLName xml.Name `xml:"http://etherx.jabber.org/streams error"` - Text string `xml:"urn:ietf:params:xml:ns:xmpp-streams text"` +type StreamErrorGroup struct { + BadFormat *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams bad-format"` + BadNamespacePrefix *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams bad-namespace-prefix"` + Conflict *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams conflict"` + ConnectionTimeout *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams connection-timeout"` + HostGone *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams host-gone"` + HostUnknown *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams host-unknown"` + ImproperAddressing *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams improper-addressing"` + InternalServerError *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams internal-server-error"` + InvalidFrom *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams invalid-from"` + InvalidID *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams invalid-id"` + InvalidNamespace *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams invalid-namespace"` + InvalidXML *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams invalid-xml"` + NotAuthorized *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams not-authorized"` + NotWellFormed *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams not-well-formed"` + PolicyViolation *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams policy-violation"` + RemoteConnectionFailed *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams remote-connection-failed"` + Reset *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams reset"` + ResourceConstraint *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams resource-constraint"` + RestrictedXML *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams restricted-xml"` + SeeOtherHost string `xml:"urn:ietf:params:xml:ns:xmpp-streams see-other-host"` + SystemShutdown *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams system-shutdown"` + UndefinedCondition *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams undefined-condition"` + UnsupportedEncoding *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams unsupported-encoding"` + UnsupportedStanzaType *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams unsupported-stanza-type"` + UnsupportedVersion *xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-streams unsupported-version"` +} - Any xml.Name `xml:",any"` +type StreamError struct { + XMLName xml.Name `xml:"http://etherx.jabber.org/streams error"` + Text string `xml:"urn:ietf:params:xml:ns:xmpp-streams text"` + Other []XMLElement `xml:",any"` + StreamErrorGroup } type ErrorClientType string