Add support for sending files OOB.

singlequotes
Martin Dosch 1 year ago
parent 9afb631412
commit d481aa688c
No known key found for this signature in database
GPG Key ID: 52A57CFCE13D657D

@ -1,6 +1,8 @@
# Changelog
## Unreleased
### Added
- Add support for sending Out of Band Data (OOB).
## [v0.5.6] 2022-11-11
### Added

@ -83,7 +83,7 @@ If no configuration file is present or if the values should be overridden it is
the account details via command line options:
```plain
Usage: go-sendxmpp [-cdilnt] [-a value] [-f value] [--help] [--http-upload value] [-j value] [-m value] [--muc-password value] [--ox] [--ox-delete-nodes] [--ox-genprivkey-rsa] [--ox-genprivkey-x25519] [--ox-import-privkey value] [--ox-passphrase value] [-p value] [--raw] [-r value] [--timeout value] [--tls-version value] [-u value] [--version] [parameters ...]
Usage: go-sendxmpp [-cdilnt] [-a value] [-f value] [--help] [-h value] [-j value] [-m value] [--muc-password value] [--ox] [--ox-delete-nodes] [--ox-genprivkey-rsa] [--ox-genprivkey-x25519] [--ox-import-privkey value] [--ox-passphrase value] [-p value] [--raw] [-r value] [--timeout value] [--tls-version value] [-u value] [--version] [parameters ...]
-a, --alias=value Set alias/nicknamefor chatrooms.
-c, --chatroom Send message to a chatroom.
-d, --debug Show debugging info.
@ -102,6 +102,8 @@ Usage: go-sendxmpp [-cdilnt] [-a value] [-f value] [--help] [--http-upload value
Password for password protected MUCs.
-n, --no-tls-verify
Skip verification of TLS certificates (not recommended).
--oob-file=value
URL to send a file as out of band data.
--ox Use "OpenPGP for XMPP" encryption (experimental).
--ox-delete-nodes
Delete existing OpenPGP nodes on the server.

@ -9,6 +9,7 @@ import (
"crypto/rand"
"fmt"
"log"
"net/url"
"os"
"regexp"
"strings"
@ -23,6 +24,12 @@ func validUTF8(s string) string {
return s
}
func validURI(s string) (string, error) {
// Check if URI is valid
_, err := url.ParseRequestURI(s)
return s, err
}
func readFile(path string) (*bytes.Buffer, error) {
file, err := os.Open(path)
if err != nil {

@ -120,6 +120,7 @@ func main() {
flagOxImportPrivKey := getopt.StringLong("ox-import-privkey", 0, "",
"Import an existing private OpenPGP key.")
flagOxDeleteNodes := getopt.BoolLong("ox-delete-nodes", 0, "Delete existing OpenPGP nodes on the server.")
flagOOBFile := getopt.StringLong("oob-file", 0, "", "URL to send a file as out of band data.")
// Parse command line flags.
getopt.Parse()
@ -146,6 +147,8 @@ func main() {
case *flagHTTPUpload != "" && *flagMessageFile != "":
log.Fatal("You can't send a message while using" +
" http upload.")
case *flagOx && *flagOOBFile != "":
log.Fatal("No encryption possible for OOB data.")
}
// Read recipients from command line and quit if none are specified.
@ -270,7 +273,7 @@ func main() {
// Also for listening mode and Ox key handling.
if !*flagInteractive && !*flagListen && *flagHTTPUpload == "" &&
!*flagOxDeleteNodes && *flagOxImportPrivKey == "" &&
!*flagOxGenPrivKeyX25519 && !*flagOxGenPrivKeyRSA &&
!*flagOxGenPrivKeyX25519 && !*flagOxGenPrivKeyRSA && *flagOOBFile == "" &&
message == "" {
scanner := bufio.NewScanner(os.Stdin)
@ -295,7 +298,7 @@ func main() {
// Exit if message is empty.
if message == "" && !*flagInteractive && !*flagListen && !*flagOxGenPrivKeyRSA &&
!*flagOxGenPrivKeyX25519 && *flagOxImportPrivKey == "" &&
!*flagOxDeleteNodes && *flagHTTPUpload == "" {
!*flagOxDeleteNodes && *flagHTTPUpload == "" && *flagOOBFile == "" {
os.Exit(0)
}
@ -389,6 +392,16 @@ func main() {
*flagHTTPUpload)
}
if *flagOOBFile != "" {
// Remove invalid UTF8 code points.
message = validUTF8(*flagOOBFile)
// Check if the URI is valid.
_, err := validURI(message)
if err != nil {
log.Fatal(err)
}
}
var msgType string
msgType = "chat"
if *flagChatroom {
@ -532,7 +545,7 @@ func main() {
break
}
switch {
case *flagHTTPUpload != "":
case *flagHTTPUpload != "" || *flagOOBFile != "":
_, err = client.Send(xmpp.Chat{Remote: recipient.Jid,
Type: msgType, Ooburl: message, Text: message})
if err != nil {

@ -1,6 +1,6 @@
.\" generated with Ronn-NG/v0.9.1
.\" http://github.com/apjanke/ronn-ng/tree/0.9.1
.TH "GO\-SENDXMPP" "1" "November 2022" ""
.TH "GO\-SENDXMPP" "1" "February 2023" ""
.SH "NAME"
\fBgo\-sendxmpp\fR \- A tool to send messages to an XMPP contact or MUC\.
.SH "SYNOPSIS"
@ -47,6 +47,9 @@ Password for password protected MUCs\.
\fB\-n\fR, \fB\-\-no\-tls\-verify\fR
Skip verification of TLS certificates (not recommended)\.
.TP
\fB\-\-oob\-file\fR=[\fIvalue\fR]
URL to send a file as out of band data\.
.TP
\fB\-\-ox\fR
Use "OpenPGP for XMPP" encryption (experimental)\.
.br

@ -132,6 +132,9 @@ are shown. If no JIDs are specified all received messages will be shown.</dd>
<code>-n</code>, <code>--no-tls-verify</code>
</dt>
<dd>Skip verification of TLS certificates (not recommended).</dd>
<dt>
<code>--oob-file</code>=[<var>value</var>]</dt>
<dd>URL to send a file as out of band data.</dd>
<dt><code>--ox</code></dt>
<dd>Use "OpenPGP for XMPP" encryption (experimental). <br>
Ox in go-sendxmpp only supports sending encrypted 1-1 messages. Sending to groupchats and
@ -215,7 +218,7 @@ License: BSD 2-clause License</p>
<ol class='man-decor man-foot man foot'>
<li class='tl'></li>
<li class='tc'>November 2022</li>
<li class='tc'>February 2023</li>
<li class='tr'>go-sendxmpp(1)</li>
</ol>

@ -53,6 +53,9 @@ Password for password protected MUCs.
* `-n`, `--no-tls-verify`:
Skip verification of TLS certificates (not recommended).
* `--oob-file`=[<value>]:
URL to send a file as out of band data.
* `--ox`:
Use "OpenPGP for XMPP" encryption (experimental).
Ox in go-sendxmpp only supports sending encrypted 1-1 messages. Sending to groupchats and

Loading…
Cancel
Save