summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-07-29 09:47:23 (GMT)
committerTobias Markmann <tm@ayena.de>2016-11-28 10:35:05 (GMT)
commit2039930eadd4756068a8a60c8340d9908a7136d3 (patch)
treed8aca4bf98a2bb6e3b819305b1f87af3117f4910 /Swiften/Client/ClientOptions.h
parent2f90eb7409df91a80c60b189242ac0c1de313910 (diff)
downloadswift-2039930eadd4756068a8a60c8340d9908a7136d3.zip
swift-2039930eadd4756068a8a60c8340d9908a7136d3.tar.bz2
Correctly handle server initiated closing of stream
If a server closes the XMPP stream, it sends a </stream:stream> tag. The client is supposed to respond with the same tag and then both parties can close the TLS/TCP socket. Previously Swift(-en) would simply ignore </stream:stream> tag if it was not directly followed by a shutdown of the TCP connection. In addition there is now a timeout timer started as soon as Swiften or the server initiates a shutdown. It will close the socket and cleanup the ClientSession if the server does not respond in time or the network is faulty. Refactored some code in ClientSession in the process. Moved ClientSession::State to a C++11 strongly typed enum class. This also fixes issues where duplicated </stream:stream> tags would be send by Swift. Test-Information: Tested against Prosody ba782a093b14 and M-Link 16.3v6-0, which provide ad-hoc commands to end a user session. Previously this was ignored by Swift. Now it correctly responds to the server, detects it as a disconnect and tries to reconnect afterwards. Added unit test for the case where the server closes the session stream. Change-Id: I59dfde3aa6b50dc117f340e5db6b9e58b54b3c60
Diffstat (limited to 'Swiften/Client/ClientOptions.h')
-rw-r--r--Swiften/Client/ClientOptions.h54
1 files changed, 23 insertions, 31 deletions
diff --git a/Swiften/Client/ClientOptions.h b/Swiften/Client/ClientOptions.h
index 3a93197..1a337b6 100644
--- a/Swiften/Client/ClientOptions.h
+++ b/Swiften/Client/ClientOptions.h
@@ -30,21 +30,7 @@ namespace Swift {
HTTPConnectProxy
};
- ClientOptions() :
- useStreamCompression(true),
- useTLS(UseTLSWhenAvailable),
- allowPLAINWithoutTLS(false),
- useStreamResumption(false),
- forgetPassword(false),
- useAcks(true),
- singleSignOn(false),
- manualHostname(""),
- manualPort(-1),
- proxyType(SystemConfiguredProxy),
- manualProxyHostname(""),
- manualProxyPort(-1),
- boshHTTPConnectProxyAuthID(""),
- boshHTTPConnectProxyAuthPassword("") {
+ ClientOptions() {
}
/**
@@ -52,14 +38,14 @@ namespace Swift {
*
* Default: true
*/
- bool useStreamCompression;
+ bool useStreamCompression = true;
/**
* Sets whether TLS encryption should be used.
*
* Default: UseTLSWhenAvailable
*/
- UseTLS useTLS;
+ UseTLS useTLS = UseTLSWhenAvailable;
/**
* Sets whether plaintext authentication is
@@ -67,14 +53,14 @@ namespace Swift {
*
* Default: false
*/
- bool allowPLAINWithoutTLS;
+ bool allowPLAINWithoutTLS = false;
/**
* Use XEP-196 stream resumption when available.
*
* Default: false
*/
- bool useStreamResumption;
+ bool useStreamResumption = false;
/**
* Forget the password once it's used.
@@ -84,69 +70,69 @@ namespace Swift {
*
* Default: false
*/
- bool forgetPassword;
+ bool forgetPassword = false;
/**
* Use XEP-0198 acks in the stream when available.
* Default: true
*/
- bool useAcks;
+ bool useAcks = true;
/**
* Use Single Sign On.
* Default: false
*/
- bool singleSignOn;
+ bool singleSignOn = false;
/**
* The hostname to connect to.
* Leave this empty for standard XMPP connection, based on the JID domain.
*/
- std::string manualHostname;
+ std::string manualHostname = "";
/**
* The port to connect to.
* Leave this to -1 to use the port discovered by SRV lookups, and 5222 as a
* fallback.
*/
- int manualPort;
+ int manualPort = -1;
/**
* The type of proxy to use for connecting to the XMPP
* server.
*/
- ProxyType proxyType;
+ ProxyType proxyType = SystemConfiguredProxy;
/**
* Override the system-configured proxy hostname.
*/
- std::string manualProxyHostname;
+ std::string manualProxyHostname = "";
/**
* Override the system-configured proxy port.
*/
- int manualProxyPort;
+ int manualProxyPort = -1;
/**
* If non-empty, use BOSH instead of direct TCP, with the given URL.
* Default: empty (no BOSH)
*/
- URL boshURL;
+ URL boshURL = URL();
/**
* If non-empty, BOSH connections will try to connect over this HTTP CONNECT
* proxy instead of directly.
* Default: empty (no proxy)
*/
- URL boshHTTPConnectProxyURL;
+ URL boshHTTPConnectProxyURL = URL();
/**
* If this and matching Password are non-empty, BOSH connections over
* HTTP CONNECT proxies will use these credentials for proxy access.
* Default: empty (no authentication needed by the proxy)
*/
- SafeString boshHTTPConnectProxyAuthID;
- SafeString boshHTTPConnectProxyAuthPassword;
+ SafeString boshHTTPConnectProxyAuthID = SafeString("");
+ SafeString boshHTTPConnectProxyAuthPassword = SafeString("");
/**
* This can be initialized with a custom HTTPTrafficFilter, which allows HTTP CONNECT
@@ -158,5 +144,11 @@ namespace Swift {
* Options passed to the TLS stack
*/
TLSOptions tlsOptions;
+
+ /**
+ * Session shutdown timeout in milliseconds. This is the maximum time Swiften
+ * waits from a session close to the socket close.
+ */
+ int sessionShutdownTimeoutInMilliseconds = 10000;
};
}