Commit Graph

13 Commits (bcf7c1b2e87cfaa3b9fdeaa58d0b5ea0cce69e97)

Author SHA1 Message Date
Michael Santos bcf7c1b2e8 Check libstrophe funs for NULL return values
Ensure XML elements may exist in the stanza before attempting to use
them.
9 years ago
Michael Santos 4cbd8ec1c3 Add wrappers around libstrophe funs that may fail
Check for errors on libstrophe functions that return non-void. Some of
the funs have undocumented failure conditions (e.g.,
xmpp_stanza_copy()). Others return less than zero or enum values. To
account for future discoveries, use a wrapper instead of a macro.
9 years ago
Michael Santos ef7e414af6 Exit on connection failure
Should output a better error message based on the status returned to
handle_connection.
9 years ago
Michael Santos cf501f5fde Optionally disable XMPP pings 10 years ago
Michael Santos fdab8a8901 Initial support for XEP-0198 stream management
Request stream management for the session by default. The rate of requests
and acks is controlled by the -I option. With stream management, the
client can check when all stanzas have been flushed to the server. For
example, the following works:

    cat /path/textfile | xmppipe -o transfer -r sender

    # on another system
    xmppipe -o transfer -r receiver > tmpfile

The behaviour is to always attempt enabling stream management. The XEP
is ambiguous about the response to an enable when stream management is
not offered. Presumably the server will respond with "failure".

So the code should probably have 2 checks:

* if stream management is offered as a feature, send an enable
* if the server responds with "enabled", handle requests
10 years ago
Michael Santos a233caf32c Set default keepalive failure limit 10 years ago
Michael Santos 246c148d0e Track ping replies
Set a limit on the number of pings without a reply and exit if the limit
is reached. Useful for detecing broken network connections due to
network changes.

The default configuration will take about 4 minutes to detect failure
(1 keepalive every 60 seconds, tolerate 3 failures).
10 years ago
Michael Santos 4cbee9c78c Optionally specify server address/port 10 years ago
Michael Santos c983814007 Exit on connection failure
No point shutting down nicely if the connection has failed: exit
immediately and print out an error.

The error is the same whether the connection has failed due to a DNS
lookup, TCP connection or authentication failure. Running in debug mode
can show the reason for failure. libstrophe has an enum indicating the
connection state; maybe this can be used for better error reporting.
10 years ago
Michael Santos 353951298e Generate a unique ID per message
Add a ID per message. Seems to fix the duplicate messages seen with MUCs
on the Conversations android client whenever the network is switched
(e.g., from wifi to cell).

Introduce a dependency on Linux's libuuid which introduces portability
issues. However, it should be simple to add support for the BSD UUID
interface.

libuuid was used because it is a fast and simple way of generating
a unique id.  Realistically, the ID only needs to be unique within
the MUC and so could probably be replaced with an sprintf() combining
time of day, PID and a random number.
10 years ago
Michael Santos 4325445536 Exit on presence errors
Force exiting on nick conflicts. xmppipe could generate a unique resource
(e.g., xmppipe-<pid>) but it prevents accidentally having two instances
running in a room.
10 years ago
Michael Santos 849507ad5d mucxxx -> muc_xxx; ERR -> XMPPIPE_ERR 10 years ago
Michael Santos 3d79e9fda8 Forward stdin over XMPP 10 years ago