Skip to content

Commit

Permalink
Renamed AccessManager::IsIPAllowed to AccessManager::GetIPAllowed
Browse files Browse the repository at this point in the history
Renamed AccessManager::IsPeerAllowed to AccessManager::GetPeerAllowed
  • Loading branch information
kareldonk committed Aug 16, 2020
1 parent 6aaa822 commit 8520f1a
Show file tree
Hide file tree
Showing 17 changed files with 87 additions and 87 deletions.
16 changes: 8 additions & 8 deletions QuantumGateLib/API/Access.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,19 @@ namespace QuantumGate::API::Access
return m_AccessManager->GetAllIPReputations();
}

Result<bool> Manager::IsIPAllowed(const WChar* ip_str, const CheckType check) const noexcept
Result<bool> Manager::GetIPAllowed(const WChar* ip_str, const CheckType check) const noexcept
{
return m_AccessManager->IsIPAllowed(ip_str, check);
return m_AccessManager->GetIPAllowed(ip_str, check);
}

Result<bool> Manager::IsIPAllowed(const String& ip_str, const CheckType check) const noexcept
Result<bool> Manager::GetIPAllowed(const String& ip_str, const CheckType check) const noexcept
{
return m_AccessManager->IsIPAllowed(ip_str.c_str(), check);
return m_AccessManager->GetIPAllowed(ip_str.c_str(), check);
}

Result<bool> Manager::IsIPAllowed(const IPAddress& ip, const CheckType check) const noexcept
Result<bool> Manager::GetIPAllowed(const IPAddress& ip, const CheckType check) const noexcept
{
return m_AccessManager->IsIPAllowed(ip, check);
return m_AccessManager->GetIPAllowed(ip, check);
}

Result<> Manager::AddPeer(PeerSettings&& pas) noexcept
Expand All @@ -143,9 +143,9 @@ namespace QuantumGate::API::Access
m_AccessManager->RemoveAllPeers();
}

Result<bool> Manager::IsPeerAllowed(const PeerUUID& puuid) const noexcept
Result<bool> Manager::GetPeerAllowed(const PeerUUID& puuid) const noexcept
{
return m_AccessManager->IsPeerAllowed(puuid);
return m_AccessManager->GetPeerAllowed(puuid);
}

void Manager::SetPeerAccessDefault(const PeerAccessDefault pad) noexcept
Expand Down
8 changes: 4 additions & 4 deletions QuantumGateLib/API/Access.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,16 @@ namespace QuantumGate::API::Access
void ResetAllIPReputations() noexcept;
Result<Vector<IPReputation>> GetAllIPReputations() const noexcept;

Result<bool> IsIPAllowed(const WChar* ip_str, const CheckType check) const noexcept;
Result<bool> IsIPAllowed(const String& ip_str, const CheckType check) const noexcept;
Result<bool> IsIPAllowed(const IPAddress& ip, const CheckType check) const noexcept;
Result<bool> GetIPAllowed(const WChar* ip_str, const CheckType check) const noexcept;
Result<bool> GetIPAllowed(const String& ip_str, const CheckType check) const noexcept;
Result<bool> GetIPAllowed(const IPAddress& ip, const CheckType check) const noexcept;

Result<> AddPeer(PeerSettings&& pas) noexcept;
Result<> UpdatePeer(PeerSettings&& pas) noexcept;
Result<> RemovePeer(const PeerUUID& puuid) noexcept;
void RemoveAllPeers() noexcept;

Result<bool> IsPeerAllowed(const PeerUUID& puuid) const noexcept;
Result<bool> GetPeerAllowed(const PeerUUID& puuid) const noexcept;

void SetPeerAccessDefault(const PeerAccessDefault pad) noexcept;
[[nodiscard]] PeerAccessDefault GetPeerAccessDefault() const noexcept;
Expand Down
20 changes: 10 additions & 10 deletions QuantumGateLib/Core/Access/AccessManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,24 +221,24 @@ namespace QuantumGate::Implementation::Core::Access
return m_SubnetLimits.WithSharedLock()->GetLimits();
}

Result<bool> Manager::IsIPAllowed(const WChar* ip_str, const CheckType check) noexcept
Result<bool> Manager::GetIPAllowed(const WChar* ip_str, const CheckType check) noexcept
{
IPAddress ipaddr;
if (IPAddress::TryParse(ip_str, ipaddr))
{
return IsIPAllowed(ipaddr, check);
return GetIPAllowed(ipaddr, check);
}

return ResultCode::AddressInvalid;
}

Result<bool> Manager::IsIPAllowed(const IPAddress& ip, const CheckType check) noexcept
Result<bool> Manager::GetIPAllowed(const IPAddress& ip, const CheckType check) noexcept
{
switch (check)
{
case CheckType::IPFilters:
{
return m_IPFilters.WithSharedLock()->IsAllowed(ip);
return m_IPFilters.WithSharedLock()->GetAllowed(ip);
}
case CheckType::IPReputations:
{
Expand All @@ -250,7 +250,7 @@ namespace QuantumGate::Implementation::Core::Access
}
case CheckType::All:
{
if (const auto result = m_IPFilters.WithSharedLock()->IsAllowed(ip); result)
if (const auto result = m_IPFilters.WithSharedLock()->GetAllowed(ip); result)
{
if (*result &&
m_IPAccessControl.WithUniqueLock()->HasAcceptableReputation(ip) &&
Expand All @@ -273,13 +273,13 @@ namespace QuantumGate::Implementation::Core::Access
return false;
}

Result<bool> Manager::IsIPConnectionAllowed(const IPAddress& ip, const CheckType check) noexcept
Result<bool> Manager::GetIPConnectionAllowed(const IPAddress& ip, const CheckType check) noexcept
{
switch (check)
{
case CheckType::IPFilters:
{
return m_IPFilters.WithSharedLock()->IsAllowed(ip);
return m_IPFilters.WithSharedLock()->GetAllowed(ip);
}
case CheckType::IPReputations:
{
Expand All @@ -291,7 +291,7 @@ namespace QuantumGate::Implementation::Core::Access
}
case CheckType::All:
{
if (const auto result = m_IPFilters.WithSharedLock()->IsAllowed(ip); result)
if (const auto result = m_IPFilters.WithSharedLock()->GetAllowed(ip); result)
{
if (*result &&
m_IPAccessControl.WithUniqueLock()->HasAcceptableReputation(ip) &&
Expand Down Expand Up @@ -353,9 +353,9 @@ namespace QuantumGate::Implementation::Core::Access
m_AccessUpdateCallbacks.WithUniqueLock()();
}

Result<bool> Manager::IsPeerAllowed(const PeerUUID& puuid) const noexcept
Result<bool> Manager::GetPeerAllowed(const PeerUUID& puuid) const noexcept
{
return m_PeerAccessControl.WithSharedLock()->IsAllowed(puuid);
return m_PeerAccessControl.WithSharedLock()->GetAllowed(puuid);
}

const ProtectedBuffer* Manager::GetPeerPublicKey(const PeerUUID& puuid) const noexcept
Expand Down
8 changes: 4 additions & 4 deletions QuantumGateLib/Core/Access/AccessManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,17 @@ namespace QuantumGate::Implementation::Core::Access
[[nodiscard]] bool AddIPConnection(const IPAddress& ip) noexcept;
[[nodiscard]] bool RemoveIPConnection(const IPAddress& ip) noexcept;

Result<bool> IsIPAllowed(const WChar* ip_str, const CheckType check) noexcept;
Result<bool> IsIPAllowed(const IPAddress& ip, const CheckType check) noexcept;
Result<bool> GetIPAllowed(const WChar* ip_str, const CheckType check) noexcept;
Result<bool> GetIPAllowed(const IPAddress& ip, const CheckType check) noexcept;

Result<bool> IsIPConnectionAllowed(const IPAddress& ip, const CheckType check) noexcept;
Result<bool> GetIPConnectionAllowed(const IPAddress& ip, const CheckType check) noexcept;

Result<> AddPeer(PeerSettings&& pas) noexcept;
Result<> UpdatePeer(PeerSettings&& pas) noexcept;
Result<> RemovePeer(const PeerUUID& puuid) noexcept;
void RemoveAllPeers() noexcept;

Result<bool> IsPeerAllowed(const PeerUUID& puuid) const noexcept;
Result<bool> GetPeerAllowed(const PeerUUID& puuid) const noexcept;

const ProtectedBuffer* GetPeerPublicKey(const PeerUUID& puuid) const noexcept;

Expand Down
6 changes: 3 additions & 3 deletions QuantumGateLib/Core/Access/IPFilters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,20 +243,20 @@ namespace QuantumGate::Implementation::Core::Access
return Hash::GetNonPersistentHash(ip.GetString() + mask.GetString());
}

Result<bool> IPFilters::IsAllowed(const WChar* ip) const noexcept
Result<bool> IPFilters::GetAllowed(const WChar* ip) const noexcept
{
IPAddress ipaddr;
if (IPAddress::TryParse(ip, ipaddr))
{
return IsAllowed(ipaddr);
return GetAllowed(ipaddr);
}

LogErr(L"Could not check if IP is allowed: unrecognized IP address");

return ResultCode::AddressInvalid;
}

Result<bool> IPFilters::IsAllowed(const IPAddress& ipaddr) const noexcept
Result<bool> IPFilters::GetAllowed(const IPAddress& ipaddr) const noexcept
{
// IP addresses are blocked by default unless they are allowed via a filter in the
// allowed filter ranges. Even if they are allowed via one of the allowed filter
Expand Down
4 changes: 2 additions & 2 deletions QuantumGateLib/Core/Access/IPFilters.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ namespace QuantumGate::Implementation::Core::Access

Result<Vector<IPFilter>> GetFilters() const noexcept;

Result<bool> IsAllowed(const WChar* ip) const noexcept;
Result<bool> IsAllowed(const IPAddress& ipaddr) const noexcept;
Result<bool> GetAllowed(const WChar* ip) const noexcept;
Result<bool> GetAllowed(const IPAddress& ipaddr) const noexcept;

private:
Result<IPFilterID> AddFilterImpl(const IPAddress& ip, const IPAddress& mask,
Expand Down
2 changes: 1 addition & 1 deletion QuantumGateLib/Core/Access/PeerAccessControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ namespace QuantumGate::Implementation::Core::Access
return ResultCode::Failed;
}

Result<bool> PeerAccessControl::IsAllowed(const PeerUUID& puuid) const noexcept
Result<bool> PeerAccessControl::GetAllowed(const PeerUUID& puuid) const noexcept
{
assert(puuid.IsValid());

Expand Down
2 changes: 1 addition & 1 deletion QuantumGateLib/Core/Access/PeerAccessControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace QuantumGate::Implementation::Core::Access
Result<> UpdatePeer(PeerSettings&& pas) noexcept;
Result<> RemovePeer(const PeerUUID& puuid) noexcept;

Result<bool> IsAllowed(const PeerUUID& puuid) const noexcept;
Result<bool> GetAllowed(const PeerUUID& puuid) const noexcept;

const ProtectedBuffer* GetPublicKey(const PeerUUID& puuid) const noexcept;

Expand Down
2 changes: 1 addition & 1 deletion QuantumGateLib/Core/ListenerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ namespace QuantumGate::Implementation::Core::Listener
if (m_AccessManager.AddIPConnectionAttempt(ipaddr))
{
// Check if IP is allowed through filters/limits and if it has acceptible reputation
if (const auto result = m_AccessManager.IsIPConnectionAllowed(ipaddr, Access::CheckType::All); result.Succeeded())
if (const auto result = m_AccessManager.GetIPConnectionAllowed(ipaddr, Access::CheckType::All); result.Succeeded())
{
return *result;
}
Expand Down
4 changes: 2 additions & 2 deletions QuantumGateLib/Core/Peer/Peer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1820,7 +1820,7 @@ namespace QuantumGate::Implementation::Core::Peer
LogDbg(L"Checking access for peer %s", GetPeerName().c_str());

// Check if peer IP is still allowed access
const auto result = GetAccessManager().IsIPAllowed(GetPeerIPAddress(), Access::CheckType::All);
const auto result = GetAccessManager().GetIPAllowed(GetPeerIPAddress(), Access::CheckType::All);
if (!result || !(*result))
{
// Peer IP isn't allowed anymore; disconnect the peer as soon as possible
Expand All @@ -1838,7 +1838,7 @@ namespace QuantumGate::Implementation::Core::Peer
if (status == Status::Ready || status == Status::SessionInit)
{
// Check if peer UUID is still allowed access
const auto result2 = GetAccessManager().IsPeerAllowed(GetPeerUUID());
const auto result2 = GetAccessManager().GetPeerAllowed(GetPeerUUID());
if (!result2 || !(*result2))
{
// Peer UUID isn't allowed anymore; disconnect the peer as soon as possible
Expand Down
4 changes: 2 additions & 2 deletions QuantumGateLib/Core/Peer/PeerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,8 +681,8 @@ namespace QuantumGate::Implementation::Core::Peer
{
auto result_code = ResultCode::Failed;

if (const auto allowed = m_AccessManager.IsIPConnectionAllowed(params.PeerIPEndpoint.GetIPAddress(),
Access::CheckType::All); allowed && *allowed)
if (const auto allowed = m_AccessManager.GetIPConnectionAllowed(params.PeerIPEndpoint.GetIPAddress(),
Access::CheckType::All); allowed && *allowed)
{
auto reused = false;
PeerLUID pluid{ 0 };
Expand Down
2 changes: 1 addition & 1 deletion QuantumGateLib/Core/Peer/PeerMessageProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ namespace QuantumGate::Implementation::Core::Peer
// Should have a peer UUID by now
assert(m_Peer.GetPeerUUID().IsValid());

if (const auto allowed = m_Peer.GetAccessManager().IsPeerAllowed(m_Peer.GetPeerUUID()); allowed && *allowed)
if (const auto allowed = m_Peer.GetAccessManager().GetPeerAllowed(m_Peer.GetPeerUUID()); allowed && *allowed)
{
const auto authenticated = VerifySignature(psig);
if (authenticated || (!authenticated && !m_Peer.GetSettings().Local.RequireAuthentication))
Expand Down
2 changes: 1 addition & 1 deletion QuantumGateLib/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#define VERSION_MAJOR 0
#define VERSION_MINOR 2
#define VERSION_REVISION 5
#define VERSION_BUILD 849
#define VERSION_BUILD 851

#define FILE_VERSION VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION, VERSION_BUILD
#define FILE_VERSION_STR STR(VERSION_MAJOR) "." STR(VERSION_MINOR) "." STR(VERSION_REVISION) "." STR(VERSION_BUILD)
Expand Down
2 changes: 1 addition & 1 deletion Test/Socks5Extender/Socks5Extender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ namespace QuantumGate::Socks5Extender

bool Extender::IsOutgoingIPAllowed(const IPAddress& ip) const noexcept
{
if (const auto result = m_IPFilters.WithSharedLock()->IsAllowed(ip); result.Succeeded())
if (const auto result = m_IPFilters.WithSharedLock()->GetAllowed(ip); result.Succeeded())
{
return *result;
}
Expand Down
2 changes: 1 addition & 1 deletion Test/TestApp/CIPFiltersDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ void CIPFiltersDlg::OnEnChangeTestIp()
void CIPFiltersDlg::OnBnClickedTestButton()
{
auto ip = GetTextValue(IDC_TEST_IP);
const auto result = m_AccessManager->IsIPAllowed((LPCTSTR)ip, QuantumGate::Access::CheckType::IPFilters);
const auto result = m_AccessManager->GetIPAllowed((LPCTSTR)ip, QuantumGate::Access::CheckType::IPFilters);
if (result.Succeeded())
{
if (*result)
Expand Down
Loading

0 comments on commit 8520f1a

Please sign in to comment.