diff --git a/go.mod b/go.mod index f26a747..8d0ce78 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/beevik/etree v1.3.0 github.com/gabriel-vasile/mimetype v1.4.3 github.com/pborman/getopt/v2 v2.1.0 - github.com/xmppo/go-xmpp v0.1.5-0.20240404090514-0324b31f56ee + github.com/xmppo/go-xmpp v0.1.5 salsa.debian.org/mdosch/xmppsrv v0.2.6 ) diff --git a/main.go b/main.go index 948e1a7..006897c 100644 --- a/main.go +++ b/main.go @@ -288,7 +288,7 @@ func main() { Host: server, User: user, DialTimeout: timeout, - Resource: "go-sendxmpp", + Resource: "go-sendxmpp" + getShortID(), Password: password, // NoTLS doesn't mean that no TLS is used at all but that instead // of using an encrypted connection to the server (direct TLS) @@ -296,12 +296,12 @@ func main() { // set when NoTLS is set go-sendxmpp won't use unencrypted // client-to-server connections. // See https://pkg.go.dev/github.com/xmppo/go-xmpp#Options - NoTLS: !*flagDirectTLS, - StartTLS: !*flagDirectTLS, - Debug: *flagDebug, - TLSConfig: &tlsConfig, - Mechanism: *flagSCRAMPinning, - SSDP: !*flagSSDPOff, + NoTLS: !*flagDirectTLS, + StartTLS: !*flagDirectTLS, + Debug: *flagDebug, + TLSConfig: &tlsConfig, + Mechanism: *flagSCRAMPinning, + SSDP: !*flagSSDPOff, UserAgentSW: "go-sendxmpp", } diff --git a/vendor/github.com/xmppo/go-xmpp/xmpp.go b/vendor/github.com/xmppo/go-xmpp/xmpp.go index 96beab9..9bfeb1f 100644 --- a/vendor/github.com/xmppo/go-xmpp/xmpp.go +++ b/vendor/github.com/xmppo/go-xmpp/xmpp.go @@ -23,7 +23,6 @@ import ( "crypto/tls" "crypto/x509" "encoding/base64" - "encoding/binary" "encoding/xml" "errors" "fmt" @@ -68,14 +67,6 @@ var DebugWriter io.Writer = os.Stderr // Cookie is a unique XMPP session identifier type Cookie uint64 -func getCookie() Cookie { - var buf [8]byte - if _, err := rand.Reader.Read(buf[:]); err != nil { - panic("Failed to read random bytes: " + err.Error()) - } - return Cookie(binary.LittleEndian.Uint64(buf[:])) -} - // Client holds XMPP connection options type Client struct { conn net.Conn // connection to server @@ -584,7 +575,7 @@ func (c *Client) init(o *Options) error { if o.Resource != "" { resource = o.Resource } else { - resource = fmt.Sprint(getCookie()) + resource = uuid.NewString() } bind2Data = fmt.Sprintf("%s", nsBind2, resource) @@ -885,7 +876,7 @@ func (c *Client) init(o *Options) error { if !bind2 { // Generate a unique cookie - cookie := getCookie() + cookie := uuid.New() // Send IQ message asking to bind to the local user name. if o.Resource == "" { @@ -917,7 +908,7 @@ func (c *Client) init(o *Options) error { } if o.Session { // if server support session, open it - cookie := getCookie() // generate new id value for session + cookie := uuid.New() // generate new id value for session fmt.Fprintf(c.stanzaWriter, "\n", xmlEscape(domain), cookie, nsSession) } diff --git a/vendor/github.com/xmppo/go-xmpp/xmpp_information_query.go b/vendor/github.com/xmppo/go-xmpp/xmpp_information_query.go index 8e30a13..65b9a24 100644 --- a/vendor/github.com/xmppo/go-xmpp/xmpp_information_query.go +++ b/vendor/github.com/xmppo/go-xmpp/xmpp_information_query.go @@ -2,7 +2,8 @@ package xmpp import ( "fmt" - "strconv" + + "github.com/google/uuid" ) const ( @@ -12,8 +13,8 @@ const ( ) func (c *Client) Discovery() (string, error) { - // use getCookie for a pseudo random id. - reqID := strconv.FormatUint(uint64(getCookie()), 10) + // use UUIDv4 for a pseudo random id. + reqID := uuid.NewString() return c.RawInformationQuery(c.jid, c.domain, reqID, IQTypeGet, XMPPNS_DISCO_ITEMS, "") } diff --git a/vendor/modules.txt b/vendor/modules.txt index 082d49e..c5be9a3 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -60,7 +60,7 @@ github.com/pborman/getopt/v2 # github.com/pkg/errors v0.9.1 ## explicit github.com/pkg/errors -# github.com/xmppo/go-xmpp v0.1.5-0.20240404090514-0324b31f56ee => /home/martin/build/go-xmpp +# github.com/xmppo/go-xmpp v0.1.5 => /home/martin/build/go-xmpp ## explicit; go 1.21.5 github.com/xmppo/go-xmpp # golang.org/x/crypto v0.22.0