Skip to content

Commit

Permalink
Remove 'loopback address detection' helper function
Browse files Browse the repository at this point in the history
It is not needed since `QHostAddress::isLoopback()` can do the job.
PR #21259.
  • Loading branch information
Chocobo1 authored Aug 31, 2024
1 parent 72feee6 commit fc82abe
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 9 deletions.
7 changes: 0 additions & 7 deletions src/base/utils/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,6 @@ namespace Utils
return subnet;
}

bool isLoopbackAddress(const QHostAddress &addr)
{
return (addr == QHostAddress::LocalHost)
|| (addr == QHostAddress::LocalHostIPv6)
|| (addr == QHostAddress(u"::ffff:127.0.0.1"_s));
}

bool isIPInSubnets(const QHostAddress &addr, const QList<Subnet> &subnets)
{
QHostAddress protocolEquivalentAddress;
Expand Down
1 change: 0 additions & 1 deletion src/base/utils/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ namespace Utils::Net

bool isValidIP(const QString &ip);
std::optional<Subnet> parseSubnet(const QString &subnetStr);
bool isLoopbackAddress(const QHostAddress &addr);
bool isIPInSubnets(const QHostAddress &addr, const QList<Subnet> &subnets);
QString subnetToString(const Subnet &subnet);
QHostAddress canonicalIPv6Addr(const QHostAddress &addr);
Expand Down
2 changes: 1 addition & 1 deletion src/webui/webapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ QString WebApplication::generateSid() const

bool WebApplication::isAuthNeeded()
{
if (!m_isLocalAuthEnabled && Utils::Net::isLoopbackAddress(m_clientAddress))
if (!m_isLocalAuthEnabled && m_clientAddress.isLoopback())
return false;
if (m_isAuthSubnetWhitelistEnabled && Utils::Net::isIPInSubnets(m_clientAddress, m_authSubnetWhitelist))
return false;
Expand Down

0 comments on commit fc82abe

Please sign in to comment.