mirror of
https://salsa.debian.org/mdosch/go-sendxmpp
synced 2024-11-17 03:25:33 +00:00
Improve sasl2 user agent id stuff.
This commit is contained in:
parent
c7376832ce
commit
b2d090a623
1
const.go
1
const.go
@ -41,6 +41,7 @@ const (
|
||||
oxAltBody = "This message is encrypted (XEP-0373: OpenPGP for XMPP)."
|
||||
pubsubPubOptions = "http://jabber.org/protocol/pubsub#publish-options"
|
||||
strChat = "chat"
|
||||
strEmpty = ""
|
||||
strError = "error"
|
||||
strGroupchat = "groupchat"
|
||||
strHeadline = "headline"
|
||||
|
@ -63,7 +63,7 @@ func getClientID() (string, error) {
|
||||
clientID = uuid.NewString()
|
||||
file, err := os.Create(clientIDLoc)
|
||||
if err != nil {
|
||||
return strError, fmt.Errorf("getClientID: failed to create clientid file: %w", err)
|
||||
return strEmpty, fmt.Errorf("getClientID: failed to create clientid file: %w", err)
|
||||
}
|
||||
defer file.Close()
|
||||
if runtime.GOOS != "windows" {
|
||||
@ -73,7 +73,7 @@ func getClientID() (string, error) {
|
||||
}
|
||||
_, err = file.Write([]byte(clientID))
|
||||
if err != nil {
|
||||
return strError, fmt.Errorf("getClientID: failed to write client id file: %w", err)
|
||||
return strEmpty, fmt.Errorf("getClientID: failed to write client id file: %w", err)
|
||||
}
|
||||
} else {
|
||||
clientID = buf.String()
|
||||
|
9
vendor/github.com/xmppo/go-xmpp/xmpp.go
generated
vendored
9
vendor/github.com/xmppo/go-xmpp/xmpp.go
generated
vendored
@ -431,7 +431,7 @@ func (c *Client) init(o *Options) error {
|
||||
return err
|
||||
}
|
||||
var mechanism, channelBinding, clientFirstMessage, clientFinalMessageBare, authMessage string
|
||||
var bind2Data, resource, userAgentSW, userAgentDev string
|
||||
var bind2Data, resource, userAgentSW, userAgentDev, userAgentID string
|
||||
var serverSignature, keyingMaterial []byte
|
||||
var scramPlus, ok, tlsConnOK, tls13, serverEndPoint, sasl2, bind2 bool
|
||||
var cbsSlice, mechSlice []string
|
||||
@ -601,9 +601,12 @@ func (c *Client) init(o *Options) error {
|
||||
if o.UserAgentDev != "" {
|
||||
userAgentDev = fmt.Sprintf("<device>%s</device>", o.UserAgentDev)
|
||||
}
|
||||
if o.UserAgentID != "" {
|
||||
userAgentID = fmt.Sprintf(" id='%s'", o.UserAgentID)
|
||||
}
|
||||
fmt.Fprintf(c.stanzaWriter,
|
||||
"<authenticate xmlns='%s' mechanism='%s'><initial-response>%s</initial-response><user-agent id='%s'>%s%s</user-agent>%s</authenticate>\n",
|
||||
nsSASL2, mechanism, base64.StdEncoding.EncodeToString([]byte(clientFirstMessage)), o.UserAgentID, userAgentSW, userAgentDev, bind2Data)
|
||||
"<authenticate xmlns='%s' mechanism='%s'><initial-response>%s</initial-response><user-agent%s>%s%s</user-agent>%s</authenticate>\n",
|
||||
nsSASL2, mechanism, base64.StdEncoding.EncodeToString([]byte(clientFirstMessage)), userAgentID, userAgentSW, userAgentDev, bind2Data)
|
||||
} else {
|
||||
fmt.Fprintf(c.stanzaWriter, "<auth xmlns='%s' mechanism='%s'>%s</auth>\n",
|
||||
nsSASL, mechanism, base64.StdEncoding.EncodeToString([]byte(clientFirstMessage)))
|
||||
|
Loading…
Reference in New Issue
Block a user