Deprecate resource setting and introduce alias setting.

v0.5
Martin Dosch 2 years ago
parent 6bac04c88c
commit d7cfbcfb8f

@ -4,6 +4,7 @@
### Added
- Reply to `disco#info` queries.
- Send `service-unavailable` errors for all other IQs of type `get` and `set`.
- New config option and command line flag `alias` to uncouple MUC nickname/alias from resource.
### Changed
- Ox: Improve error messages for failed key requests.
@ -11,6 +12,7 @@
- Check for empty messages.
- Always look up CNAME before doing SRV lookups (via xmppsrv v0.2.3).
- Detect CNAME loops (max. 5 CNAMEs) (via xmppsrv >= v0.2.4).
- Deprecate resource config option and command line flag.
## [v0.5.1] 2022-05-22
### Changed

@ -73,17 +73,18 @@ setting:
eval_password: <command_to_unlock_your_password>
```
You can also configure the resource (and nickname for MUCs) via the `resource` setting:
You can also configure the alias/nickname for MUCs via the `alias` setting:
```
resource: <my_resource>
alias: <my_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] [--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] [--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 ...]
-a, --alias=value Set alias/nicknamefor chatrooms.
-c, --chatroom Send message to a chatroom.
-d, --debug Show debugging info.
-f, --file=value Set configuration file. (Default:
@ -120,7 +121,7 @@ Usage: go-sendxmpp [-cdilnt] [-f value] [--help] [--http-upload value] [-j value
--raw Send raw XML.
-r, --resource=value
Set resource. When sending to a chatroom this is used as
'alias'.
'alias'. DEPRECATED: Use --alias instead.
--timeout=value
Connection timeout in seconds. [10]
-t, --tls Use direct TLS.

@ -27,6 +27,7 @@ type configuration struct {
port string
password string
resource string
alias string
}
func readMessage(messageFilePath string) (string, error) {
@ -76,10 +77,10 @@ func main() {
}
var (
err error
message, user, server, password, resource string
oxPrivKey *crypto.Key
recipients []recipientsType
err error
message, user, server, password, resource, alias string
oxPrivKey *crypto.Key
recipients []recipientsType
)
// Define command line flags.
@ -92,7 +93,9 @@ func main() {
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'.")
"When sending to a chatroom this is used as 'alias'. DEPRECATED: Use --alias instead.")
flagAlias := getopt.StringLong("alias", 'a', "", "Set alias/nickname"+
"for chatrooms.")
flagFile := getopt.StringLong("file", 'f', "", "Set configuration file. (Default: "+
"~/.config/go-sendxmpp/sendxmpprc)")
flagMessageFile := getopt.StringLong("message", 'm', "", "Set file including the message.")
@ -168,6 +171,7 @@ func main() {
server = config.jserver
password = config.password
resource = config.resource
alias = config.alias
if config.port != "" {
server = net.JoinHostPort(server, fmt.Sprint(config.port))
}
@ -188,11 +192,21 @@ func main() {
password = *flagPassword
}
// Overwrite resource if specified via command line flag
switch {
// Use "go-sendxmpp" if no nick is specified via config or command line flag.
case alias == "" && *flagAlias == "":
alias = "go-sendxmpp"
// Overwrite configured alias if a nick is specified via command line flag.
case *flagAlias != "":
alias = *flagAlias
}
// Overwrite resource if specified via command line flag.
if *flagResource != "" {
fmt.Println("Deprecated flag: --resource.")
resource = *flagResource
} else if resource == "" {
// Use "go-sendxmpp" plus a random string if no other resource is specified
// Use "go-sendxmpp" plus a random string if no other resource is specified.
resource = "go-sendxmpp." + getShortID()
}
@ -371,10 +385,10 @@ func main() {
for _, recipient := range recipients {
if *flagMUCPassword != "" {
dummyTime := time.Now()
_, err = client.JoinProtectedMUC(recipient.Jid, resource,
_, err = client.JoinProtectedMUC(recipient.Jid, alias,
*flagMUCPassword, xmpp.NoHistory, 0, &dummyTime)
} else {
_, err = client.JoinMUCNoHistory(recipient.Jid, resource)
_, err = client.JoinMUCNoHistory(recipient.Jid, alias)
}
if err != nil {
log.Fatal(err)

@ -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" "July 2022" ""
.TH "GO\-SENDXMPP" "1" "August 2022" ""
.SH "NAME"
\fBgo\-sendxmpp\fR \- A little tool to send messages to an XMPP contact or MUC\.
.SH "SYNOPSIS"
@ -10,6 +10,8 @@ A little tool to send messages to an XMPP contact or MUC inspired by (but not as
.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/config\fR (preferred), \fB~/\.config/go\-sendxmpp/sendxmpprc\fR (deprecated) \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"
\fB\-a\fR, \fB\-\-alias\fR=[\fIvalue\fR]: Set alias/nicknamefor chatrooms\.
.P
\fB\-c\fR, \fB\-\-chatroom\fR=[\fIvalue\fR]: Send message to a chatroom\.
.P
\fB\-d\fR, \fB\-\-debug\fR: Show debugging info\.
@ -56,7 +58,7 @@ If there is an existing private key for "OpenPGP for XMPP" created by another cl
.P
\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 go\-sendxmpp will join the MUC\.
.P
\fB\-r\fR, \fB\-\-resource\fR=[\fIvalue\fR]: Set resource\. When sending to a chatroom this is used as 'alias'\.
\fB\-r\fR, \fB\-\-resource\fR=[\fIvalue\fR]: DEPRECATED: Set resource\. When sending to a chatroom this is used as 'alias'\.
.P
\fB\-\-timeout=\fR[\fIvalue\fR]: Connection timeout in seconds\. (Default: 10)
.P

@ -91,6 +91,9 @@ file location is specified with <code>-f</code> or <code>--file</code>.</p>
<h2 id="OPTIONS">OPTIONS</h2>
<p><code>-a</code>, <code>--alias</code>=[<var>value</var>]:
Set alias/nicknamefor chatrooms.</p>
<p><code>-c</code>, <code>--chatroom</code>=[<var>value</var>]:
Send message to a chatroom.</p>
@ -174,7 +177,7 @@ file location is specified with <code>-f</code> or <code>--file</code>.</p>
To send raw XML to a MUC you have to specify the MUC via <code>-c</code> and go-sendxmpp will join the MUC.</p>
<p><code>-r</code>, <code>--resource</code>=[<var>value</var>]:
Set resource. When sending to a chatroom this is used as 'alias'.</p>
DEPRECATED: Set resource. When sending to a chatroom this is used as 'alias'.</p>
<p><code>--timeout=</code>[<var>value</var>]:
Connection timeout in seconds. (Default: 10)</p>
@ -206,11 +209,11 @@ License: BSD 2-clause License</p>
<h2 id="SEE-ALSO">SEE ALSO</h2>
<p><span class="man-ref">go-sendxmpp<span class="s">(5)</span></span>, <span class="man-ref">sendxmpp<span class="s">(1)</span></span></p>
<p><a class="man-ref" href="go-sendxmpp.5.html">go-sendxmpp<span class="s">(5)</span></a>, <span class="man-ref">sendxmpp<span class="s">(1)</span></span></p>
<ol class='man-decor man-foot man foot'>
<li class='tl'></li>
<li class='tc'>July 2022</li>
<li class='tc'>August 2022</li>
<li class='tr'>go-sendxmpp(1)</li>
</ol>

@ -16,6 +16,9 @@ file location is specified with `-f` or `--file`.
## OPTIONS
`-a`, `--alias`=[<value>]:
Set alias/nicknamefor chatrooms.
`-c`, `--chatroom`=[<value>]:
Send message to a chatroom.
@ -99,7 +102,7 @@ file location is specified with `-f` or `--file`.
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'.
DEPRECATED: Set resource. When sending to a chatroom this is used as 'alias'.
`--timeout=`[<value>]:
Connection timeout in seconds. (Default: 10)

@ -1,6 +1,6 @@
.\" generated with Ronn-NG/v0.9.1
.\" http://github.com/apjanke/ronn-ng/tree/0.9.1
.TH "GO\-SENDXMPP" "5" "February 2022" ""
.TH "GO\-SENDXMPP" "5" "August 2022" ""
.SH "NAME"
\fBgo\-sendxmpp\fR \- A little tool to send messages to an XMPP contact or MUC\.
.SH "LOCATION"
@ -16,7 +16,7 @@ password: [\fIyour_jabber_password\fR]
.br
eval_password: [\fIcommand_to_unlock_your_password\fR]
.br
resource: [\fIyour_resource\fR]
alias: [\fIyour_alias\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

@ -88,7 +88,7 @@ jserver: [<var>jabber_server</var>] <br>
port: [<var>jabber_port</var>] <br>
password: [<var>your_jabber_password</var>] <br>
eval_password: [<var>command_to_unlock_your_password</var>] <br>
resource: [<var>your_resource</var>]</p>
alias: [<var>your_alias</var>]</p>
<h2 id="REQUIRED-SETTINGS">REQUIRED SETTINGS</h2>
@ -116,7 +116,7 @@ License: BSD 2-clause License</p>
<ol class='man-decor man-foot man foot'>
<li class='tl'></li>
<li class='tc'>February 2022</li>
<li class='tc'>August 2022</li>
<li class='tr'>go-sendxmpp(5)</li>
</ol>

@ -14,7 +14,7 @@ jserver: [<jabber_server>]
port: [<jabber_port>]
password: [<your_jabber_password>]
eval_password: [<command_to_unlock_your_password>]
resource: [<your_resource>]
alias: [<your_alias>]
## REQUIRED SETTINGS

@ -7,6 +7,7 @@ package main
import (
"bufio"
"errors"
"fmt"
"log"
"os"
"os/exec"
@ -120,6 +121,9 @@ func parseConfig(configPath string) (configuration, error) {
output.port = row[1]
case "resource:":
output.resource = row[1]
fmt.Println(configPath+":", "Deprecated option: resource.")
case "alias:":
output.alias = row[1]
default:
if len(row) >= 2 {
if strings.Contains(scanner.Text(), ";") {

Loading…
Cancel
Save