mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-13 00:07:54 +00:00
Cache more preference values
These values from Preference class are frequently used. Also group related variables together.
This commit is contained in:
parent
de8050701d
commit
e04aae686f
@ -53,7 +53,6 @@
|
|||||||
#include "base/utils/bytearray.h"
|
#include "base/utils/bytearray.h"
|
||||||
#include "base/utils/fs.h"
|
#include "base/utils/fs.h"
|
||||||
#include "base/utils/misc.h"
|
#include "base/utils/misc.h"
|
||||||
#include "base/utils/net.h"
|
|
||||||
#include "base/utils/random.h"
|
#include "base/utils/random.h"
|
||||||
#include "base/utils/string.h"
|
#include "base/utils/string.h"
|
||||||
#include "api/apierror.h"
|
#include "api/apierror.h"
|
||||||
@ -426,9 +425,6 @@ void WebApplication::configure()
|
|||||||
{
|
{
|
||||||
const auto pref = Preferences::instance();
|
const auto pref = Preferences::instance();
|
||||||
|
|
||||||
m_domainList = pref->getServerDomains().split(';', QString::SkipEmptyParts);
|
|
||||||
std::for_each(m_domainList.begin(), m_domainList.end(), [](QString &entry) { entry = entry.trimmed(); });
|
|
||||||
|
|
||||||
const QString rootFolder = Utils::Fs::expandPathAbs(
|
const QString rootFolder = Utils::Fs::expandPathAbs(
|
||||||
!pref->isAltWebUiEnabled() ? WWW_FOLDER : pref->getWebUiRootFolder());
|
!pref->isAltWebUiEnabled() ? WWW_FOLDER : pref->getWebUiRootFolder());
|
||||||
if (rootFolder != m_rootFolder) {
|
if (rootFolder != m_rootFolder) {
|
||||||
@ -442,6 +438,13 @@ void WebApplication::configure()
|
|||||||
m_translatedFiles.clear();
|
m_translatedFiles.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_isLocalAuthEnabled = pref->isWebUiLocalAuthEnabled();
|
||||||
|
m_isAuthSubnetWhitelistEnabled = pref->isWebUiAuthSubnetWhitelistEnabled();
|
||||||
|
m_authSubnetWhitelist = pref->getWebUiAuthSubnetWhitelist();
|
||||||
|
|
||||||
|
m_domainList = pref->getServerDomains().split(';', QString::SkipEmptyParts);
|
||||||
|
std::for_each(m_domainList.begin(), m_domainList.end(), [](QString &entry) { entry = entry.trimmed(); });
|
||||||
|
|
||||||
m_isClickjackingProtectionEnabled = pref->isWebUiClickjackingProtectionEnabled();
|
m_isClickjackingProtectionEnabled = pref->isWebUiClickjackingProtectionEnabled();
|
||||||
m_isCSRFProtectionEnabled = pref->isWebUiCSRFProtectionEnabled();
|
m_isCSRFProtectionEnabled = pref->isWebUiCSRFProtectionEnabled();
|
||||||
m_isHttpsEnabled = pref->isWebUiHttpsEnabled();
|
m_isHttpsEnabled = pref->isWebUiHttpsEnabled();
|
||||||
@ -619,11 +622,9 @@ QString WebApplication::generateSid() const
|
|||||||
|
|
||||||
bool WebApplication::isAuthNeeded()
|
bool WebApplication::isAuthNeeded()
|
||||||
{
|
{
|
||||||
qDebug("Checking auth rules against client address %s", qPrintable(m_env.clientAddress.toString()));
|
if (!m_isLocalAuthEnabled && Utils::Net::isLoopbackAddress(m_env.clientAddress))
|
||||||
const Preferences *pref = Preferences::instance();
|
|
||||||
if (!pref->isWebUiLocalAuthEnabled() && Utils::Net::isLoopbackAddress(m_env.clientAddress))
|
|
||||||
return false;
|
return false;
|
||||||
if (pref->isWebUiAuthSubnetWhitelistEnabled() && Utils::Net::isIPInRange(m_env.clientAddress, pref->getWebUiAuthSubnetWhitelist()))
|
if (m_isAuthSubnetWhitelistEnabled && Utils::Net::isIPInRange(m_env.clientAddress, m_authSubnetWhitelist))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
#include "base/http/irequesthandler.h"
|
#include "base/http/irequesthandler.h"
|
||||||
#include "base/http/responsebuilder.h"
|
#include "base/http/responsebuilder.h"
|
||||||
#include "base/http/types.h"
|
#include "base/http/types.h"
|
||||||
|
#include "base/utils/net.h"
|
||||||
#include "base/utils/version.h"
|
#include "base/utils/version.h"
|
||||||
|
|
||||||
constexpr Utils::Version<int, 3, 2> API_VERSION {2, 0, 1};
|
constexpr Utils::Version<int, 3, 2> API_VERSION {2, 0, 1};
|
||||||
@ -133,7 +134,6 @@ private:
|
|||||||
QSet<QString> m_publicAPIs;
|
QSet<QString> m_publicAPIs;
|
||||||
bool m_isAltUIUsed = false;
|
bool m_isAltUIUsed = false;
|
||||||
QString m_rootFolder;
|
QString m_rootFolder;
|
||||||
QStringList m_domainList;
|
|
||||||
|
|
||||||
struct TranslatedFile
|
struct TranslatedFile
|
||||||
{
|
{
|
||||||
@ -143,7 +143,12 @@ private:
|
|||||||
QMap<QString, TranslatedFile> m_translatedFiles;
|
QMap<QString, TranslatedFile> m_translatedFiles;
|
||||||
QString m_currentLocale;
|
QString m_currentLocale;
|
||||||
|
|
||||||
|
bool m_isLocalAuthEnabled;
|
||||||
|
bool m_isAuthSubnetWhitelistEnabled;
|
||||||
|
QList<Utils::Net::Subnet> m_authSubnetWhitelist;
|
||||||
|
|
||||||
// security related
|
// security related
|
||||||
|
QStringList m_domainList;
|
||||||
bool m_isClickjackingProtectionEnabled;
|
bool m_isClickjackingProtectionEnabled;
|
||||||
bool m_isCSRFProtectionEnabled;
|
bool m_isCSRFProtectionEnabled;
|
||||||
bool m_isHttpsEnabled;
|
bool m_isHttpsEnabled;
|
||||||
|
Loading…
Reference in New Issue
Block a user