diff --git a/src/xmpp/client.go b/src/xmpp/client.go index 36ae46b..1d6869e 100644 --- a/src/xmpp/client.go +++ b/src/xmpp/client.go @@ -85,8 +85,8 @@ func startClient(stream *Stream, jid JID) error { start := xml.StartElement{ xml.Name{"stream", "stream"}, []xml.Attr{ - xml.Attr{xml.Name{"", "xmlns"}, "jabber:client"}, - xml.Attr{xml.Name{"xmlns", "stream"}, "http://etherx.jabber.org/streams"}, + xml.Attr{xml.Name{"", "xmlns"}, nsClient}, + xml.Attr{xml.Name{"xmlns", "stream"}, nsStreams}, xml.Attr{xml.Name{"", "from"}, jid.Full()}, xml.Attr{xml.Name{"", "to"}, jid.Domain}, xml.Attr{xml.Name{"", "version"}, "1.0"}, @@ -96,7 +96,7 @@ func startClient(stream *Stream, jid JID) error { if rstart, err := stream.SendStart(&start); err != nil { return err } else { - if rstart.Name != (xml.Name{nsStream, "stream"}) { + if rstart.Name != (xml.Name{nsStreams, "stream"}) { return fmt.Errorf("unexpected start element: %s", rstart.Name) } } diff --git a/src/xmpp/component.go b/src/xmpp/component.go index ed332a9..257b269 100644 --- a/src/xmpp/component.go +++ b/src/xmpp/component.go @@ -27,8 +27,8 @@ func startComponent(stream *Stream, jid JID) (string, error) { start := xml.StartElement{ xml.Name{"stream", "stream"}, []xml.Attr{ - xml.Attr{xml.Name{"", "xmlns"}, "jabber:component:accept"}, - xml.Attr{xml.Name{"xmlns", "stream"}, "http://etherx.jabber.org/streams"}, + xml.Attr{xml.Name{"", "xmlns"}, nsComponentAccept}, + xml.Attr{xml.Name{"xmlns", "stream"}, nsStreams}, xml.Attr{xml.Name{"", "to"}, jid.Full()}, }, } @@ -38,7 +38,7 @@ func startComponent(stream *Stream, jid JID) (string, error) { if rstart, err := stream.SendStart(&start); err != nil { return "", err } else { - if rstart.Name != (xml.Name{nsStream, "stream"}) { + if rstart.Name != (xml.Name{nsStreams, "stream"}) { return "", fmt.Errorf("unexpected start element: %s", rstart.Name) } // Find the stream id. @@ -73,7 +73,7 @@ func handshake(stream *Stream, streamId, secret string) error { if start, err := stream.Next(); err != nil { return err } else { - if start.Name != (xml.Name{"jabber:component:accept", "handshake"}) { + if start.Name != (xml.Name{nsComponentAccept, "handshake"}) { return fmt.Errorf("Expected , for %s", start.Name) } } diff --git a/src/xmpp/ns.go b/src/xmpp/ns.go index 638122e..9e4c185 100644 --- a/src/xmpp/ns.go +++ b/src/xmpp/ns.go @@ -1,6 +1,10 @@ package xmpp const ( - nsErrorStanzas = "urn:ietf:params:xml:ns:xmpp-stanzas" - nsErrorStreams = "urn:ietf:params:xml:ns:xmpp-streams" + nsStreams = "http://etherx.jabber.org/streams" + nsClient = "jabber:client" + nsTLS = "urn:ietf:params:xml:ns:xmpp-tls" + nsComponentAccept = "jabber:component:accept" + nsErrorStanzas = "urn:ietf:params:xml:ns:xmpp-stanzas" + nsErrorStreams = "urn:ietf:params:xml:ns:xmpp-streams" ) diff --git a/src/xmpp/stream.go b/src/xmpp/stream.go index 2c20335..4c3acc1 100644 --- a/src/xmpp/stream.go +++ b/src/xmpp/stream.go @@ -9,11 +9,6 @@ import ( "net" ) -const ( - nsStream = "http://etherx.jabber.org/streams" - nsTLS = "urn:ietf:params:xml:ns:xmpp-tls" -) - // Stream configuration. type StreamConfig struct { // Log all sent and received stanzas.