forked from chteufleur/go-xmpp
Collect and consolidate namespaces.
This commit is contained in:
parent
f9302660b0
commit
82015bcab4
|
|
@ -85,8 +85,8 @@ func startClient(stream *Stream, jid JID) error {
|
||||||
start := xml.StartElement{
|
start := xml.StartElement{
|
||||||
xml.Name{"stream", "stream"},
|
xml.Name{"stream", "stream"},
|
||||||
[]xml.Attr{
|
[]xml.Attr{
|
||||||
xml.Attr{xml.Name{"", "xmlns"}, "jabber:client"},
|
xml.Attr{xml.Name{"", "xmlns"}, nsClient},
|
||||||
xml.Attr{xml.Name{"xmlns", "stream"}, "http://etherx.jabber.org/streams"},
|
xml.Attr{xml.Name{"xmlns", "stream"}, nsStreams},
|
||||||
xml.Attr{xml.Name{"", "from"}, jid.Full()},
|
xml.Attr{xml.Name{"", "from"}, jid.Full()},
|
||||||
xml.Attr{xml.Name{"", "to"}, jid.Domain},
|
xml.Attr{xml.Name{"", "to"}, jid.Domain},
|
||||||
xml.Attr{xml.Name{"", "version"}, "1.0"},
|
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 {
|
if rstart, err := stream.SendStart(&start); err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
if rstart.Name != (xml.Name{nsStream, "stream"}) {
|
if rstart.Name != (xml.Name{nsStreams, "stream"}) {
|
||||||
return fmt.Errorf("unexpected start element: %s", rstart.Name)
|
return fmt.Errorf("unexpected start element: %s", rstart.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,8 @@ func startComponent(stream *Stream, jid JID) (string, error) {
|
||||||
start := xml.StartElement{
|
start := xml.StartElement{
|
||||||
xml.Name{"stream", "stream"},
|
xml.Name{"stream", "stream"},
|
||||||
[]xml.Attr{
|
[]xml.Attr{
|
||||||
xml.Attr{xml.Name{"", "xmlns"}, "jabber:component:accept"},
|
xml.Attr{xml.Name{"", "xmlns"}, nsComponentAccept},
|
||||||
xml.Attr{xml.Name{"xmlns", "stream"}, "http://etherx.jabber.org/streams"},
|
xml.Attr{xml.Name{"xmlns", "stream"}, nsStreams},
|
||||||
xml.Attr{xml.Name{"", "to"}, jid.Full()},
|
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 {
|
if rstart, err := stream.SendStart(&start); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
} else {
|
} else {
|
||||||
if rstart.Name != (xml.Name{nsStream, "stream"}) {
|
if rstart.Name != (xml.Name{nsStreams, "stream"}) {
|
||||||
return "", fmt.Errorf("unexpected start element: %s", rstart.Name)
|
return "", fmt.Errorf("unexpected start element: %s", rstart.Name)
|
||||||
}
|
}
|
||||||
// Find the stream id.
|
// Find the stream id.
|
||||||
|
|
@ -73,7 +73,7 @@ func handshake(stream *Stream, streamId, secret string) error {
|
||||||
if start, err := stream.Next(); err != nil {
|
if start, err := stream.Next(); err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
if start.Name != (xml.Name{"jabber:component:accept", "handshake"}) {
|
if start.Name != (xml.Name{nsComponentAccept, "handshake"}) {
|
||||||
return fmt.Errorf("Expected <handshake/>, for %s", start.Name)
|
return fmt.Errorf("Expected <handshake/>, for %s", start.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
package xmpp
|
package xmpp
|
||||||
|
|
||||||
const (
|
const (
|
||||||
nsErrorStanzas = "urn:ietf:params:xml:ns:xmpp-stanzas"
|
nsStreams = "http://etherx.jabber.org/streams"
|
||||||
nsErrorStreams = "urn:ietf:params:xml:ns:xmpp-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"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,6 @@ import (
|
||||||
"net"
|
"net"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
nsStream = "http://etherx.jabber.org/streams"
|
|
||||||
nsTLS = "urn:ietf:params:xml:ns:xmpp-tls"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Stream configuration.
|
// Stream configuration.
|
||||||
type StreamConfig struct {
|
type StreamConfig struct {
|
||||||
// Log all sent and received stanzas.
|
// Log all sent and received stanzas.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue