Skip to content

Commit

Permalink
Inroduce a new option for tls srv (On by default)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ri0n committed Jun 20, 2024
1 parent 372e7a3 commit 0534923
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/xmpp/xmpp-core/connector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,17 +149,18 @@ AdvancedConnector::Proxy::operator QNetworkProxy()
// AdvancedConnector
//----------------------------------------------------------------------------
typedef enum { Idle, Connecting, Connected } Mode;
typedef enum { Force, Probe, Never } LegacySSL;
typedef enum : char { Force, Probe, Never } LegacySSL;

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

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

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

void AdvancedConnector::setOptTlsSrv(bool value) { d->opt_srvtls = value; }

void AdvancedConnector::connectToServer(const QString &server)
{
#ifdef XMPP_DEBUG
Expand Down Expand Up @@ -335,13 +338,15 @@ void AdvancedConnector::connectToServer(const QString &server)
});
connect(s, SIGNAL(error(int)), SLOT(bs_error(int)));

QStringList services = { XMPP_CLIENT_SRV };
if (!d->opt_host.isEmpty()) { /* if custom host:port */
d->host = d->opt_host;
d->port = d->opt_port;
s->connectToHost(d->host, quint16(d->port));
return;
} else if (d->opt_ssl != Never) { /* if ssl forced or should be probed */
}

QStringList services = { XMPP_CLIENT_SRV };
if (d->opt_ssl == Never && d->opt_srvtls) { /* if ssl forced or should be probed */
d->port = XMPP_LEGACY_PORT;
services << XMPP_CLIENT_TLS_SRV;
}
Expand Down
1 change: 1 addition & 0 deletions src/xmpp/xmpp-core/xmpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ class AdvancedConnector : public Connector {
void setProxy(const Proxy &proxy);
void setOptProbe(bool);
void setOptSSL(bool);
void setOptTlsSrv(bool);

void changePollInterval(int secs);

Expand Down

0 comments on commit 0534923

Please sign in to comment.