xmpp_conn_set_flags() and xmpp_conn_get_flags() unify interface of
connection configuration.
This interface allows compile-time check of supported features or even
run-time check. Therefore, applications can be built with older
libstrophe which doesn't support some optional flags.
* Exit from tls_start() on fatal errors. If SSL_connect() fails and
returns -1 this leads to endless loop in case of fatal error.
* Don't set writefds on SSL_ERROR_WANT_READ. Otherwise, this makes
select(2) exit immediately what leads to CPU usage.
* Clear conn->secured and conn->tls_failed. These values could be
saved after re-connect.
* conn is not secured if conn->tls is NULL. This condition handles
disconnected connections.
sha1.c contains symbols that overlap with libcrypto. This patch
fixes linking with libstrophe as static library.
Prefix crypto_ will help to group other crypto API in the future.
This pseudo-random number generator solves problem with
platform-independent generation of randomized nonces.
Current implementation uses weak entropy, especially when
kernel.randomize_va_space = 0. But it can be improved by
adding new sources to xmpp_rand_reseed().
New internal API introduced:
xmpp_rand_new
xmpp_rand_free
xmpp_rand
xmpp_rand_bytes
xmpp_rand_nonce
The use of 0xff as a separator for libexpat only works on arch where
char is defined as an unsigned char. This is an unportable behaviour.
Before this patch this is what I experienced:
xmpp DEBUG sock_connect to im.bouledef.eu:5222 returned 3
xmpp DEBUG attempting to connect to im.bouledef.eu
xmpp DEBUG connection successful
conn DEBUG SENT: <?xml version="1.0"?><stream:stream to="bouledef.eu" xml:lang="en" version="1.0" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams">
conn ERROR Server did not open valid stream.
xmpp DEBUG Closing socket.
DEBUG: disconnected
event DEBUG Stopping event loop.
xmpp DEBUG RECV: <http://etherx.jabber.org/streamsÿfeatures><urn:ietf:params:xml:ns:xmpp-tlsÿstarttls><urn:ietf:params:xml:ns:xmpp-tlsÿrequired/></urn:ietf:params:xml:ns:xmpp-tlsÿstarttls></http://etherx.jabber.org/streamsÿfeatures>
event DEBUG Event loop completed.
name = http://etherx.jabber.org/streamsÿstream
Passing an array as a parameter to a function in C doesn't work, they decay
into pointer. Defining them is pointless and error prone, so just
declare a pointer.
On Win32 at least, select() will immediately fail with an error if
there are no file descriptors to wait for (max == 0). In the simple case
of a single XMPP session and an event loop that runs only while the
connection is open, this isn't a problem, but doesn't work for more
complex scenarios.
Add some handling so that if xmpp_run_once is called and there are no
active connections, simply sleep for duration of the timeout and
return.