mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-30 16:34:16 +00:00
Perform ip string validation inside setWebUiAuthSubnetWhitelist
This commit is contained in:
parent
98a2dedb32
commit
d184bd8c82
@ -487,10 +487,18 @@ QList<Utils::Net::Subnet> Preferences::getWebUiAuthSubnetWhitelist() const
|
|||||||
return subnets;
|
return subnets;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preferences::setWebUiAuthSubnetWhitelist(const QList<Utils::Net::Subnet> &subnets)
|
void Preferences::setWebUiAuthSubnetWhitelist(const QStringList &subnets)
|
||||||
{
|
{
|
||||||
|
QList<Utils::Net::Subnet> filteredSubnets;
|
||||||
|
foreach (QString subnetString, subnets) {
|
||||||
|
bool ok = false;
|
||||||
|
const Utils::Net::Subnet subnet = Utils::Net::parseSubnet(subnetString.trimmed(), &ok);
|
||||||
|
if (ok)
|
||||||
|
filteredSubnets.append(subnet);
|
||||||
|
}
|
||||||
|
|
||||||
QStringList subnetsStringList;
|
QStringList subnetsStringList;
|
||||||
for (const Utils::Net::Subnet &subnet : subnets)
|
for (const Utils::Net::Subnet &subnet : filteredSubnets)
|
||||||
subnetsStringList.append(Utils::Net::subnetToString(subnet));
|
subnetsStringList.append(Utils::Net::subnetToString(subnet));
|
||||||
|
|
||||||
setValue("Preferences/WebUI/AuthSubnetWhitelist", subnetsStringList);
|
setValue("Preferences/WebUI/AuthSubnetWhitelist", subnetsStringList);
|
||||||
|
@ -191,7 +191,7 @@ public:
|
|||||||
bool isWebUiAuthSubnetWhitelistEnabled() const;
|
bool isWebUiAuthSubnetWhitelistEnabled() const;
|
||||||
void setWebUiAuthSubnetWhitelistEnabled(bool enabled);
|
void setWebUiAuthSubnetWhitelistEnabled(bool enabled);
|
||||||
QList<Utils::Net::Subnet> getWebUiAuthSubnetWhitelist() const;
|
QList<Utils::Net::Subnet> getWebUiAuthSubnetWhitelist() const;
|
||||||
void setWebUiAuthSubnetWhitelist(const QList<Utils::Net::Subnet> &subnets);
|
void setWebUiAuthSubnetWhitelist(const QStringList &subnets);
|
||||||
QString getWebUiUsername() const;
|
QString getWebUiUsername() const;
|
||||||
void setWebUiUsername(const QString &username);
|
void setWebUiUsername(const QString &username);
|
||||||
QString getWebUiPassword() const;
|
QString getWebUiPassword() const;
|
||||||
|
@ -68,12 +68,10 @@ void IPSubnetWhitelistOptionsDialog::on_buttonBox_accepted()
|
|||||||
{
|
{
|
||||||
if (m_modified) {
|
if (m_modified) {
|
||||||
// save to session
|
// save to session
|
||||||
QList<Utils::Net::Subnet> subnets;
|
QStringList subnets;
|
||||||
// Operate on the m_sortFilter to grab the strings in sorted order
|
// Operate on the m_sortFilter to grab the strings in sorted order
|
||||||
for (int i = 0; i < m_sortFilter->rowCount(); ++i) {
|
for (int i = 0; i < m_sortFilter->rowCount(); ++i)
|
||||||
const QString subnet = m_sortFilter->index(i, 0).data().toString();
|
subnets.append(m_sortFilter->index(i, 0).data().toString());
|
||||||
subnets.append(QHostAddress::parseSubnet(subnet));
|
|
||||||
}
|
|
||||||
Preferences::instance()->setWebUiAuthSubnetWhitelist(subnets);
|
Preferences::instance()->setWebUiAuthSubnetWhitelist(subnets);
|
||||||
QDialog::accept();
|
QDialog::accept();
|
||||||
}
|
}
|
||||||
|
@ -437,16 +437,8 @@ void prefjson::setPreferences(const QString& json)
|
|||||||
if (m.contains("bypass_auth_subnet_whitelist_enabled"))
|
if (m.contains("bypass_auth_subnet_whitelist_enabled"))
|
||||||
pref->setWebUiAuthSubnetWhitelistEnabled(m["bypass_auth_subnet_whitelist_enabled"].toBool());
|
pref->setWebUiAuthSubnetWhitelistEnabled(m["bypass_auth_subnet_whitelist_enabled"].toBool());
|
||||||
if (m.contains("bypass_auth_subnet_whitelist")) {
|
if (m.contains("bypass_auth_subnet_whitelist")) {
|
||||||
QList<Utils::Net::Subnet> subnets;
|
// recognize new lines and commas as delimiters
|
||||||
// recognize new line and comma as delimiters
|
pref->setWebUiAuthSubnetWhitelist(m["bypass_auth_subnet_whitelist"].toString().split(QRegularExpression("\n|,"), QString::SkipEmptyParts));
|
||||||
foreach (QString subnetString, m["bypass_auth_subnet_whitelist"].toString().split(QRegularExpression("\n|,"), QString::SkipEmptyParts)) {
|
|
||||||
bool ok = false;
|
|
||||||
const Utils::Net::Subnet subnet = Utils::Net::parseSubnet(subnetString.trimmed(), &ok);
|
|
||||||
if (ok)
|
|
||||||
subnets.append(subnet);
|
|
||||||
}
|
|
||||||
|
|
||||||
pref->setWebUiAuthSubnetWhitelist(subnets);
|
|
||||||
}
|
}
|
||||||
// Update my dynamic domain name
|
// Update my dynamic domain name
|
||||||
if (m.contains("dyndns_enabled"))
|
if (m.contains("dyndns_enabled"))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user