Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package go-sendxmpp for openSUSE:Factory checked in at 2024-03-10 20:25:39 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/go-sendxmpp (Old) and /work/SRC/openSUSE:Factory/.go-sendxmpp.new.1770 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "go-sendxmpp" Sun Mar 10 20:25:39 2024 rev:13 rq:1156683 version:0.8.4 Changes: -------- --- /work/SRC/openSUSE:Factory/go-sendxmpp/go-sendxmpp.changes 2024-02-20 21:13:06.475135997 +0100 +++ /work/SRC/openSUSE:Factory/.go-sendxmpp.new.1770/go-sendxmpp.changes 2024-03-10 20:26:15.213600167 +0100 @@ -1,0 +2,15 @@ +Sun Mar 10 07:17:16 UTC 2024 - Michael Vetter <[email protected]> + +- Update to 0.8.4: + * Properly handle lost connection. + * Better compatibility with perl sendxmpp config files. + * Improve file name for private Ox keys. + * Improve fallback behavior if no SRV records are provided. + * Remove 100ms sleep before closing the connection. This should + be no more needed since go-xmpp commit + 9684a8ff690f0d75e284f8845696c5057926d276. + * Return an error if there is no answer to an IQ within 60s. + * Check for errors after sending the auth message during + SCRAM authentication (via go-xmpp v0.1.2). + +------------------------------------------------------------------- Old: ---- go-sendxmpp-0.8.3.tar.gz New: ---- go-sendxmpp-0.8.4.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ go-sendxmpp.spec ++++++ --- /var/tmp/diff_new_pack.KZBts3/_old 2024-03-10 20:26:15.897625270 +0100 +++ /var/tmp/diff_new_pack.KZBts3/_new 2024-03-10 20:26:15.897625270 +0100 @@ -17,7 +17,7 @@ Name: go-sendxmpp -Version: 0.8.3 +Version: 0.8.4 Release: 0 Summary: A little tool to send messages to an XMPP contact or MUC License: BSD-2-Clause ++++++ _service ++++++ --- /var/tmp/diff_new_pack.KZBts3/_old 2024-03-10 20:26:15.929626444 +0100 +++ /var/tmp/diff_new_pack.KZBts3/_new 2024-03-10 20:26:15.929626444 +0100 @@ -3,7 +3,7 @@ <param name="url">https://salsa.debian.org/mdosch/go-sendxmpp.git</param> <param name="scm">git</param> <param name="exclude">.git</param> - <param name="revision">v0.8.3</param> + <param name="revision">v0.8.4</param> <param name="versionformat">@PARENT_TAG@</param> <param name="changesgenerate">disable</param> <param name="versionrewrite-pattern">v(.*)</param> ++++++ go-sendxmpp-0.8.3.tar.gz -> go-sendxmpp-0.8.4.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/go-sendxmpp-0.8.3/.gitlab-ci.yml new/go-sendxmpp-0.8.4/.gitlab-ci.yml --- old/go-sendxmpp-0.8.3/.gitlab-ci.yml 2024-02-17 17:06:30.000000000 +0100 +++ new/go-sendxmpp-0.8.4/.gitlab-ci.yml 2024-03-09 21:13:48.000000000 +0100 @@ -38,6 +38,8 @@ #- '[ -e .golangci.yml ] || cp /golangci/.golangci.yml .' #- golangci-lint run #allow_failure: true + artifacts: + expire_in: 1 year compile: stage: build @@ -47,19 +49,14 @@ - echo "${CI_JOB_ID}" > CI_JOB_ID.txt - env GOOS=linux GOARCH=amd64 go build -buildmode=pie -ldflags "-s -w -extldflags '-static'" -o $CI_PROJECT_DIR/linux-amd64/go-sendxmpp - env GOOS=linux GOARCH=arm64 go build -buildmode=pie -ldflags "-s -w -extldflags '-static'" -o $CI_PROJECT_DIR/linux-arm64/go-sendxmpp - - env GOOS=linux GOARCH=386 go build -ldflags "-s -w -extldflags '-static'" -o $CI_PROJECT_DIR/linux-386/go-sendxmpp - - env GOOS=linux GOARCH=arm go build -ldflags "-s -w -extldflags '-static'" -o $CI_PROJECT_DIR/linux-arm/go-sendxmpp - - env GOOS=windows GOARCH=386 go build -buildmode=pie -ldflags "-s -w -extldflags '-static'" -o $CI_PROJECT_DIR/win386/go-sendxmpp.exe - env GOOS=windows GOARCH=amd64 go build -buildmode=pie -ldflags "-s -w -extldflags '-static'" -o $CI_PROJECT_DIR/win64/go-sendxmpp.exe artifacts: paths: - linux-amd64/go-sendxmpp - linux-arm64/go-sendxmpp - - linux-386/go-sendxmpp - - linux-arm/go-sendxmpp - - win386/go-sendxmpp.exe - win64/go-sendxmpp.exe - CI_JOB_ID.txt + expire_in: 2 years release: stage: release @@ -71,7 +68,6 @@ release-cli create --name "Release $CI_COMMIT_TAG" --tag-name $CI_COMMIT_TAG --description="`head -n $(expr "$(grep -nm2 "^## " CHANGELOG.md|awk '(NR>1) {print $1}'|cut -f1 -d:) - 2"|bc) CHANGELOG.md`" \ --assets-link "{\"name\":\"Linux amd64\",\"url\":\"https://salsa.debian.org/mdosch/go-sendxmpp/-/jobs/`cat CI_JOB_ID.txt`/artifacts/file/linux-amd64/go-sendxmpp\"}" \ --assets-link "{\"name\":\"Linux arm64\",\"url\":\"https://salsa.debian.org/mdosch/go-sendxmpp/-/jobs/`cat CI_JOB_ID.txt`/artifacts/file/linux-arm64/go-sendxmpp\"}" \ - --assets-link "{\"name\":\"Linux 386\",\"url\":\"https://salsa.debian.org/mdosch/go-sendxmpp/-/jobs/`cat CI_JOB_ID.txt`/artifacts/file/linux-386/go-sendxmpp\"}" \ - --assets-link "{\"name\":\"Linux arm\",\"url\":\"https://salsa.debian.org/mdosch/go-sendxmpp/-/jobs/`cat CI_JOB_ID.txt`/artifacts/file/linux-arm/go-sendxmpp\"}" \ - --assets-link "{\"name\":\"Windows 386\",\"url\":\"https://salsa.debian.org/mdosch/go-sendxmpp/-/jobs/`cat CI_JOB_ID.txt`/artifacts/file/win386/go-sendxmpp.exe\"}" \ --assets-link "{\"name\":\"Windows amd64\",\"url\":\"https://salsa.debian.org/mdosch/go-sendxmpp/-/jobs/`cat CI_JOB_ID.txt`/artifacts/file/win64/go-sendxmpp.exe\"}" + artifacts: + expire_in: 2 years diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/go-sendxmpp-0.8.3/CHANGELOG.md new/go-sendxmpp-0.8.4/CHANGELOG.md --- old/go-sendxmpp-0.8.3/CHANGELOG.md 2024-02-17 17:06:30.000000000 +0100 +++ new/go-sendxmpp-0.8.4/CHANGELOG.md 2024-03-09 21:13:48.000000000 +0100 @@ -1,5 +1,15 @@ # Changelog +## [v0.8.4] 2024-03-09 +### Changed +- Properly handle lost connection. +- Better compatibility with perl sendxmpp config files. +- Improve file name for private Ox keys. +- Improve fallback behavior if no SRV records are provided. +- Remove 100ms sleep before closing the connection. This should be no more needed since go-xmpp commit 9684a8ff690f0d75e284f8845696c5057926d276. +- Return an error if there is no answer to an IQ within 60s. +- Check for errors after sending the auth message during SCRAM authentication (via go-xmpp v0.1.2). + ## [v0.8.3] 2024-02-17 ### Changed - Use a human readable file name for private Ox keys. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/go-sendxmpp-0.8.3/connect.go new/go-sendxmpp-0.8.4/connect.go --- old/go-sendxmpp-0.8.3/connect.go 2024-02-17 17:06:30.000000000 +0100 +++ new/go-sendxmpp-0.8.4/connect.go 2024-03-09 21:13:48.000000000 +0100 @@ -16,9 +16,9 @@ func connect(options xmpp.Options, directTLS bool) (*xmpp.Client, error) { proxy := os.Getenv("HTTP_PROXY") + server := options.User[strings.Index(options.User, "@")+1:] // Look up SRV records if server is not specified manually. if options.Host == "" { - server := options.User[strings.Index(options.User, "@")+1:] // Don't do SRV look ups if proxy is set. if proxy == "" { // Look up xmpp-client SRV records. @@ -43,16 +43,22 @@ } } } - // Try port 5223 if directTLS is set and no xmpp-client SRV records are provided. + } + _, port, _ := net.SplitHostPort(options.Host) + if port == "" { + if options.Host == "" { + options.Host = server + } + // Try port 5223 if directTLS is set and no port is provided. if directTLS { options.NoTLS = false options.StartTLS = false - options.Host = net.JoinHostPort(server, "5223") + options.Host = net.JoinHostPort(options.Host, "5223") } else { - // Try port 5222 if no xmpp-client SRV records are provided and directTLS is not set. + // Try port 5222 if no port is provided and directTLS is not set. options.NoTLS = true options.StartTLS = true - options.Host = net.JoinHostPort(server, "5222") + options.Host = net.JoinHostPort(options.Host, "5222") } } // Connect to server diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/go-sendxmpp-0.8.3/const.go new/go-sendxmpp-0.8.4/const.go --- old/go-sendxmpp-0.8.3/const.go 2024-02-17 17:06:30.000000000 +0100 +++ new/go-sendxmpp-0.8.4/const.go 2024-03-09 21:13:48.000000000 +0100 @@ -5,7 +5,7 @@ package main const ( - version = "0.8.3" + version = "0.8.4" // defaults defaultBufferSize = 100 defaultConfigRowSep = 2 @@ -17,7 +17,6 @@ defaultRpadMultiple = 100 defaultRSABits = 4096 defaultShortIDBytes = 4 - defaultSleepTime = 100 defaultTimeout = 10 defaultTLSMinVersion = 12 defaultTLS10 = 10 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/go-sendxmpp-0.8.3/go.mod new/go-sendxmpp-0.8.4/go.mod --- old/go-sendxmpp-0.8.3/go.mod 2024-02-17 17:06:30.000000000 +0100 +++ new/go-sendxmpp-0.8.4/go.mod 2024-03-09 21:13:48.000000000 +0100 @@ -7,7 +7,7 @@ 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.0.2-0.20240201055852-b369b7df1031 + github.com/xmppo/go-xmpp v0.1.2 salsa.debian.org/mdosch/xmppsrv v0.2.6 ) @@ -16,8 +16,8 @@ github.com/ProtonMail/go-mime v0.0.0-20230322103455-7d82a3887f2f // indirect github.com/cloudflare/circl v1.3.7 // indirect github.com/pkg/errors v0.9.1 // indirect - golang.org/x/crypto v0.19.0 // indirect - golang.org/x/net v0.21.0 // indirect - golang.org/x/sys v0.17.0 // indirect + golang.org/x/crypto v0.21.0 // indirect + golang.org/x/net v0.22.0 // indirect + golang.org/x/sys v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/go-sendxmpp-0.8.3/go.sum new/go-sendxmpp-0.8.4/go.sum --- old/go-sendxmpp-0.8.3/go.sum 2024-02-17 17:06:30.000000000 +0100 +++ new/go-sendxmpp-0.8.4/go.sum 2024-03-09 21:13:48.000000000 +0100 @@ -25,15 +25,15 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/xmppo/go-xmpp v0.0.2-0.20240201055852-b369b7df1031 h1:FOObNOvf3Tc3pKHGHp6LZRVBT7tv1KeqFSvOswLTi8E= -github.com/xmppo/go-xmpp v0.0.2-0.20240201055852-b369b7df1031/go.mod h1:goIl07FSeu+OGrFpTC8fMUTG4Dc7B6LnOZ+qxe0WVi8= +github.com/xmppo/go-xmpp v0.1.2 h1:oQPd/wVUBb53AdbpsuIYwFPtBQC3gYaHaWbaLDev+oA= +github.com/xmppo/go-xmpp v0.1.2/go.mod h1:yyTnJMs6I6KUKv3BjXc4i3NU/iWBxY3yBGiUvUcW0Qg= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo= -golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -42,8 +42,8 @@ golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= -golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= +golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= +golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -56,8 +56,8 @@ golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/go-sendxmpp-0.8.3/httpupload.go new/go-sendxmpp-0.8.4/httpupload.go --- old/go-sendxmpp-0.8.3/httpupload.go 2024-02-17 17:06:30.000000000 +0100 +++ new/go-sendxmpp-0.8.4/httpupload.go 2024-03-09 21:13:48.000000000 +0100 @@ -155,8 +155,8 @@ if maxFileSize != 0 { if fileSize > maxFileSize { return "", errors.New("http-upload: file size " + strconv.FormatInt(fileSize/1024/1024, 10) + - " MB is larger than the maximum file size allowed (" + - strconv.FormatInt(maxFileSize/1024/1024, 10) + " MB).") + " MiB is larger than the maximum file size allowed (" + + strconv.FormatInt(maxFileSize/1024/1024, 10) + " MiB).") } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/go-sendxmpp-0.8.3/main.go new/go-sendxmpp-0.8.4/main.go --- old/go-sendxmpp-0.8.3/main.go 2024-02-17 17:06:30.000000000 +0100 +++ new/go-sendxmpp-0.8.4/main.go 2024-03-09 21:13:48.000000000 +0100 @@ -32,9 +32,6 @@ } func closeAndExit(client *xmpp.Client, cancel context.CancelFunc, err error) { - // Wait for a short time as some messages are not delivered by the server - // if the connection is closed immediately after sending a message. - time.Sleep(defaultSleepTime * time.Millisecond) cancel() client.Close() if err != nil { @@ -217,6 +214,22 @@ if *flagPassword != "" { password = *flagPassword } + // If no server part is specified in the username but a server is specified + // just assume the server is identical to the server part and hope for the + // best. This is for compatibility with the old perl sendxmpp config files. + var serverpart string + if !strings.Contains(user, "@") && server != "" { + // Remove port if server contains it. + if strings.Contains(server, ":") { + serverpart, _, err = net.SplitHostPort(server) + if err != nil { + log.Fatal(err) + } + } else { + serverpart = server + } + user = user + "@" + serverpart + } switch { // Use "go-sendxmpp" if no nick is specified via config or command line flag. @@ -318,7 +331,7 @@ iqc := make(chan xmpp.IQ, defaultBufferSize) msgc := make(chan xmpp.Chat, defaultBufferSize) ctx, cancel := context.WithCancel(context.Background()) - go rcvStanzas(client, iqc, msgc, ctx) + go rcvStanzas(client, iqc, msgc, ctx, cancel) for _, r := range getopt.Args() { var re recipientsType re.Jid = r diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/go-sendxmpp-0.8.3/ox.go new/go-sendxmpp-0.8.4/ox.go --- old/go-sendxmpp-0.8.3/ox.go 2024-02-17 17:06:30.000000000 +0100 +++ new/go-sendxmpp-0.8.4/ox.go 2024-03-09 21:13:48.000000000 +0100 @@ -347,12 +347,19 @@ // TODO: Remove handling of oldDataFile in a later version when it's very likely that there are no // more versions in use using the oldDataFile (<0.8.3). oldDataFile := dataDir + base64.StdEncoding.EncodeToString([]byte(jid)) - dataFile := dataDir + strings.Replace(jid, "@", "_at_", -1) + oldDataFile2 := dataDir + strings.Replace(jid, "@", "_at_", -1) + dataFile := dataDir + strings.Replace(strings.Replace(jid, "@", "_at_", -1), ".", "_", -1) if _, err := os.Stat(oldDataFile); err == nil { err := os.Rename(oldDataFile, dataFile) if err != nil { return dataFile, err } + } + if _, err := os.Stat(oldDataFile2); err == nil { + err := os.Rename(oldDataFile2, dataFile) + if err != nil { + return dataFile, err + } } return dataFile, nil } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/go-sendxmpp-0.8.3/stanzahandling.go new/go-sendxmpp-0.8.4/stanzahandling.go --- old/go-sendxmpp-0.8.3/stanzahandling.go 2024-02-17 17:06:30.000000000 +0100 +++ new/go-sendxmpp-0.8.4/stanzahandling.go 2024-03-09 21:13:48.000000000 +0100 @@ -6,9 +6,11 @@ import ( "context" + "errors" "fmt" "log" "runtime" + "time" "github.com/beevik/etree" // BSD-2-clause "github.com/xmppo/go-xmpp" // BSD-3-Clause @@ -24,7 +26,11 @@ if err != nil { return iq, fmt.Errorf("sendIQ: failed to send iq: %w", err) } - iq = <-c + select { + case iq = <-c: + case <-time.After(60 * time.Second): + return iq, errors.New("sendIQ: server didn't reply to IQ: " + content) + } return iq, nil } @@ -38,7 +44,7 @@ } } -func rcvStanzas(client *xmpp.Client, iqc chan xmpp.IQ, msgc chan xmpp.Chat, ctx context.Context) { +func rcvStanzas(client *xmpp.Client, iqc chan xmpp.IQ, msgc chan xmpp.Chat, ctx context.Context, cancel context.CancelFunc) { for { received, err := client.Recv() // Don't print errors if the program is getting shut down, @@ -49,7 +55,7 @@ return default: if err != nil { - log.Println(err) + closeAndExit(client, cancel, err) } } switch v := received.(type) { @@ -69,6 +75,9 @@ if query != nil { xmlns = query.SelectAttr("xmlns") } + if xmlns == nil { + break + } switch xmlns.Value { case nsDiscoInfo: root := etree.NewDocument() ++++++ vendor.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/github.com/xmppo/go-xmpp/xmpp.go new/vendor/github.com/xmppo/go-xmpp/xmpp.go --- old/vendor/github.com/xmppo/go-xmpp/xmpp.go 2024-02-19 08:38:20.000000000 +0100 +++ new/vendor/github.com/xmppo/go-xmpp/xmpp.go 2024-03-10 08:18:29.000000000 +0100 @@ -16,7 +16,6 @@ "bufio" "bytes" "crypto/hmac" - "crypto/md5" "crypto/rand" "crypto/sha1" "crypto/sha256" @@ -331,30 +330,30 @@ // Close closes the XMPP connection func (c *Client) Close() error { if c.conn != (*tls.Conn)(nil) { - return c.conn.Close() + fmt.Fprintf(c.stanzaWriter, "</stream:stream>\n") + // Wait for the server also closing the stream. + for { + select { + case <-time.After(10 * time.Second): + break + default: + ee, err := nextEnd(c.p) + // If the server already closed the stream it is + // likely to receive an error when trying to parse + // the stream. Therefore the connection is also closed + // if an error is received. + if err != nil { + return c.conn.Close() + } + if ee.Name.Local == "stream" { + return c.conn.Close() + } + } + } } return nil } -func saslDigestResponse(username, realm, passwd, nonce, cnonceStr, authenticate, digestURI, nonceCountStr string) string { - h := func(text string) []byte { - h := md5.New() - h.Write([]byte(text)) - return h.Sum(nil) - } - hex := func(bytes []byte) string { - return fmt.Sprintf("%x", bytes) - } - kd := func(secret, data string) []byte { - return h(secret + ":" + data) - } - - a1 := string(h(username+":"+realm+":"+passwd)) + ":" + nonce + ":" + cnonceStr - a2 := authenticate + ":" + digestURI - response := hex(kd(hex(h(a1)), nonce+":"+nonceCountStr+":"+cnonceStr+":auth:"+hex(h(a2)))) - return response -} - func cnonce() string { randSize := big.NewInt(0) randSize.Lsh(big.NewInt(1), 64) @@ -537,10 +536,23 @@ fmt.Fprintf(c.stanzaWriter, "<auth xmlns='%s' mechanism='%s'>%s</auth>\n", nsSASL, mechanism, base64.StdEncoding.EncodeToString([]byte(clientFirstMessage))) var sfm string - if err = c.p.DecodeElement(&sfm, nil); err != nil { - return errors.New("unmarshal <challenge>: " + err.Error()) + _, val, err := next(c.p) + if err != nil { + return err + } + switch v := val.(type) { + case *saslFailure: + errorMessage := v.Text + if errorMessage == "" { + // v.Any is type of sub-element in failure, + // which gives a description of what failed if there was no text element + errorMessage = v.Any.Local + } + return errors.New("auth failure: " + errorMessage) + case *saslChallenge: + sfm = v.Text } - b, err := base64.StdEncoding.DecodeString(string(sfm)) + b, err := base64.StdEncoding.DecodeString(sfm) if err != nil { return err } @@ -1282,11 +1294,6 @@ Mechanism []string `xml:"mechanism"` } -type saslAuth struct { - XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-sasl auth"` - Mechanism string `xml:",attr"` -} - type saslChannelBindings struct { XMLName xml.Name `xml:"sasl-channel-binding"` Text string `xml:",chardata"` @@ -1297,12 +1304,6 @@ } `xml:"channel-binding"` } -type saslChallenge string - -type saslRspAuth string - -type saslResponse string - type saslAbort struct { XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-sasl abort"` } @@ -1318,6 +1319,11 @@ Text string `xml:"text"` } +type saslChallenge struct { + XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-sasl challenge"` + Text string `xml:",chardata"` +} + // RFC 3920 C.5 Resource binding name space type bindBind struct { XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-bind bind"` @@ -1388,11 +1394,6 @@ Stamp string `xml:"stamp,attr"` } -type clientText struct { - Lang string `xml:",attr"` - Body string `xml:"chardata"` -} - type clientPresence struct { XMLName xml.Name `xml:"jabber:client presence"` From string `xml:"from,attr"` @@ -1456,6 +1457,21 @@ } } +// Scan XML token stream to find next EndElement +func nextEnd(p *xml.Decoder) (xml.EndElement, error) { + p.Strict = false + for { + t, err := p.Token() + if err != nil || t == nil { + return xml.EndElement{}, err + } + switch t := t.(type) { + case xml.EndElement: + return t, nil + } + } +} + // Scan XML token stream for next element and save into val. // If val == nil, allocate new element based on proto map. // Either way, return val. @@ -1482,7 +1498,7 @@ case nsSASL + " mechanisms": nv = &saslMechanisms{} case nsSASL + " challenge": - nv = "" + nv = &saslChallenge{} case nsSASL + " response": nv = "" case nsSASL + " abort": diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/github.com/xmppo/go-xmpp/xmpp_pubsub.go new/vendor/github.com/xmppo/go-xmpp/xmpp_pubsub.go --- old/vendor/github.com/xmppo/go-xmpp/xmpp_pubsub.go 2024-02-19 08:38:20.000000000 +0100 +++ new/vendor/github.com/xmppo/go-xmpp/xmpp_pubsub.go 2024-03-10 08:18:29.000000000 +0100 @@ -22,11 +22,6 @@ Items []clientPubsubItem `xml:"item"` } -type clientPubsub struct { - XMLName xml.Name `xml:"pubsub"` - Items clientPubsubItems `xml:"items"` -} - type clientPubsubEvent struct { XMLName xml.Name `xml:"event"` XMLNS string `xml:"xmlns,attr"` diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vendor/modules.txt new/vendor/modules.txt --- old/vendor/modules.txt 2024-02-19 08:38:20.000000000 +0100 +++ new/vendor/modules.txt 2024-03-10 08:18:29.000000000 +0100 @@ -57,10 +57,10 @@ # github.com/pkg/errors v0.9.1 ## explicit github.com/pkg/errors -# github.com/xmppo/go-xmpp v0.0.2-0.20240201055852-b369b7df1031 +# github.com/xmppo/go-xmpp v0.1.2 ## explicit; go 1.21.5 github.com/xmppo/go-xmpp -# golang.org/x/crypto v0.19.0 +# golang.org/x/crypto v0.21.0 ## explicit; go 1.18 golang.org/x/crypto/argon2 golang.org/x/crypto/blake2b @@ -68,13 +68,13 @@ golang.org/x/crypto/hkdf golang.org/x/crypto/pbkdf2 golang.org/x/crypto/sha3 -# golang.org/x/net v0.21.0 +# golang.org/x/net v0.22.0 ## explicit; go 1.18 golang.org/x/net/html golang.org/x/net/html/atom golang.org/x/net/internal/socks golang.org/x/net/proxy -# golang.org/x/sys v0.17.0 +# golang.org/x/sys v0.18.0 ## explicit; go 1.18 golang.org/x/sys/cpu # golang.org/x/text v0.14.0
