pax_global_header00006660000000000000000000000064142017151000014501gustar00rootroot0000000000000052 comment=679cbbda031613db5fb7eaa5d9ee275cc3ff9f7e go-sendxmpp-v0.2.0/000077500000000000000000000000001420171510000141275ustar00rootroot00000000000000go-sendxmpp-v0.2.0/.gitignore000066400000000000000000000004501420171510000161160ustar00rootroot00000000000000config.json .vscode # Binaries for programs and plugins *.exe *.dll *.so *.dylib # Test binary, build with `go test -c` *.test # Output of the go coverage tool, specifically when used with LiteIDE *.out # Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736 .glide/ go-sendxmpp-v0.2.0/.gitlab-ci.yml000066400000000000000000000066051420171510000165720ustar00rootroot00000000000000# To contribute improvements to CI/CD templates, please follow the Development guide at: # https://docs.gitlab.com/ee/development/cicd/templates.html # This specific template is located at: # https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Go.gitlab-ci.yml image: golang:latest variables: # Please edit to your GitLab project REPO_NAME: salsa.debian.org/mdosch/go-sendxmpp # The problem is that to be able to use go get, one needs to put # the repository in the $GOPATH. So for example if your gitlab domain # is gitlab.com, and that your repository is namespace/project, and # the default GOPATH being /go, then you'd need to have your # repository in /go/src/gitlab.com/namespace/project # Thus, making a symbolic link corrects this. before_script: - mkdir -p $GOPATH/src/$(dirname $REPO_NAME) - ln -svf $CI_PROJECT_DIR $GOPATH/src/$REPO_NAME - cd $GOPATH/src/$REPO_NAME stages: - test - build - release format: stage: test script: - go fmt $(go list ./... | grep -v /vendor/) - go vet $(go list ./... | grep -v /vendor/) - go test -race $(go list ./... | grep -v /vendor/) compile: stage: build only: - tags script: - echo "${CI_JOB_ID}" > CI_JOB_ID.txt - env GOOS=linux GOARCH=amd64 go build -race -ldflags "-extldflags '-static'" -o $CI_PROJECT_DIR/linux-amd64/go-sendxmpp - env GOOS=linux GOARCH=arm64 go build -ldflags "-extldflags '-static'" -o $CI_PROJECT_DIR/linux-arm64/go-sendxmpp - env GOOS=linux GOARCH=386 go build -ldflags "-extldflags '-static'" -o $CI_PROJECT_DIR/linux-386/go-sendxmpp - env GOOS=linux GOARCH=arm go build -ldflags "-extldflags '-static'" -o $CI_PROJECT_DIR/linux-arm/go-sendxmpp - env GOOS=windows GOARCH=386 go build -ldflags "-extldflags '-static'" -o $CI_PROJECT_DIR/win386/go-sendxmpp.exe - env GOOS=windows GOARCH=amd64 go build -ldflags "-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 release: stage: release image: registry.gitlab.com/gitlab-org/release-cli:latest only: - tags script: - | release-cli create --name "Release $CI_COMMIT_TAG" --tag-name $CI_COMMIT_TAG --description="`cat 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\"}" go-sendxmpp-v0.2.0/CHANGELOG.md000066400000000000000000000013101420171510000157330ustar00rootroot00000000000000# Changelog ##[v0.2.0] ### Added - Added listening function. - Added flag to configure connection timeout. - Added flag to configure minimum TLS version. - Added flag to show version. ### Removed - Removed deprecated option `-x`. ## [v0.1.3] ### Changed - Rename files to use a limited character set (alpha numerical and some extra characters) file name before uploading. Workaround for https://github.com/mattn/go-xmpp/issues/132 ## [v0.1.2] ### Changed - Use xml.Marshal to safely build HTTP Upload request. - Use salsa.debian.org/mdosch/xmppsrv for SRV lookups. ## [v0.1.1] ### Changed - Xml-escape file name in http-upload. - Xml-escape mimetype in http-upload. ## [v0.1.0] ### Added - Initial release go-sendxmpp-v0.2.0/LICENSE000066400000000000000000000024511420171510000151360ustar00rootroot00000000000000BSD 2-Clause License Copyright (c) 2020 - 2021, Martin Dosch All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. go-sendxmpp-v0.2.0/LICENSE-mellium000066400000000000000000000024271420171510000166030ustar00rootroot00000000000000Copyright © 2014 The Mellium Contributors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. go-sendxmpp-v0.2.0/README.md000066400000000000000000000107551420171510000154160ustar00rootroot00000000000000# go-sendxmpp ## about A little tool to send messages to an XMPP contact or MUC inspired by [sendxmpp](https://sendxmpp.hostname.sk/). You can find other sendxmpp alternatives in the [XSF wiki](https://wiki.xmpp.org/web/User:MDosch/Sendxmpp_incarnations). ## support You might join the [chat](https://join.jabber.network/#go-sendxmpp@chat.mdosch.de?join) if you have problems, want to contribute or just want to talk about the project. You might also talk about any of the other sendxmpp incarnations. :) [![Go-sendxmpp MUC badge](https://chat.mdosch.de:5281/muc_badge/go-sendxmpp@chat.mdosch.de)](https://join.jabber.network/#go-sendxmpp@chat.mdosch.de?join) ## requirements * [go](https://golang.org/) ## installation ### repositories including go-sendxmpp [![Packaging status](https://repology.org/badge/vertical-allrepos/go:sendxmpp.svg)](https://repology.org/project/go:sendxmpp/versions) ### manual installation #### Go < 1.16 ```plain $ go get -u salsa.debian.org/mdosch/go-sendxmpp ``` #### Go >= 1.16 ```plain $ go install salsa.debian.org/mdosch/go-sendxmpp@latest ``` You will find the binary in `$GOPATH/bin` or, if set, `$GOBIN`. ### binaries There are some (automatically built and untested) binaries linked to the [release](https://salsa.debian.org/mdosch/go-sendxmpp/-/releases). ## usage You can either pipe a programs output to `go-sendxmpp`, write in your terminal (put \^D in a new line to finish) or send the input from a file (`-m` or `--message`). The account data is expected at `~/.config/go-sendxmpp/sendxmpprc` if no other configuration file location is specified with `-f` or `--file`. The configuration file is expected to be in the following format: ```plain username: password: ``` If this is not sufficient to connect you might also specify `jserver` and `port`. It is also possible to use a password manager. In this case the `password` setting should be replaced by the `eval_password` setting: ``` eval_password: ``` You can also configure the resource (and nickname for MUCs) via the `resource` setting: ``` resource: ``` If no configuration file is present or if the values should be overridden it is possible to define the account details via command line options: ```plain Usage: go-sendxmpp [-cdilnt] [-f value] [--help] [--http-upload value] [-j value] [-m value] [-p value] [--raw] [-r value] [--timeout value] [--tls-version value] [-u value] [--version] [parameters ...] -c, --chatroom Send message to a chatroom. -d, --debug Show debugging info. -f, --file=value Set configuration file. (Default: ~/.config/go-sendxmpp/sendxmpprc) --help Show help. --http-upload=value Send a file via http-upload. -i, --interactive Interactive mode (for use with e.g. 'tail -f'). -j, --jserver=value XMPP server address. -l, --listen Listen for messages and print them to stdout. -m, --message=value Set file including the message. -n, --no-tls-verify Skip verification of TLS certificates (not recommended). -p, --password=value Password for XMPP account. --raw Send raw XML. -r, --resource=value Set resource. When sending to a chatroom this is used as 'alias'. --timeout=value Connection timeout in seconds. [10] -t, --tls Use direct TLS. --tls-version=value Minimal TLS version. 10 (TSLv1.0), 11 (TLSv1.1), 12 (TLSv1.2) or 13 (TLSv1.3). [12] -u, --username=value Username for XMPP account. --version Show version information. ``` ### examples Send a message to two recipients using a configuration file. ```bash cat message.txt | ./go-sendxmpp -f ./sendxmpp recipient1@example.com recipient2@example.com ``` Send a message to two recipients directly defining account credentials. ```bash cat message.txt | ./go-sendxmpp -u bob@example.com -j example.com -p swordfish recipient1@example.com recipient2@example.com ``` Send a message to two groupchats (`-c`) using a configuration file. ```bash cat message.txt | ./go-sendxmpp -cf ./sendxmpp chat1@conference.example.com chat2@conference.example.com ``` Send file changes to two groupchats (`-c`) using a configuration file. ```bash tail -f example.log | ./go-sendxmpp -cif ./sendxmpp chat1@conference.example.com chat2@conference.example.com ``` go-sendxmpp-v0.2.0/connect.go000066400000000000000000000031761420171510000161160ustar00rootroot00000000000000// Copyright 2021 Martin Dosch. // Use of this source code is governed by the BSD-2-clause // license that can be found in the LICENSE file.package main package main import ( "fmt" "net" "strings" "github.com/mattn/go-xmpp" // BSD-3-Clause "salsa.debian.org/mdosch/xmppsrv" // BSD-2-Clause ) func connect(options xmpp.Options, directTLS bool) (*xmpp.Client, error) { // Look up SRV records if server is not specified manually. if options.Host == "" { server := options.User[strings.Index(options.User, "@")+1:] // Look up xmpp-client SRV records. srvMixed, err := xmppsrv.LookupClient(server) if len(srvMixed) > 0 && err == nil { for _, adr := range srvMixed { if !directTLS && adr.Type != "xmpps-client" { // Use StartTLS options.NoTLS = true options.StartTLS = true options.Host = net.JoinHostPort(adr.Target, fmt.Sprint(adr.Port)) // Connect to server client, err := options.NewClient() if err == nil { return client, err } } else if adr.Type == "xmpps-client" { // Use direct TLS options.NoTLS = false options.StartTLS = false options.Host = net.JoinHostPort(adr.Target, fmt.Sprint(adr.Port)) // Connect to server client, err := options.NewClient() if err == nil { return client, err } } } } // Try port 5222 if no xmpp-client SRV records are provided. options.NoTLS = true options.StartTLS = true options.Host = net.JoinHostPort(server, "5222") // Connect to server client, err := options.NewClient() return client, err } // Connect to server client, err := options.NewClient() return client, err } go-sendxmpp-v0.2.0/go-sendxmpp.go000066400000000000000000000373241420171510000167300ustar00rootroot00000000000000// Copyright 2018 - 2021 Martin Dosch. // Use of this source code is governed by the BSD-2-clause // license that can be found in the LICENSE file. package main import ( "bufio" "crypto/tls" "errors" "fmt" "io" "log" "net" "os" "os/exec" "os/user" "runtime" "strconv" "strings" "time" "github.com/mattn/go-xmpp" // BSD-3-Clause "github.com/pborman/getopt/v2" // BSD-3-Clause ) type configuration struct { username string jserver string port string password string resource string } // Opens the config file and returns the specified values // for username, server and port. func parseConfig(configPath string) (configuration, error) { var ( output configuration err error ) // Use $XDG_CONFIG_HOME/.config/go-sendxmpp/sendxmpprc or // ~/.sendxmpprc if no config path is specified. if configPath == "" { // Get systems user config path. osConfigDir := os.Getenv("$XDG_CONFIG_HOME") if osConfigDir != "" { configPath = osConfigDir + "/go-sendxmpp/sendxmpprc" // Check that the config file is existing. _, err := os.Stat(configPath) if os.IsNotExist(err) { // If the file is not existing at ~/.config/go-sendxmpp/sendxmpprc // check at the perl sendxmpp legacy destination. configPath = osConfigDir + "/.sendxmpprc" _, err = os.Stat(configPath) if os.IsNotExist(err) { return output, errors.New("no configuration file found") } } } else { // Get the current user. curUser, err := user.Current() if err != nil { return output, err } // Get home directory. home := curUser.HomeDir if home == "" { return output, errors.New("no home directory found") } configPath = home + "/.config/go-sendxmpp/sendxmpprc" // Check that config file is existing. _, err = os.Stat(configPath) if os.IsNotExist(err) { // If the file is not existing at ~/.config/go-sendxmpp/sendxmpprc // check at the perl sendxmpp legacy destination. configPath = home + "/.sendxmpprc" _, err = os.Stat(configPath) if os.IsNotExist(err) { return output, errors.New("no configuration file found") } } } } // Only check file permissions if we are not running on windows. if runtime.GOOS != "windows" { info, _ := os.Stat(configPath) // Check for file permissions. Must be 600, 640, 440 or 400. perm := info.Mode().Perm() permissions := strconv.FormatInt(int64(perm), 8) if permissions != "600" && permissions != "640" && permissions != "440" && permissions != "400" { return output, errors.New("Wrong permissions for " + configPath + ": " + permissions + " instead of 400, 440, 600 or 640.") } } // Open config file. file, err := os.Open(configPath) if err != nil { return output, err } scanner := bufio.NewScanner(file) scanner.Split(bufio.ScanLines) // Read config file per line. for scanner.Scan() { if strings.HasPrefix(scanner.Text(), "#") { continue } row := strings.SplitN(scanner.Text(), " ", 2) switch row[0] { case "username:": output.username = row[1] case "jserver:": output.jserver = row[1] case "password:": output.password = row[1] case "eval_password:": shell := os.Getenv("SHELL") if shell == "" { shell = "/bin/sh" } out, err := exec.Command(shell, "-c", row[1]).Output() if err != nil { log.Fatal(err) } output.password = string(out) if output.password[len(output.password)-1] == '\n' { output.password = output.password[:len(output.password)-1] } case "port:": output.port = row[1] case "resource:": output.resource = row[1] default: if len(row) >= 2 { if strings.Contains(scanner.Text(), ";") { output.username = strings.Split(row[0], ";")[0] output.jserver = strings.Split(row[0], ";")[1] output.password = row[1] } else { output.username = strings.Split(row[0], ":")[0] output.jserver = strings.Split(row[0], "@")[1] output.password = row[1] } } } } file.Close() // Check if the username is a valid JID output.username, err = MarshalJID(output.username) if err != nil { // Check whether only the local part was used by appending an @ and the // server part. output.username = output.username + "@" + output.jserver // Check if the username is a valid JID now output.username, err = MarshalJID(output.username) if err != nil { return output, errors.New("invalid username/JID: " + output.username) } } return output, err } func readMessage(messageFilePath string) (string, error) { var ( output string err error ) // Check that message file is existing. _, err = os.Stat(messageFilePath) if os.IsNotExist(err) { return output, err } // Open message file. file, err := os.Open(messageFilePath) if err != nil { return output, err } scanner := bufio.NewScanner(file) scanner.Split(bufio.ScanLines) for scanner.Scan() { if output == "" { output = scanner.Text() } else { output = output + "\n" + scanner.Text() } } if err := scanner.Err(); err != nil { if err != io.EOF { return "", err } } file.Close() return output, err } func main() { var ( err error message, user, server, password, resource string ) // Define command line flags. flagHelp := getopt.BoolLong("help", 0, "Show help.") flagHttpUpload := getopt.StringLong("http-upload", 0, "", "Send a file via http-upload.") flagDebug := getopt.BoolLong("debug", 'd', "Show debugging info.") flagServer := getopt.StringLong("jserver", 'j', "", "XMPP server address.") flagUser := getopt.StringLong("username", 'u', "", "Username for XMPP account.") flagPassword := getopt.StringLong("password", 'p', "", "Password for XMPP account.") flagChatroom := getopt.BoolLong("chatroom", 'c', "Send message to a chatroom.") flagDirectTLS := getopt.BoolLong("tls", 't', "Use direct TLS.") flagResource := getopt.StringLong("resource", 'r', "", "Set resource. "+ "When sending to a chatroom this is used as 'alias'.") flagFile := getopt.StringLong("file", 'f', "", "Set configuration file. (Default: "+ "~/.config/go-sendxmpp/sendxmpprc)") flagMessageFile := getopt.StringLong("message", 'm', "", "Set file including the message.") flagInteractive := getopt.BoolLong("interactive", 'i', "Interactive mode (for use with e.g. 'tail -f').") flagSkipVerify := getopt.BoolLong("no-tls-verify", 'n', "Skip verification of TLS certificates (not recommended).") flagRaw := getopt.BoolLong("raw", 0, "Send raw XML.") flagListen := getopt.BoolLong("listen", 'l', "Listen for messages and print them to stdout.") flagTimeout := getopt.IntLong("timeout", 0, 10, "Connection timeout in seconds.") flagTLSMinVersion := getopt.IntLong("tls-version", 0, 12, "Minimal TLS version. 10 (TSLv1.0), 11 (TLSv1.1), 12 (TLSv1.2) or 13 (TLSv1.3).") flagVersion := getopt.BoolLong("version", 0, "Show version information.") // Parse command line flags. getopt.Parse() // If requested, show help and quit. if *flagHelp { getopt.Usage() os.Exit(0) } // If requested, show version and quit. if *flagVersion { fmt.Println("go-sendxmpp", "0.2.0") fmt.Println("License: BSD-2-clause") os.Exit(0) } // Read recipients from command line and quit if none are specified. // For listening or sending raw XML it's not required to specify a recipient except // when sending raw messages to MUCs (go-sendxmpp will join the MUC automatically). recipients := getopt.Args() if (len(recipients) == 0 && !*flagRaw && !*flagListen) || (len(recipients) == 0 && *flagChatroom) { log.Fatal("No recipient specified.") } // Check that all recipient JIDs are valid. for i, recipient := range recipients { validatedJid, err := MarshalJID(recipient) if err != nil { log.Fatal(err) } recipients[i] = validatedJid } // Read configuration file if user or password is not specified. if *flagUser == "" || *flagPassword == "" { // Read configuration from file. config, err := parseConfig(*flagFile) if err != nil { log.Fatal("Error parsing ", *flagFile, ": ", err) } // Set connection options according to config. user = config.username server = config.jserver password = config.password resource = config.resource if config.port != "" { server = net.JoinHostPort(server, fmt.Sprint(config.port)) } } // Overwrite user if specified via command line flag. if *flagUser != "" { user = *flagUser } // Overwrite server if specified via command line flag. if *flagServer != "" { server = *flagServer } // Overwrite password if specified via command line flag. if *flagPassword != "" { password = *flagPassword } // Overwrite resource if specified via command line flag if *flagResource != "" { resource = *flagResource } else if resource == "" { // Use "go-sendxmpp" plus a random string if no other resource is specified resource = "go-sendxmpp." + getID() } if (*flagHttpUpload != "") && (*flagInteractive || (*flagMessageFile != "")) { if *flagInteractive { log.Fatal("Interactive mode and http upload can't" + " be used at the same time.") } if *flagMessageFile != "" { log.Fatal("You can't send a message while using" + " http upload.") } } // Timeout timeout := time.Duration(*flagTimeout * 1000000000) // Use ALPN var tlsConfig tls.Config tlsConfig.ServerName = user[strings.Index(user, "@")+1:] tlsConfig.NextProtos = append(tlsConfig.NextProtos, "xmpp-client") tlsConfig.InsecureSkipVerify = *flagSkipVerify switch *flagTLSMinVersion { case 10: tlsConfig.MinVersion = tls.VersionTLS10 case 11: tlsConfig.MinVersion = tls.VersionTLS11 case 12: tlsConfig.MinVersion = tls.VersionTLS12 case 13: tlsConfig.MinVersion = tls.VersionTLS13 default: fmt.Println("Unknown TLS version.") os.Exit(0) } // Set XMPP connection options. options := xmpp.Options{ Host: server, User: user, DialTimeout: timeout, Resource: resource, 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) // an unencrypted connection is established. As StartTLS is // set when NoTLS is set go-sendxmpp won't use unencrypted // client-to-server connections. // See https://pkg.go.dev/github.com/mattn/go-xmpp#Options NoTLS: !*flagDirectTLS, StartTLS: !*flagDirectTLS, Debug: *flagDebug, TLSConfig: &tlsConfig, } // Read message from file. if *flagMessageFile != "" { message, err = readMessage(*flagMessageFile) if err != nil { log.Fatal(err) } } // Connect to server. client, err := connect(options, *flagDirectTLS) if err != nil { log.Fatal(err) } if *flagHttpUpload != "" { message = httpUpload(client, tlsConfig.ServerName, *flagHttpUpload) } // Skip reading message if '-i' or '--interactive' is set to work with e.g. 'tail -f'. // Also for listening mode. if !*flagInteractive && !*flagListen { if message == "" { scanner := bufio.NewScanner(os.Stdin) for scanner.Scan() { if message == "" { message = scanner.Text() } else { message = message + "\n" + scanner.Text() } } if err := scanner.Err(); err != nil { if err != io.EOF { // Close connection and quit. _ = client.Close() log.Fatal(err) } } } } // Send raw XML to chatroom if *flagChatroom && *flagRaw { // Join the MUCs. for _, recipient := range recipients { _, err := client.JoinMUCNoHistory(recipient, *flagResource) if err != nil { // Try to nicely close connection, // even if there was an error joining. _ = client.Close() log.Fatal(err) } } // Send raw XMP _, err = client.SendOrg(message) if err != nil { // Try to nicely close connection, // even if there was an error sending. _ = client.Close() log.Fatal(err) } // After sending the message, leave the MUCs for _, recipient := range recipients { _, err = client.LeaveMUC(recipient) if err != nil { log.Println(err) } } // Wait for a short time as some messages are not delievered by the server // if the connection is closed immediately after sending a message. time.Sleep(100 * time.Millisecond) return } if *flagListen { for { received, err := client.Recv() if err != nil { log.Println(err) } switch v := received.(type) { case xmpp.Chat: if v.Text == "" { continue } t := time.Now() bareFrom := strings.Split(v.Remote, "/")[0] // Print any messages if no recipients are specified if len(recipients) == 0 { fmt.Println(t.Format(time.RFC3339), bareFrom+":", v.Text) } else { for _, recipient := range recipients { if bareFrom == strings.ToLower(recipient) { fmt.Println(t.Format(time.RFC3339), bareFrom+":", v.Text) } } } default: continue } } } // Send message to chatroom(s) if the flag is set. if *flagChatroom { for _, recipient := range recipients { // Join the MUC. _, err := client.JoinMUCNoHistory(recipient, *flagResource) if err != nil { // Try to nicely close connection, // even if there was an error joining. _ = client.Close() log.Fatal(err) } } // Send in endless loop (for usage with e.g. "tail -f"). if *flagInteractive { for { scanner := bufio.NewScanner(os.Stdin) scanner.Scan() message = scanner.Text() for _, recipient := range recipients { _, err = client.Send(xmpp.Chat{Remote: recipient, Type: "groupchat", Text: message}) if err != nil { // Try to nicely close connection, // even if there was an error sending. _ = client.Close() log.Fatal(err) } } } } else { // Send the message. for _, recipient := range recipients { if *flagHttpUpload != "" { _, err = client.Send(xmpp.Chat{Remote: recipient, Type: "groupchat", Ooburl: message, Text: message}) } else { _, err = client.Send(xmpp.Chat{Remote: recipient, Type: "groupchat", Text: message}) } if err != nil { // Try to nicely close connection, // even if there was an error sending. _ = client.Close() log.Fatal(err) } } } for _, recipient := range recipients { // After sending the message, leave the Muc _, err = client.LeaveMUC(recipient) if err != nil { log.Println(err) } } } else { // Send raw XML if *flagRaw { _, err = client.SendOrg(message) if err != nil { // Try to nicely close connection, // even if there was an error sending. _ = client.Close() log.Fatal(err) } // Wait for a short time as some messages are not delievered by the server // if the connection is closed immediately after sending a message. time.Sleep(100 * time.Millisecond) return } // Send in endless loop (for usage with e.g. "tail -f"). if *flagInteractive { for { scanner := bufio.NewScanner(os.Stdin) scanner.Scan() message = scanner.Text() for _, recipient := range recipients { _, err = client.Send(xmpp.Chat{Remote: recipient, Type: "chat", Text: message}) if err != nil { // Try to nicely close connection, // even if there was an error sending. _ = client.Close() log.Fatal(err) } } } } else { for _, recipient := range recipients { if *flagHttpUpload != "" { _, err = client.Send(xmpp.Chat{Remote: recipient, Type: "chat", Ooburl: message, Text: message}) } else { _, err = client.Send(xmpp.Chat{Remote: recipient, Type: "chat", Text: message}) } if err != nil { // Try to nicely close connection, // even if there was an error sending. _ = client.Close() log.Fatal(err) } } } } // Wait for a short time as some messages are not delievered by the server // if the connection is closed immediately after sending a message. time.Sleep(100 * time.Millisecond) // Close XMPP connection err = client.Close() if err != nil { log.Fatal(err) } } go-sendxmpp-v0.2.0/go.mod000066400000000000000000000004671420171510000152440ustar00rootroot00000000000000module salsa.debian.org/mdosch/go-sendxmpp go 1.13 require ( github.com/gabriel-vasile/mimetype v1.4.0 github.com/mattn/go-xmpp v0.0.0-20211029151415-912ba614897a github.com/pborman/getopt/v2 v2.1.0 golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect salsa.debian.org/mdosch/xmppsrv v0.1.1 ) go-sendxmpp-v0.2.0/go.sum000066400000000000000000000037111420171510000152640ustar00rootroot00000000000000github.com/gabriel-vasile/mimetype v1.4.0 h1:Cn9dkdYsMIu56tGho+fqzh7XmvY2YyGU0FnbhiOsEro= github.com/gabriel-vasile/mimetype v1.4.0/go.mod h1:fA8fi6KUiG7MgQQ+mEWotXoEOvmxRtOJlERCzSmRvr8= github.com/mattn/go-xmpp v0.0.0-20211029151415-912ba614897a h1:BRuMO9LUDuGp6viOhrEbmuXNlvC78X5QdsnY9Wc+cqM= github.com/mattn/go-xmpp v0.0.0-20211029151415-912ba614897a/go.mod h1:Cs5mF0OsrRRmhkyOod//ldNPOwJsrBvJ+1WRspv0xoc= github.com/pborman/getopt/v2 v2.1.0 h1:eNfR+r+dWLdWmV8g5OlpyrTYHkhVNxHBdN2cCrJmOEA= github.com/pborman/getopt/v2 v2.1.0/go.mod h1:4NtW75ny4eBw9fO1bhtNdYTlZKYX5/tBLtsOpwKIKd0= golang.org/x/net v0.0.0-20210505024714-0287a6fb4125/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd h1:O7DYs+zxREGLKzKoMQrtrEacpb0ZVXA5rIwylE2Xchk= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 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/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= salsa.debian.org/mdosch/xmppsrv v0.1.1 h1:I/5HS+cOg27LRADQ2R4KqQY6DTVMsaPMu9ywSAMTOG8= salsa.debian.org/mdosch/xmppsrv v0.1.1/go.mod h1:udWXnWFa9zkcyN9YSB/u44BCnnRDpeQ0eDy3MVLjHZQ= go-sendxmpp-v0.2.0/httpupload.go000066400000000000000000000157001420171510000166450ustar00rootroot00000000000000// Copyright 2020 - 2021 Martin Dosch. // Use of this source code is governed by the BSD-2-clause // license that can be found in the LICENSE file. package main import ( "bytes" "crypto/rand" "encoding/xml" "fmt" "log" "net/http" "os" "path/filepath" "regexp" "strconv" "github.com/gabriel-vasile/mimetype" // MIT License "github.com/mattn/go-xmpp" // BSD-3-Clause" ) func getID() string { b := make([]byte, 12) _, err := rand.Read(b) if err != nil { log.Fatal(err) } id := fmt.Sprintf("%x-%x-%x", b[0:4], b[4:8], b[8:]) return id } func httpUpload(client *xmpp.Client, jserver string, filePath string) string { // Created with https://github.com/miku/zek type IQDiscoItemsType struct { XMLName xml.Name `xml:"query"` Text string `xml:",chardata"` Xmlns string `xml:"xmlns,attr"` Item []struct { Text string `xml:",chardata"` Jid string `xml:"jid,attr"` } `xml:"item"` } // Created with https://github.com/miku/zek type IQDiscoInfoType struct { XMLName xml.Name `xml:"query"` Text string `xml:",chardata"` Xmlns string `xml:"xmlns,attr"` Identity struct { Text string `xml:",chardata"` Type string `xml:"type,attr"` Name string `xml:"name,attr"` Category string `xml:"category,attr"` } `xml:"identity"` Feature []struct { Text string `xml:",chardata"` Var string `xml:"var,attr"` } `xml:"feature"` X []struct { Text string `xml:",chardata"` Type string `xml:"type,attr"` Xmlns string `xml:"xmlns,attr"` Field []struct { Text string `xml:",chardata"` Type string `xml:"type,attr"` Var string `xml:"var,attr"` Value string `xml:"value"` } `xml:"field"` } `xml:"x"` } type IQHttpUploadSlotRequest struct { XMLName xml.Name `xml:"request"` Xmlns string `xml:"xmlns,attr"` FileName string `xml:"filename,attr"` FileType string `xml:"mime-type,attr"` FileSize int64 `xml:"size,attr"` } // Created with https://github.com/miku/zek type IQHttpUploadSlot struct { XMLName xml.Name `xml:"slot"` Text string `xml:",chardata"` Xmlns string `xml:"xmlns,attr"` Get struct { Text string `xml:",chardata"` URL string `xml:"url,attr"` } `xml:"get"` Put struct { Text string `xml:",chardata"` URL string `xml:"url,attr"` Headers []struct { Name string `xml:"name,attr"` Value string `xml:",chardata"` } `xml:"header"` } `xml:"put"` } var iqDiscoItemsXML IQDiscoItemsType var iqDiscoInfoXML IQDiscoInfoType var iqHttpUploadSlotXML IQHttpUploadSlot var uploadComponent string var maxFileSize int64 // Get file size fileInfo, err := os.Stat(filePath) if err != nil { log.Fatal(err) } fileSize := fileInfo.Size() // Open File f, err := os.Open(filePath) if err != nil { log.Fatal(err) } defer f.Close() // Read file buffer := make([]byte, fileSize) _, err = f.Read(buffer) if err != nil { log.Fatal(err) } // Get mime type mimeType := mimetype.Detect(buffer).String() var mimeTypeEscaped bytes.Buffer xml.Escape(&mimeTypeEscaped, []byte(mimeType)) // Get file name fileName := filepath.Base(filePath) // Just use alphanumerical characters for now to work around // https://github.com/mattn/go-xmpp/issues/132 reg, err := regexp.Compile(`[^a-zA-Z0-9\+\-\_\.]+`) if err != nil { log.Fatal(err) } fileNameEscaped := reg.ReplaceAllString(fileName, "_") //var fileNameEscaped bytes.Buffer //xml.Escape(&fileNameEscaped, []byte(fileName)) // Query server for disco#items id := getID() c := make(chan xmpp.IQ) go getIQ(client, id, c) _, err = client.RawInformation(client.JID(), jserver, id, "get", "") if err != nil { log.Fatal(err) } iqContent := <-c close(c) if iqContent.Type != "result" { log.Fatal("Error while disco#items query.") } err = xml.Unmarshal(iqContent.Query, &iqDiscoItemsXML) if err != nil { log.Fatal(err) } // Check the services reported by disco#items for the http upload service for _, r := range iqDiscoItemsXML.Item { id = getID() c := make(chan xmpp.IQ) go getIQ(client, id, c) _, err = client.RawInformation(client.JID(), r.Jid, id, "get", "") if err != nil { log.Fatal(err) } iqDiscoInfo := <-c close(c) if iqDiscoInfo.Type != "result" { log.Fatal("Error while disco#info query.") } err = xml.Unmarshal(iqDiscoInfo.Query, &iqDiscoInfoXML) if err != nil { log.Fatal(err) } if iqDiscoInfoXML.Identity.Type == "file" && iqDiscoInfoXML.Identity.Category == "store" { uploadComponent = r.Jid } } if uploadComponent == "" { log.Fatal("No http upload component found.") } for _, r := range iqDiscoInfoXML.X { for i, t := range r.Field { if t.Var == "max-file-size" && r.Field[i-1].Value == "urn:xmpp:http:upload:0" { maxFileSize, err = strconv.ParseInt(t.Value, 10, 64) if err != nil { log.Fatal("Error while checking server maximum http upload file size.") } } } } // Check if the file size doesn't exceed the maximum file size of the http upload // component if a maximum file size is reported, if not just continue and hope for // the best. if maxFileSize != 0 { if fileSize > maxFileSize { log.Fatal("File size " + strconv.FormatInt(fileSize/1024/1024, 10) + " MB is larger than the maximum file size allowed (" + strconv.FormatInt(maxFileSize/1024/1024, 10) + " MB).") } } var request IQHttpUploadSlotRequest request.Xmlns = "urn:xmpp:http:upload:0" request.FileName = fileNameEscaped request.FileSize = fileSize request.FileType = mimeType r, err := xml.Marshal(request) if err != nil { log.Fatal(err) } // Request http upload slot id = getID() c = make(chan xmpp.IQ) go getIQ(client, id, c) _, err = client.RawInformation(client.JID(), uploadComponent, id, "get", string(r)) if err != nil { log.Fatal(err) } uploadSlot := <-c close(c) if uploadSlot.Type != "result" { log.Fatal("Error while requesting upload slot.") } err = xml.Unmarshal(uploadSlot.Query, &iqHttpUploadSlotXML) if err != nil { log.Fatal(err) } // Upload file httpClient := &http.Client{} req, err := http.NewRequest(http.MethodPut, iqHttpUploadSlotXML.Put.URL, bytes.NewBuffer(buffer)) if err != nil { log.Fatal(err) } req.Header.Set("Content-Type", mimeTypeEscaped.String()) for _, h := range iqHttpUploadSlotXML.Put.Headers { switch h.Name { case "Authorization", "Cookie", "Expires": req.Header.Set(h.Name, h.Value) } } resp, err := httpClient.Do(req) if err != nil { log.Fatal(err) } // Test for http status code "200 OK" or "201 Created" if resp.StatusCode != 200 && resp.StatusCode != 201 { log.Fatal("Http upload failed.") } // Return http link return iqHttpUploadSlotXML.Get.URL } func getIQ(client *xmpp.Client, id string, c chan xmpp.IQ) { for { msg, err := client.Recv() if err != nil { log.Fatal(err) } switch v := msg.(type) { case xmpp.IQ: if v.ID == id { c <- v return } } } } go-sendxmpp-v0.2.0/jid.go000066400000000000000000000050031420171510000152220ustar00rootroot00000000000000// Copyright 2014 The Mellium Contributors. // Use of this source code is governed by the BSD-2-clause // license that can be found in the LICENSE-mellium file. // Original taken from mellium.im/xmpp/jid (BSD-2-Clause) and adjusted for my needs. // Copyright 2020 - 2021 Martin Dosch package main import ( "errors" "strings" "unicode/utf8" ) // MarshalJID checks that JIDs include localpart and serverpart // and return it marshalled. Shamelessly stolen from // mellium.im/xmpp/jid func MarshalJID(input string) (string, error) { var ( err error localpart string domainpart string resourcepart string ) s := input // Remove any portion from the first '/' character to the end of the // string (if there is a '/' character present). sep := strings.Index(s, "/") if sep == -1 { resourcepart = "" } else { // If the resource part exists, make sure it isn't empty. if sep == len(s)-1 { return input, errors.New("Invalid JID" + input + ": The resourcepart must be larger than 0 bytes") } resourcepart = s[sep+1:] s = s[:sep] } // Remove any portion from the beginning of the string to the first // '@' character (if there is an '@' character present). sep = strings.Index(s, "@") switch { case sep == -1: // There is no @ sign, and therefore no localpart. return input, errors.New("Invalid JID: " + input) case sep == 0: // The JID starts with an @ sign (invalid empty localpart) err = errors.New("Invalid JID:" + input) return input, err default: domainpart = s[sep+1:] localpart = s[:sep] } // We'll throw out any trailing dots on domainparts, since they're ignored: // // If the domainpart includes a final character considered to be a label // separator (dot) by [RFC1034], this character MUST be stripped from // the domainpart before the JID of which it is a part is used for the // purpose of routing an XML stanza, comparing against another JID, or // constructing an XMPP URI or IRI [RFC5122]. In particular, such a // character MUST be stripped before any other canonicalization steps // are taken. domainpart = strings.TrimSuffix(domainpart, ".") if !utf8.ValidString(localpart) || !utf8.ValidString(domainpart) || !utf8.ValidString(resourcepart) { return input, errors.New("Invalid JID: " + input) } if localpart == "" || domainpart == "" { return input, errors.New("Invalid JID: " + input) } if resourcepart == "" { return localpart + "@" + domainpart, err } return localpart + "@" + domainpart + "/" + resourcepart, err } go-sendxmpp-v0.2.0/man/000077500000000000000000000000001420171510000147025ustar00rootroot00000000000000go-sendxmpp-v0.2.0/man/go-sendxmpp.1000066400000000000000000000061731420171510000172340ustar00rootroot00000000000000.\" generated with Ronn-NG/v0.9.1 .\" http://github.com/apjanke/ronn-ng/tree/0.9.1 .TH "GO\-SENDXMPP" "1" "February 2022" "" .SH "NAME" \fBgo\-sendxmpp\fR \- A little tool to send messages to an XMPP contact or MUC\. .SH "SYNOPSIS" \fBgo\-sendxmpp\fR [\-cdintx] [\-f value] [\-\-help] [\-j value] [\-m value] [\-p value] [\-r value] [\-u value] [parameters \|\.\|\.\|\.] .SH "DESCRIPTION" A little tool to send messages to an XMPP contact or MUC inspired by (but not as powerful as) \fBsendxmpp\fR\. .br You can either pipe a programs output to \fBgo\-sendxmpp\fR, write in your terminal (put \fB^D\fR in a new line to finish) or send the input from a file (\fB\-m\fR or \fB\-\-message\fR)\. The account data is expected at \fB~/\.config/go\-sendxmpp/sendxmpprc\fR (preferred) or \fB~/\.sendxmpprc\fR (for compatibility with the original perl sendxmpp) if no other configuration file location is specified with \fB\-f\fR or \fB\-\-file\fR\. .SH "OPTIONS" .IP "\[ci]" 4 \fB\-c\fR, \fB\-\-chatroom\fR=[\fIvalue\fR]: Send message to a chatroom\. .IP "\[ci]" 4 \fB\-d\fR, \fB\-\-debug\fR: Show debugging info\. .IP "\[ci]" 4 \fB\-f\fR, \fB\-\-file\fR=[\fIvalue\fR]: Set configuration file\. (Default: ~/\.sendxmpprc) .IP "\[ci]" 4 \fB\-\-help\fR: Show help\. .IP "\[ci]" 4 \fB\-\-http\-upload=\fR[\fIvalue\fR]: Send a file via http\-upload\. .IP "\[ci]" 4 \fB\-i\fR, \fB\-\-interactive\fR: Interactive mode (for use with e\.g\. \fBtail \-f\fR)\. .IP "\[ci]" 4 \fB\-j\fR, \fB\-\-jserver\fR=[\fIvalue\fR]: XMPP server address\. .IP "\[ci]" 4 \fB\-l\fR, \fB\-\-listen\fR: Listen for messages and print them to stdout\. If JIDs are specified only messages from those contacts are shown\. If no JIDs are specified all received messages will be shown\. .IP "\[ci]" 4 \fB\-m\fR, \fB\-\-message\fR=[\fIvalue\fR]: Set file including the message\. .IP "\[ci]" 4 \fB\-n\fR, \fB\-\-no\-tls\-verify\fR: Skip verification of TLS certificates (not recommended)\. .IP "\[ci]" 4 \fB\-\-tls\-version\fR=[\fIvalue\fR]: Minimal TLS version\. 10 (TSLv1\.0), 11 (TLSv1\.1) (Default: 12) .IP "\[ci]" 4 \fB\-p\fR, \fB\-\-password\fR=[\fIvalue\fR]: Password for XMPP account\. .IP "\[ci]" 4 \fB\-\-raw\fR: Send raw XML\. To send raw XML to a contact as normal chat message no contact must be specified\. To send raw XML to a MUC you have to specify the MUC via \fB\-c\fR and \fBgo\-sendxmpp\fR will join the MUC\. .IP "\[ci]" 4 \fB\-r\fR, \fB\-\-resource\fR=[\fIvalue\fR]: Set resource\. When sending to a chatroom this is used as 'alias'\. .IP "\[ci]" 4 \fB\-\-timeout=\fR[\fIvalue\fR]: Connection timeout in seconds\. (Default: 10) .IP "\[ci]" 4 \fB\-t\fR, \fB\-\-tls\fR: Use direct TLS\. .IP "\[ci]" 4 \fB\-u\fR, \fB\-\-username\fR=[\fIvalue\fR]: Username for XMPP account (JID)\. .IP "\[ci]" 4 \fB\-\-version\fR: Show version information\. .IP "" 0 .SH "CHAT" Feel free to join \fIhttps://join\.jabber\.network/#go\-sendxmpp@chat\.mdosch\.de?join\fR\. .SH "AUTHOR" Written by Martin Dosch\. .SH "REPORTING BUGS" Report bugs at \fIhttps://salsa\.debian\.org/mdosch/go\-sendxmpp/issues\fR\. .SH "COPYRIGHT" Copyright (c) 2018 \- 2021 Martin Dosch License: BSD 2\-clause License .SH "SEE ALSO" go\-sendxmpp(5), sendxmpp(1) go-sendxmpp-v0.2.0/man/go-sendxmpp.1.html000066400000000000000000000160501420171510000201720ustar00rootroot00000000000000 go-sendxmpp(1) - A little tool to send messages to an XMPP contact or MUC.
  1. go-sendxmpp(1)
  2. go-sendxmpp(1)

NAME

go-sendxmpp - A little tool to send messages to an XMPP contact or MUC.

SYNOPSIS

go-sendxmpp [-cdintx] [-f value] [--help] [-j value] [-m value] [-p value] [-r value] [-u value] [parameters ...]

DESCRIPTION

A little tool to send messages to an XMPP contact or MUC inspired by (but not as powerful as) sendxmpp.
You can either pipe a programs output to go-sendxmpp, write in your terminal (put ^D in a new line to finish) or send the input from a file (-m or --message). The account data is expected at ~/.config/go-sendxmpp/sendxmpprc (preferred) or ~/.sendxmpprc (for compatibility with the original perl sendxmpp) if no other configuration file location is specified with -f or --file.

OPTIONS

  • -c, --chatroom=[value]: Send message to a chatroom.

  • -d, --debug: Show debugging info.

  • -f, --file=[value]: Set configuration file. (Default: ~/.sendxmpprc)

  • --help: Show help.

  • --http-upload=[value]: Send a file via http-upload.

  • -i, --interactive: Interactive mode (for use with e.g. tail -f).

  • -j, --jserver=[value]: XMPP server address.

  • -l, --listen: Listen for messages and print them to stdout. If JIDs are specified only messages from those contacts are shown. If no JIDs are specified all received messages will be shown.

  • -m, --message=[value]: Set file including the message.

  • -n, --no-tls-verify: Skip verification of TLS certificates (not recommended).

  • --tls-version=[value]: Minimal TLS version. 10 (TSLv1.0), 11 (TLSv1.1) (Default: 12)

  • -p, --password=[value]: Password for XMPP account.

  • --raw: Send raw XML. To send raw XML to a contact as normal chat message no contact must be specified. To send raw XML to a MUC you have to specify the MUC via -c and go-sendxmpp will join the MUC.

  • -r, --resource=[value]: Set resource. When sending to a chatroom this is used as 'alias'.

  • --timeout=[value]: Connection timeout in seconds. (Default: 10)

  • -t, --tls: Use direct TLS.

  • -u, --username=[value]: Username for XMPP account (JID).

  • --version: Show version information.

CHAT

Feel free to join https://join.jabber.network/#go-sendxmpp@chat.mdosch.de?join.

AUTHOR

Written by Martin Dosch.

REPORTING BUGS

Report bugs at https://salsa.debian.org/mdosch/go-sendxmpp/issues.

Copyright (c) 2018 - 2021 Martin Dosch License: BSD 2-clause License

SEE ALSO

go-sendxmpp(5), sendxmpp(1)

  1. February 2022
  2. go-sendxmpp(1)
go-sendxmpp-v0.2.0/man/go-sendxmpp.1.ronn000066400000000000000000000050571420171510000202070ustar00rootroot00000000000000go-sendxmpp(1) -- A little tool to send messages to an XMPP contact or MUC. ==== ## SYNOPSIS `go-sendxmpp` [-cdintx] [-f value] [--help] [-j value] [-m value] [-p value] [-r value] [-u value] [parameters ...] ## DESCRIPTION A little tool to send messages to an XMPP contact or MUC inspired by (but not as powerful as) `sendxmpp`. You can either pipe a programs output to `go-sendxmpp`, write in your terminal (put `^D` in a new line to finish) or send the input from a file (`-m` or `--message`). The account data is expected at `~/.config/go-sendxmpp/sendxmpprc` (preferred) or `~/.sendxmpprc` (for compatibility with the original perl sendxmpp) if no other configuration file location is specified with `-f` or `--file`. ## OPTIONS * `-c`, `--chatroom`=[]: Send message to a chatroom. * `-d`, `--debug`: Show debugging info. * `-f`, `--file`=[]: Set configuration file. (Default: ~/.sendxmpprc) * `--help`: Show help. * `--http-upload=`[]: Send a file via http-upload. * `-i`, `--interactive`: Interactive mode (for use with e.g. `tail -f`). * `-j`, `--jserver`=[]: XMPP server address. * `-l`, `--listen`: Listen for messages and print them to stdout. If JIDs are specified only messages from those contacts are shown. If no JIDs are specified all received messages will be shown. * `-m`, `--message`=[]: Set file including the message. * `-n`, `--no-tls-verify`: Skip verification of TLS certificates (not recommended). * `--tls-version`=[]: Minimal TLS version. 10 (TSLv1.0), 11 (TLSv1.1) (Default: 12) * `-p`, `--password`=[]: Password for XMPP account. * `--raw`: Send raw XML. To send raw XML to a contact as normal chat message no contact must be specified. To send raw XML to a MUC you have to specify the MUC via `-c` and `go-sendxmpp` will join the MUC. * `-r`, `--resource`=[]: Set resource. When sending to a chatroom this is used as 'alias'. * `--timeout=`[]: Connection timeout in seconds. (Default: 10) * `-t`, `--tls`: Use direct TLS. * `-u`, `--username`=[]: Username for XMPP account (JID). * `--version`: Show version information. ## CHAT Feel free to join [https://join.jabber.network/#go-sendxmpp@chat.mdosch.de?join](https://join.jabber.network/#go-sendxmpp@chat.mdosch.de?join). ## AUTHOR Written by Martin Dosch. ## REPORTING BUGS Report bugs at [https://salsa.debian.org/mdosch/go-sendxmpp/issues](https://salsa.debian.org/mdosch/go-sendxmpp/issues). ## COPYRIGHT Copyright (c) 2018 - 2021 Martin Dosch License: BSD 2-clause License ## SEE ALSO go-sendxmpp(5), sendxmpp(1) go-sendxmpp-v0.2.0/man/go-sendxmpp.5000066400000000000000000000026041420171510000172330ustar00rootroot00000000000000.\" generated with Ronn-NG/v0.9.1 .\" http://github.com/apjanke/ronn-ng/tree/0.9.1 .TH "GO\-SENDXMPP" "5" "February 2022" "" .SH "NAME" \fBgo\-sendxmpp\fR \- A little tool to send messages to an XMPP contact or MUC\. .SH "LOCATION" The account data is expected at ~/\.config/go\-sendxmpp/sendxmpprc (preferred) or ~/\.sendxmpprc (for compatibility with the original perl sendxmpp) if no other configuration file location is specified with \-f or \-\-file\. The configuration file is expected to be in the following format: .SH "FORMAT" username: [\fIyour_jid\fR] .br jserver: [\fIjabber_server\fR] .br port: [\fIjabber_port\fR] .br password: [\fIyour_jabber_password\fR] .br eval_password: [\fIcommand_to_unlock_your_password\fR] resource: [\fIyour_resource\fR] .SH "REQUIRED SETTINGS" If all necessary settings are supplied as command line arguments no config file is needed at all\. Setting \fBjserver\fR and \fBport\fR might not be necessary depending on the used server\. .br You should either use a password manager and the setting \fBeval_password\fR or add your password in plaintext to the config file with the setting \fBpassword\fR\. .SH "AUTHOR" Written by Martin Dosch\. .SH "REPORTING BUGS" Report bugs at \fIhttps://salsa\.debian\.org/mdosch/go\-sendxmpp/issues\fR\. .SH "COPYRIGHT" Copyright (c) 2018 \- 2021 Martin Dosch License: BSD 2\-clause License .SH "SEE ALSO" go\-sendxmpp(1), sendxmpp(1) go-sendxmpp-v0.2.0/man/go-sendxmpp.5.html000066400000000000000000000114621420171510000202000ustar00rootroot00000000000000 go-sendxmpp(5) - A little tool to send messages to an XMPP contact or MUC.
  1. go-sendxmpp(5)
  2. go-sendxmpp(5)

NAME

go-sendxmpp - A little tool to send messages to an XMPP contact or MUC.

LOCATION

The account data is expected at ~/.config/go-sendxmpp/sendxmpprc (preferred) or ~/.sendxmpprc (for compatibility with the original perl sendxmpp) if no other configuration file location is specified with -f or --file. The configuration file is expected to be in the following format:

FORMAT

username: [your_jid]
jserver: [jabber_server]
port: [jabber_port]
password: [your_jabber_password]
eval_password: [command_to_unlock_your_password] resource: [your_resource]

REQUIRED SETTINGS

If all necessary settings are supplied as command line arguments no config file is needed at all. Setting jserver and port might not be necessary depending on the used server.
You should either use a password manager and the setting eval_password or add your password in plaintext to the config file with the setting password.

AUTHOR

Written by Martin Dosch.

REPORTING BUGS

Report bugs at https://salsa.debian.org/mdosch/go-sendxmpp/issues.

Copyright (c) 2018 - 2021 Martin Dosch License: BSD 2-clause License

SEE ALSO

go-sendxmpp(1), sendxmpp(1)

  1. February 2022
  2. go-sendxmpp(5)
go-sendxmpp-v0.2.0/man/go-sendxmpp.5.ronn000066400000000000000000000023541420171510000202100ustar00rootroot00000000000000go-sendxmpp(5) -- A little tool to send messages to an XMPP contact or MUC. ==== ## LOCATION The account data is expected at ~/.config/go-sendxmpp/sendxmpprc (preferred) or ~/.sendxmpprc (for compatibility with the original perl sendxmpp) if no other configuration file location is specified with -f or --file. The configuration file is expected to be in the following format: ## FORMAT username: [] jserver: [] port: [] password: [] eval_password: [] resource: [] ## REQUIRED SETTINGS If all necessary settings are supplied as command line arguments no config file is needed at all. Setting `jserver` and `port` might not be necessary depending on the used server. You should either use a password manager and the setting `eval_password` or add your password in plaintext to the config file with the setting `password`. ## AUTHOR Written by Martin Dosch. ## REPORTING BUGS Report bugs at [https://salsa.debian.org/mdosch/go-sendxmpp/issues](https://salsa.debian.org/mdosch/go-sendxmpp/issues). ## COPYRIGHT Copyright (c) 2018 - 2021 Martin Dosch License: BSD 2-clause License ## SEE ALSO go-sendxmpp(1), sendxmpp(1)