mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-14 09:13:08 -07: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
2 changed files with 15 additions and 9 deletions
|
@ -53,7 +53,6 @@
|
|||
#include "base/utils/bytearray.h"
|
||||
#include "base/utils/fs.h"
|
||||
#include "base/utils/misc.h"
|
||||
#include "base/utils/net.h"
|
||||
#include "base/utils/random.h"
|
||||
#include "base/utils/string.h"
|
||||
#include "api/apierror.h"
|
||||
|
@ -426,9 +425,6 @@ void WebApplication::configure()
|
|||
{
|
||||
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(
|
||||
!pref->isAltWebUiEnabled() ? WWW_FOLDER : pref->getWebUiRootFolder());
|
||||
if (rootFolder != m_rootFolder) {
|
||||
|
@ -442,6 +438,13 @@ void WebApplication::configure()
|
|||
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_isCSRFProtectionEnabled = pref->isWebUiCSRFProtectionEnabled();
|
||||
m_isHttpsEnabled = pref->isWebUiHttpsEnabled();
|
||||
|
@ -619,11 +622,9 @@ QString WebApplication::generateSid() const
|
|||
|
||||
bool WebApplication::isAuthNeeded()
|
||||
{
|
||||
qDebug("Checking auth rules against client address %s", qPrintable(m_env.clientAddress.toString()));
|
||||
const Preferences *pref = Preferences::instance();
|
||||
if (!pref->isWebUiLocalAuthEnabled() && Utils::Net::isLoopbackAddress(m_env.clientAddress))
|
||||
if (!m_isLocalAuthEnabled && Utils::Net::isLoopbackAddress(m_env.clientAddress))
|
||||
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 true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue