mirror of
https://salsa.debian.org/mdosch/go-sendxmpp
synced 2024-11-17 03:25:33 +00:00
Do not use sasl2 uuid attribute.
This commit is contained in:
parent
986aea7957
commit
557d105238
40
helpers.go
40
helpers.go
@ -14,7 +14,6 @@ import (
|
||||
"net/url"
|
||||
"os"
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/google/uuid" // BSD-3-Clause
|
||||
@ -52,36 +51,6 @@ func readFile(path string) (*bytes.Buffer, error) {
|
||||
return buffer, nil
|
||||
}
|
||||
|
||||
func getClientID(jid string) (string, error) {
|
||||
var clientID string
|
||||
folder := strings.Replace(strings.Replace(jid, "@", "_at_", -1), ".", "_", -1)
|
||||
clientIDLoc, err := getClientIDLoc(folder)
|
||||
if err != nil {
|
||||
return strError, err
|
||||
}
|
||||
buf, err := readFile(clientIDLoc)
|
||||
if err != nil {
|
||||
clientID = uuid.NewString()
|
||||
file, err := os.Create(clientIDLoc)
|
||||
if err != nil {
|
||||
return strEmpty, fmt.Errorf("getClientID: failed to create clientid file: %w", err)
|
||||
}
|
||||
defer file.Close()
|
||||
if runtime.GOOS != "windows" {
|
||||
_ = file.Chmod(os.FileMode(defaultFileRights))
|
||||
} else {
|
||||
_ = file.Chmod(os.FileMode(defaultFileRightsWin))
|
||||
}
|
||||
_, err = file.Write([]byte(clientID))
|
||||
if err != nil {
|
||||
return strEmpty, fmt.Errorf("getClientID: failed to write client id file: %w", err)
|
||||
}
|
||||
} else {
|
||||
clientID = buf.String()
|
||||
}
|
||||
return clientID, nil
|
||||
}
|
||||
|
||||
func getDataPath(folder string) (string, error) {
|
||||
var err error
|
||||
var homeDir, dataDir string
|
||||
@ -117,15 +86,6 @@ func getDataPath(folder string) (string, error) {
|
||||
return dataDir, nil
|
||||
}
|
||||
|
||||
func getClientIDLoc(folder string) (string, error) {
|
||||
dataDir, err := getDataPath(folder)
|
||||
if err != nil {
|
||||
return strError, fmt.Errorf("getClientIDLoc: %w", err)
|
||||
}
|
||||
dataFile := dataDir + "clientid"
|
||||
return dataFile, nil
|
||||
}
|
||||
|
||||
func getRpad(messageLength int) string {
|
||||
rpadRunes := []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
|
||||
length := defaultRpadMultiple - messageLength%defaultRpadMultiple
|
||||
|
6
main.go
6
main.go
@ -263,11 +263,6 @@ func main() {
|
||||
// Timeout
|
||||
timeout := time.Duration(*flagTimeout) * time.Second
|
||||
|
||||
clientID, err := getClientID(user)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
// Use ALPN
|
||||
var tlsConfig tls.Config
|
||||
tlsConfig.ServerName = user[strings.Index(user, "@")+1:]
|
||||
@ -308,7 +303,6 @@ func main() {
|
||||
Mechanism: *flagSCRAMPinning,
|
||||
SSDP: !*flagSSDPOff,
|
||||
UserAgentSW: "go-sendxmpp",
|
||||
UserAgentID: clientID,
|
||||
}
|
||||
|
||||
// Read message from file.
|
||||
|
Loading…
Reference in New Issue
Block a user