Add `--timeout` flag.

v0.2
Martin Dosch 2 years ago
parent 5dd755c4b2
commit a866e98e1e

@ -3,6 +3,7 @@
##[Unreleased]
### Added
- Added listening function.
- Added flag to configure connection timeout.
### Removed
- Removed deprecated option `-x`.

@ -75,7 +75,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 [-cdilntx] [-f value] [--help] [--http-upload value] [-j value] [-m value] [-p value] [--raw] [-r value] [-u value] [parameters ...]
Usage: go-sendxmpp [-cdilnt] [-f value] [--help] [--http-upload value] [-j value] [-m value] [-p value] [--raw] [-r value] [--timeout value] [-u value] [parameters ...]
-c, --chatroom Send message to a chatroom.
-d, --debug Show debugging info.
-f, --file=value Set configuration file. (Default:
@ -97,6 +97,8 @@ Usage: go-sendxmpp [-cdilntx] [-f value] [--help] [--http-upload value] [-j valu
-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.
-u, --username=value
Username for XMPP account.

@ -237,6 +237,7 @@ func main() {
"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.")
// Parse command line flags.
getopt.Parse()
@ -316,6 +317,9 @@ func main() {
}
}
// Timeout
timeout := time.Duration(*flagTimeout * 1000000000)
// Use ALPN
var tlsConfig tls.Config
tlsConfig.ServerName = user[strings.Index(user, "@")+1:]
@ -324,11 +328,9 @@ func main() {
// Set XMPP connection options.
options := xmpp.Options{
Host: server,
User: user,
// TODO: Check whether the timeout is reasonable or maybe make
// it configurable
DialTimeout: 1 * time.Second,
Host: server,
User: user,
DialTimeout: timeout,
Resource: resource,
Password: password,
// NoTLS doesn't mean that no TLS is used at all but that instead

@ -50,6 +50,9 @@ Send raw XML\. To send raw XML to a contact as normal chat message no contact mu
\fB\-r\fR, \fB\-\-resource\fR=[\fIvalue\fR]
Set resource\. When sending to a chatroom this is used as 'alias'\.
.TP
\fB\-\-timeout=\fR[\fIvalue\fR]
Connection timeout in seconds\. (Default: 10)
.TP
\fB\-t\fR, \fB\-\-tls\fR
Use direct TLS\.
.TP

@ -137,6 +137,9 @@ To send raw XML to a MUC you have to specify the MUC via <code>-c</code> and <co
<dd>Set resource. When sending to a chatroom this is used as
'alias'.</dd>
<dt>
<code>--timeout=</code>[<var>value</var>]</dt>
<dd>Connection timeout in seconds. (Default: 10)</dd>
<dt>
<code>-t</code>, <code>--tls</code>
</dt>
<dd>Use direct TLS.</dd>
@ -164,7 +167,7 @@ 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>

@ -58,6 +58,9 @@ To send raw XML to a MUC you have to specify the MUC via `-c` and `go-sendxmpp`
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.

@ -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" "January 2022" ""
.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"

@ -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'>January 2022</li>
<li class='tc'>February 2022</li>
<li class='tr'>go-sendxmpp(5)</li>
</ol>

Loading…
Cancel
Save