Skip to content

Commit 0534923

Browse files
committed
Inroduce a new option for tls srv (On by default)
1 parent 372e7a3 commit 0534923

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/xmpp/xmpp-core/connector.cpp

+12-7
Original file line numberDiff line numberDiff line change
@@ -149,17 +149,18 @@ AdvancedConnector::Proxy::operator QNetworkProxy()
149149
// AdvancedConnector
150150
//----------------------------------------------------------------------------
151151
typedef enum { Idle, Connecting, Connected } Mode;
152-
typedef enum { Force, Probe, Never } LegacySSL;
152+
typedef enum : char { Force, Probe, Never } LegacySSL;
153153

154154
class AdvancedConnector::Private {
155155
public:
156156
ByteStream *bs; //!< Socket to use
157157

158158
/* configuration values / "options" */
159-
QString opt_host; //!< explicit host from config
160-
quint16 opt_port; //!< explicit port from config
161-
LegacySSL opt_ssl; //!< Whether to use legacy SSL support
162-
Proxy proxy; //!< Proxy configuration
159+
QString opt_host; //!< explicit host from config
160+
quint16 opt_port; //!< explicit port from config
161+
LegacySSL opt_ssl = Never; //!< Whether to use legacy SSL support
162+
bool opt_srvtls = true; //!< Whether to lookup tls port from SRV
163+
Proxy proxy; //!< Proxy configuration
163164

164165
/* State tracking values */
165166
Mode mode; //!< Idle, Connecting, Connected
@@ -242,6 +243,8 @@ void AdvancedConnector::setOptSSL(bool b)
242243
d->opt_ssl = (b ? Force : Never);
243244
}
244245

246+
void AdvancedConnector::setOptTlsSrv(bool value) { d->opt_srvtls = value; }
247+
245248
void AdvancedConnector::connectToServer(const QString &server)
246249
{
247250
#ifdef XMPP_DEBUG
@@ -335,13 +338,15 @@ void AdvancedConnector::connectToServer(const QString &server)
335338
});
336339
connect(s, SIGNAL(error(int)), SLOT(bs_error(int)));
337340

338-
QStringList services = { XMPP_CLIENT_SRV };
339341
if (!d->opt_host.isEmpty()) { /* if custom host:port */
340342
d->host = d->opt_host;
341343
d->port = d->opt_port;
342344
s->connectToHost(d->host, quint16(d->port));
343345
return;
344-
} else if (d->opt_ssl != Never) { /* if ssl forced or should be probed */
346+
}
347+
348+
QStringList services = { XMPP_CLIENT_SRV };
349+
if (d->opt_ssl == Never && d->opt_srvtls) { /* if ssl forced or should be probed */
345350
d->port = XMPP_LEGACY_PORT;
346351
services << XMPP_CLIENT_TLS_SRV;
347352
}

src/xmpp/xmpp-core/xmpp.h

+1
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ class AdvancedConnector : public Connector {
135135
void setProxy(const Proxy &proxy);
136136
void setOptProbe(bool);
137137
void setOptSSL(bool);
138+
void setOptTlsSrv(bool);
138139

139140
void changePollInterval(int secs);
140141

0 commit comments

Comments
 (0)