Allow enabling insecure TLS connections for testing
This commit is contained in:
parent
ef111fb0aa
commit
f1762a4620
|
@ -14,7 +14,7 @@ set(META_VERSION_MAJOR 1)
|
|||
set(META_VERSION_MINOR 5)
|
||||
set(META_VERSION_PATCH 5)
|
||||
set(META_RELEASE_DATE "2024-06-04")
|
||||
set(META_SOVERSION 15)
|
||||
set(META_SOVERSION 16)
|
||||
set(META_ADD_DEFAULT_CPP_UNIT_TEST_APPLICATION ON)
|
||||
set(NETWORK_INFORMATION_SUPPORT ON)
|
||||
|
||||
|
|
|
@ -119,6 +119,7 @@ SyncthingConnection::SyncthingConnection(
|
|||
#ifdef SYNCTHINGCONNECTION_SUPPORT_METERED
|
||||
, m_handlingMeteredConnectionInitialized(false)
|
||||
#endif
|
||||
, m_insecure(false)
|
||||
{
|
||||
m_trafficPollTimer.setInterval(SyncthingConnectionSettings::defaultTrafficPollInterval);
|
||||
m_trafficPollTimer.setTimerType(Qt::VeryCoarseTimer);
|
||||
|
|
|
@ -160,6 +160,7 @@ class LIB_SYNCTHING_CONNECTOR_EXPORT SyncthingConnection : public QObject {
|
|||
Q_PROPERTY(QJsonObject rawConfig READ rawConfig NOTIFY newConfig)
|
||||
Q_PROPERTY(bool useDeprecatedRoutes READ isUsingDeprecatedRoutes WRITE setUseDeprecatedRoutes)
|
||||
Q_PROPERTY(bool pausingOnMeteredConnection READ isPausingOnMeteredConnection WRITE setPausingOnMeteredConnection)
|
||||
Q_PROPERTY(bool insecure READ isInsecure WRITE setInsecure)
|
||||
|
||||
public:
|
||||
explicit SyncthingConnection(const QString &syncthingUrl = QStringLiteral("http://localhost:8080"), const QByteArray &apiKey = QByteArray(),
|
||||
|
@ -220,6 +221,8 @@ public:
|
|||
void setLongPollingTimeout(int longPollingTimeout);
|
||||
bool isPausingOnMeteredConnection() const;
|
||||
void setPausingOnMeteredConnection(bool pausingOnMeteredConnection);
|
||||
bool isInsecure() const;
|
||||
void setInsecure(bool insecure);
|
||||
|
||||
// getter for information retrieved from Syncthing
|
||||
const QString &configDir() const;
|
||||
|
@ -527,6 +530,7 @@ private:
|
|||
#ifdef SYNCTHINGCONNECTION_SUPPORT_METERED
|
||||
bool m_handlingMeteredConnectionInitialized;
|
||||
#endif
|
||||
bool m_insecure;
|
||||
};
|
||||
|
||||
/*!
|
||||
|
@ -870,6 +874,23 @@ inline bool SyncthingConnection::isPausingOnMeteredConnection() const
|
|||
return m_pausingOnMeteredConnection;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Returns whether any certificate errors will be ignored.
|
||||
* \remarks This will only ever be the case when this has been configured via setInsecure().
|
||||
*/
|
||||
inline bool SyncthingConnection::isInsecure() const
|
||||
{
|
||||
return m_insecure;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Sets whether any certificate errors will be ignored.
|
||||
*/
|
||||
inline void SyncthingConnection::setInsecure(bool insecure)
|
||||
{
|
||||
m_insecure = insecure;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Returns what information is considered to compute the overall status returned by status().
|
||||
*/
|
||||
|
|
|
@ -217,7 +217,7 @@ void SyncthingConnection::handleSslErrors(const QList<QSslError> &errors)
|
|||
}
|
||||
|
||||
// proceed if all errors are expected
|
||||
if (!hasUnexpectedErrors) {
|
||||
if (!hasUnexpectedErrors || m_insecure) {
|
||||
reply->ignoreSslErrors();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -437,6 +437,7 @@ bool restore()
|
|||
// restore developer settings from environment variables
|
||||
setVarFromEnv(v.fakeFirstLaunch, PROJECT_VARNAME_UPPER "_FAKE_FIRST_LAUNCH");
|
||||
setVarFromEnv(v.enableWipFeatures, PROJECT_VARNAME_UPPER "_ENABLE_WIP_FEATURES");
|
||||
setVarFromEnv(v.connection.insecure, PROJECT_VARNAME_UPPER "_INSECURE");
|
||||
|
||||
return v.error.isEmpty();
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ namespace Settings {
|
|||
struct SYNCTHINGWIDGETS_EXPORT Connection {
|
||||
Data::SyncthingConnectionSettings primary;
|
||||
std::vector<Data::SyncthingConnectionSettings> secondary;
|
||||
bool insecure = false; // not persistent, for testing purposes only
|
||||
|
||||
void addConfigFromWizard(const Data::SyncthingConfig &config);
|
||||
};
|
||||
|
|
|
@ -166,6 +166,8 @@ static int runApplication(int argc, const char *const *argv)
|
|||
assumeFirstLaunchArg.setFlags(Argument::Flags::Deprecated, true); // hide as it is debug-only
|
||||
auto wipArg = ConfigValueArgument("wip", '\0', "enables WIP features");
|
||||
wipArg.setFlags(Argument::Flags::Deprecated, true); // hide as it is debug-only
|
||||
auto insecureArg = ConfigValueArgument("insecure", '\0', "allow any self-signed certificate");
|
||||
insecureArg.setFlags(Argument::Flags::Deprecated, true); // hide as it is only for development
|
||||
auto waitForTrayArg = ConfigValueArgument("wait", '\0',
|
||||
"wait until the system tray becomes available instead of showing an error message if the system tray is not available on start-up");
|
||||
auto connectionArg = ConfigValueArgument("connection", '\0', "specifies one or more connection configurations to be used", { "config name" });
|
||||
|
@ -179,7 +181,7 @@ static int runApplication(int argc, const char *const *argv)
|
|||
quitArg.setFlags(Argument::Flags::Deprecated, true); // hide as only used internally for --replace
|
||||
auto &widgetsGuiArg = qtConfigArgs.qtWidgetsGuiArg();
|
||||
widgetsGuiArg.addSubArguments({ &windowedArg, &showWebUiArg, &triggerArg, &waitForTrayArg, &connectionArg, &configPathArg, &singleInstanceArg,
|
||||
&newInstanceArg, &replaceArg, &showWizardArg, &assumeFirstLaunchArg, &wipArg });
|
||||
&newInstanceArg, &replaceArg, &showWizardArg, &assumeFirstLaunchArg, &wipArg, &insecureArg });
|
||||
#ifdef SYNCTHINGTRAY_USE_LIBSYNCTHING
|
||||
auto cliArg = OperationArgument("cli", 'c', "runs Syncthing's CLI");
|
||||
auto cliHelp = ConfigValueArgument("help", 'h', "shows help for Syncthing's CLI");
|
||||
|
@ -255,6 +257,9 @@ static int runApplication(int argc, const char *const *argv)
|
|||
if (wipArg.isPresent()) {
|
||||
settings.enableWipFeatures = true;
|
||||
}
|
||||
if (insecureArg.isPresent()) {
|
||||
settings.connection.insecure = true;
|
||||
}
|
||||
LOAD_QT_TRANSLATIONS;
|
||||
if (!settings.error.isEmpty()) {
|
||||
QMessageBox::critical(nullptr, QCoreApplication::applicationName(), settings.error);
|
||||
|
|
|
@ -107,6 +107,9 @@ TrayWidget::TrayWidget(TrayMenu *parent)
|
|||
m_tabTexts << m_ui->tabWidget->tabText(i);
|
||||
}
|
||||
|
||||
// configure connection
|
||||
m_connection.setInsecure(Settings::values().connection.insecure);
|
||||
|
||||
// setup models and views
|
||||
m_ui->dirsTreeView->header()->setSortIndicator(0, Qt::AscendingOrder);
|
||||
m_ui->dirsTreeView->setModel(&m_sortFilterDirModel);
|
||||
|
|
Loading…
Reference in New Issue