Only set from if connection is encrypted.

This commit is contained in:
Martin Dosch 2024-04-23 21:24:34 +02:00
parent 321c2b14a5
commit e223dcf94b

View File

@ -1146,6 +1146,7 @@ func (c *Client) startStream(o *Options, domain string) (*streamFeatures, error)
c.stanzaWriter = c.conn c.stanzaWriter = c.conn
} }
if c.IsEncrypted() {
_, err := fmt.Fprintf(c.stanzaWriter, "<?xml version='1.0'?>"+ _, err := fmt.Fprintf(c.stanzaWriter, "<?xml version='1.0'?>"+
"<stream:stream from='%s' to='%s' xmlns='%s'"+ "<stream:stream from='%s' to='%s' xmlns='%s'"+
" xmlns:stream='%s' version='1.0'>\n", " xmlns:stream='%s' version='1.0'>\n",
@ -1153,6 +1154,14 @@ func (c *Client) startStream(o *Options, domain string) (*streamFeatures, error)
if err != nil { if err != nil {
return nil, err return nil, err
} }
} else {
_, err := fmt.Fprintf(c.stanzaWriter, "<?xml version='1.0'?>"+
"<stream:stream to='%s' xmlns='%s' xmlns:stream='%s' version='1.0'>\n",
xmlEscape(domain), nsClient, nsStream)
if err != nil {
return nil, err
}
}
// We expect the server to start a <stream>. // We expect the server to start a <stream>.
se, err := c.nextStart() se, err := c.nextStart()