diff --git a/QuantumGateLib/API/Access.cpp b/QuantumGateLib/API/Access.cpp index aef5a184..089b38db 100644 --- a/QuantumGateLib/API/Access.cpp +++ b/QuantumGateLib/API/Access.cpp @@ -108,19 +108,19 @@ namespace QuantumGate::API::Access return m_AccessManager->GetAllIPReputations(); } - Result Manager::IsIPAllowed(const WChar* ip_str, const CheckType check) const noexcept + Result 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 Manager::IsIPAllowed(const String& ip_str, const CheckType check) const noexcept + Result 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 Manager::IsIPAllowed(const IPAddress& ip, const CheckType check) const noexcept + Result 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 @@ -143,9 +143,9 @@ namespace QuantumGate::API::Access m_AccessManager->RemoveAllPeers(); } - Result Manager::IsPeerAllowed(const PeerUUID& puuid) const noexcept + Result Manager::GetPeerAllowed(const PeerUUID& puuid) const noexcept { - return m_AccessManager->IsPeerAllowed(puuid); + return m_AccessManager->GetPeerAllowed(puuid); } void Manager::SetPeerAccessDefault(const PeerAccessDefault pad) noexcept diff --git a/QuantumGateLib/API/Access.h b/QuantumGateLib/API/Access.h index d92f512a..ae432c07 100644 --- a/QuantumGateLib/API/Access.h +++ b/QuantumGateLib/API/Access.h @@ -105,16 +105,16 @@ namespace QuantumGate::API::Access void ResetAllIPReputations() noexcept; Result> GetAllIPReputations() const noexcept; - Result IsIPAllowed(const WChar* ip_str, const CheckType check) const noexcept; - Result IsIPAllowed(const String& ip_str, const CheckType check) const noexcept; - Result IsIPAllowed(const IPAddress& ip, const CheckType check) const noexcept; + Result GetIPAllowed(const WChar* ip_str, const CheckType check) const noexcept; + Result GetIPAllowed(const String& ip_str, const CheckType check) const noexcept; + Result 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 IsPeerAllowed(const PeerUUID& puuid) const noexcept; + Result GetPeerAllowed(const PeerUUID& puuid) const noexcept; void SetPeerAccessDefault(const PeerAccessDefault pad) noexcept; [[nodiscard]] PeerAccessDefault GetPeerAccessDefault() const noexcept; diff --git a/QuantumGateLib/Core/Access/AccessManager.cpp b/QuantumGateLib/Core/Access/AccessManager.cpp index b4ca512d..6674a833 100644 --- a/QuantumGateLib/Core/Access/AccessManager.cpp +++ b/QuantumGateLib/Core/Access/AccessManager.cpp @@ -221,24 +221,24 @@ namespace QuantumGate::Implementation::Core::Access return m_SubnetLimits.WithSharedLock()->GetLimits(); } - Result Manager::IsIPAllowed(const WChar* ip_str, const CheckType check) noexcept + Result 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 Manager::IsIPAllowed(const IPAddress& ip, const CheckType check) noexcept + Result 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: { @@ -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) && @@ -273,13 +273,13 @@ namespace QuantumGate::Implementation::Core::Access return false; } - Result Manager::IsIPConnectionAllowed(const IPAddress& ip, const CheckType check) noexcept + Result 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: { @@ -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) && @@ -353,9 +353,9 @@ namespace QuantumGate::Implementation::Core::Access m_AccessUpdateCallbacks.WithUniqueLock()(); } - Result Manager::IsPeerAllowed(const PeerUUID& puuid) const noexcept + Result 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 diff --git a/QuantumGateLib/Core/Access/AccessManager.h b/QuantumGateLib/Core/Access/AccessManager.h index aa2454d0..b08d5bf4 100644 --- a/QuantumGateLib/Core/Access/AccessManager.h +++ b/QuantumGateLib/Core/Access/AccessManager.h @@ -66,17 +66,17 @@ namespace QuantumGate::Implementation::Core::Access [[nodiscard]] bool AddIPConnection(const IPAddress& ip) noexcept; [[nodiscard]] bool RemoveIPConnection(const IPAddress& ip) noexcept; - Result IsIPAllowed(const WChar* ip_str, const CheckType check) noexcept; - Result IsIPAllowed(const IPAddress& ip, const CheckType check) noexcept; + Result GetIPAllowed(const WChar* ip_str, const CheckType check) noexcept; + Result GetIPAllowed(const IPAddress& ip, const CheckType check) noexcept; - Result IsIPConnectionAllowed(const IPAddress& ip, const CheckType check) noexcept; + Result 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 IsPeerAllowed(const PeerUUID& puuid) const noexcept; + Result GetPeerAllowed(const PeerUUID& puuid) const noexcept; const ProtectedBuffer* GetPeerPublicKey(const PeerUUID& puuid) const noexcept; diff --git a/QuantumGateLib/Core/Access/IPFilters.cpp b/QuantumGateLib/Core/Access/IPFilters.cpp index 19f7f002..2543ab11 100644 --- a/QuantumGateLib/Core/Access/IPFilters.cpp +++ b/QuantumGateLib/Core/Access/IPFilters.cpp @@ -243,12 +243,12 @@ namespace QuantumGate::Implementation::Core::Access return Hash::GetNonPersistentHash(ip.GetString() + mask.GetString()); } - Result IPFilters::IsAllowed(const WChar* ip) const noexcept + Result 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"); @@ -256,7 +256,7 @@ namespace QuantumGate::Implementation::Core::Access return ResultCode::AddressInvalid; } - Result IPFilters::IsAllowed(const IPAddress& ipaddr) const noexcept + Result 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 diff --git a/QuantumGateLib/Core/Access/IPFilters.h b/QuantumGateLib/Core/Access/IPFilters.h index 289c5982..e7172762 100644 --- a/QuantumGateLib/Core/Access/IPFilters.h +++ b/QuantumGateLib/Core/Access/IPFilters.h @@ -51,8 +51,8 @@ namespace QuantumGate::Implementation::Core::Access Result> GetFilters() const noexcept; - Result IsAllowed(const WChar* ip) const noexcept; - Result IsAllowed(const IPAddress& ipaddr) const noexcept; + Result GetAllowed(const WChar* ip) const noexcept; + Result GetAllowed(const IPAddress& ipaddr) const noexcept; private: Result AddFilterImpl(const IPAddress& ip, const IPAddress& mask, diff --git a/QuantumGateLib/Core/Access/PeerAccessControl.cpp b/QuantumGateLib/Core/Access/PeerAccessControl.cpp index c5725298..0808db47 100644 --- a/QuantumGateLib/Core/Access/PeerAccessControl.cpp +++ b/QuantumGateLib/Core/Access/PeerAccessControl.cpp @@ -68,7 +68,7 @@ namespace QuantumGate::Implementation::Core::Access return ResultCode::Failed; } - Result PeerAccessControl::IsAllowed(const PeerUUID& puuid) const noexcept + Result PeerAccessControl::GetAllowed(const PeerUUID& puuid) const noexcept { assert(puuid.IsValid()); diff --git a/QuantumGateLib/Core/Access/PeerAccessControl.h b/QuantumGateLib/Core/Access/PeerAccessControl.h index f4f19622..2a0ce318 100644 --- a/QuantumGateLib/Core/Access/PeerAccessControl.h +++ b/QuantumGateLib/Core/Access/PeerAccessControl.h @@ -33,7 +33,7 @@ namespace QuantumGate::Implementation::Core::Access Result<> UpdatePeer(PeerSettings&& pas) noexcept; Result<> RemovePeer(const PeerUUID& puuid) noexcept; - Result IsAllowed(const PeerUUID& puuid) const noexcept; + Result GetAllowed(const PeerUUID& puuid) const noexcept; const ProtectedBuffer* GetPublicKey(const PeerUUID& puuid) const noexcept; diff --git a/QuantumGateLib/Core/ListenerManager.cpp b/QuantumGateLib/Core/ListenerManager.cpp index 5bc9d6c3..40d7a6a4 100644 --- a/QuantumGateLib/Core/ListenerManager.cpp +++ b/QuantumGateLib/Core/ListenerManager.cpp @@ -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; } diff --git a/QuantumGateLib/Core/Peer/Peer.cpp b/QuantumGateLib/Core/Peer/Peer.cpp index 38e58515..32c06c7f 100644 --- a/QuantumGateLib/Core/Peer/Peer.cpp +++ b/QuantumGateLib/Core/Peer/Peer.cpp @@ -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 @@ -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 diff --git a/QuantumGateLib/Core/Peer/PeerManager.cpp b/QuantumGateLib/Core/Peer/PeerManager.cpp index d049a846..d90dc006 100644 --- a/QuantumGateLib/Core/Peer/PeerManager.cpp +++ b/QuantumGateLib/Core/Peer/PeerManager.cpp @@ -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 }; diff --git a/QuantumGateLib/Core/Peer/PeerMessageProcessor.cpp b/QuantumGateLib/Core/Peer/PeerMessageProcessor.cpp index 8cc0fbea..d18852f9 100644 --- a/QuantumGateLib/Core/Peer/PeerMessageProcessor.cpp +++ b/QuantumGateLib/Core/Peer/PeerMessageProcessor.cpp @@ -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)) diff --git a/QuantumGateLib/Version.h b/QuantumGateLib/Version.h index 2b2b2524..76076869 100644 --- a/QuantumGateLib/Version.h +++ b/QuantumGateLib/Version.h @@ -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) diff --git a/Test/Socks5Extender/Socks5Extender.cpp b/Test/Socks5Extender/Socks5Extender.cpp index 2732ed82..ea8cfb55 100644 --- a/Test/Socks5Extender/Socks5Extender.cpp +++ b/Test/Socks5Extender/Socks5Extender.cpp @@ -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; } diff --git a/Test/TestApp/CIPFiltersDlg.cpp b/Test/TestApp/CIPFiltersDlg.cpp index 1c87b049..01563a9f 100644 --- a/Test/TestApp/CIPFiltersDlg.cpp +++ b/Test/TestApp/CIPFiltersDlg.cpp @@ -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) diff --git a/Test/UnitTests/IPFiltersTests.cpp b/Test/UnitTests/IPFiltersTests.cpp index 86966017..be35f1c0 100644 --- a/Test/UnitTests/IPFiltersTests.cpp +++ b/Test/UnitTests/IPFiltersTests.cpp @@ -107,55 +107,55 @@ namespace UnitTests { IPFilters ipfilters; - Assert::AreEqual(true, ipfilters.IsAllowed(L"") == ResultCode::AddressInvalid); - Assert::AreEqual(true, ipfilters.IsAllowed(L"192.abc.0.1") == ResultCode::AddressInvalid); + Assert::AreEqual(true, ipfilters.GetAllowed(L"") == ResultCode::AddressInvalid); + Assert::AreEqual(true, ipfilters.GetAllowed(L"192.abc.0.1") == ResultCode::AddressInvalid); { // Not allowed by default - Assert::AreEqual(false, ipfilters.IsAllowed(L"192.168.0.1").GetValue()); - Assert::AreEqual(false, ipfilters.IsAllowed(L"192.168.0.10").GetValue()); - Assert::AreEqual(false, ipfilters.IsAllowed(L"192.168.0.200").GetValue()); + Assert::AreEqual(false, ipfilters.GetAllowed(L"192.168.0.1").GetValue()); + Assert::AreEqual(false, ipfilters.GetAllowed(L"192.168.0.10").GetValue()); + Assert::AreEqual(false, ipfilters.GetAllowed(L"192.168.0.200").GetValue()); // Allow range auto result = ipfilters.AddFilter(L"192.168.0.1", L"255.255.255.0", IPFilterType::Allowed); Assert::AreEqual(true, result.Succeeded()); // Should now be allowed - Assert::AreEqual(true, ipfilters.IsAllowed(L"192.168.0.1").GetValue()); - Assert::AreEqual(true, ipfilters.IsAllowed(L"192.168.0.10").GetValue()); - Assert::AreEqual(true, ipfilters.IsAllowed(L"192.168.0.200").GetValue()); + Assert::AreEqual(true, ipfilters.GetAllowed(L"192.168.0.1").GetValue()); + Assert::AreEqual(true, ipfilters.GetAllowed(L"192.168.0.10").GetValue()); + Assert::AreEqual(true, ipfilters.GetAllowed(L"192.168.0.200").GetValue()); // Not allowed - Assert::AreEqual(false, ipfilters.IsAllowed(L"fe80::c11a:3a9c:ef10:e795").GetValue()); + Assert::AreEqual(false, ipfilters.GetAllowed(L"fe80::c11a:3a9c:ef10:e795").GetValue()); } { // Not allowed by default - Assert::AreEqual(false, ipfilters.IsAllowed(L"192.168.1.2").GetValue()); + Assert::AreEqual(false, ipfilters.GetAllowed(L"192.168.1.2").GetValue()); // Allow range auto result2 = ipfilters.AddFilter(L"192.168.1.2", L"255.255.255.255", IPFilterType::Allowed); Assert::AreEqual(true, result2.Succeeded()); // Should now be allowed - Assert::AreEqual(true, ipfilters.IsAllowed(L"192.168.1.2").GetValue()); + Assert::AreEqual(true, ipfilters.GetAllowed(L"192.168.1.2").GetValue()); // Not allowed by default - Assert::AreEqual(false, ipfilters.IsAllowed(L"192.168.1.1").GetValue()); - Assert::AreEqual(false, ipfilters.IsAllowed(L"192.168.1.100").GetValue()); - Assert::AreEqual(false, ipfilters.IsAllowed(L"192.200.1.100").GetValue()); + Assert::AreEqual(false, ipfilters.GetAllowed(L"192.168.1.1").GetValue()); + Assert::AreEqual(false, ipfilters.GetAllowed(L"192.168.1.100").GetValue()); + Assert::AreEqual(false, ipfilters.GetAllowed(L"192.200.1.100").GetValue()); Assert::AreEqual(true, ipfilters.RemoveFilter(*result2, IPFilterType::Allowed).Succeeded()); // Not allowed anymore after removal of filter range above - Assert::AreEqual(false, ipfilters.IsAllowed(L"192.168.1.2").GetValue()); + Assert::AreEqual(false, ipfilters.GetAllowed(L"192.168.1.2").GetValue()); } { // Not allowed by default - Assert::AreEqual(false, ipfilters.IsAllowed(L"fe80:c11a:3a9c:ef10:e795::").GetValue()); + Assert::AreEqual(false, ipfilters.GetAllowed(L"fe80:c11a:3a9c:ef10:e795::").GetValue()); // Allow range auto result3 = ipfilters.AddFilter(L"fe80:c11a:3a9c:ef10:e795::", @@ -163,13 +163,13 @@ namespace UnitTests Assert::AreEqual(true, result3.Succeeded()); // Should now be allowed - Assert::AreEqual(true, ipfilters.IsAllowed(L"fe80:c11a:3a9c:ef10:e795::").GetValue()); + Assert::AreEqual(true, ipfilters.GetAllowed(L"fe80:c11a:3a9c:ef10:e795::").GetValue()); Assert::AreEqual(true, ipfilters.RemoveFilter(*result3, IPFilterType::Allowed).Succeeded()); // Not allowed anymore after removal of filter range above - Assert::AreEqual(false, ipfilters.IsAllowed(L"fe80:c11a:3a9c:ef10:e795::").GetValue()); + Assert::AreEqual(false, ipfilters.GetAllowed(L"fe80:c11a:3a9c:ef10:e795::").GetValue()); } { @@ -177,12 +177,12 @@ namespace UnitTests ipfilters.AddFilter(L"fe80:c11a:3a9c:ef11:e795::", L"ffff:ffff:ffff:ff00::", IPFilterType::Allowed).Succeeded()); - Assert::AreEqual(true, ipfilters.IsAllowed(L"fe80:c11a:3a9c:ef80:e795::").GetValue()); - Assert::AreEqual(true, ipfilters.IsAllowed(L"fe80:c11a:3a9c:ef81:e795::").GetValue()); - Assert::AreEqual(true, ipfilters.IsAllowed(L"fe80:c11a:3a9c:ef91:e795::").GetValue()); + Assert::AreEqual(true, ipfilters.GetAllowed(L"fe80:c11a:3a9c:ef80:e795::").GetValue()); + Assert::AreEqual(true, ipfilters.GetAllowed(L"fe80:c11a:3a9c:ef81:e795::").GetValue()); + Assert::AreEqual(true, ipfilters.GetAllowed(L"fe80:c11a:3a9c:ef91:e795::").GetValue()); - Assert::AreEqual(false, ipfilters.IsAllowed(L"fe80:c11a:3a9c:df11::").GetValue()); - Assert::AreEqual(false, ipfilters.IsAllowed(L"fe80:c11a:3a9c:ff11::").GetValue()); + Assert::AreEqual(false, ipfilters.GetAllowed(L"fe80:c11a:3a9c:df11::").GetValue()); + Assert::AreEqual(false, ipfilters.GetAllowed(L"fe80:c11a:3a9c:ff11::").GetValue()); } // Remove all filters @@ -198,30 +198,30 @@ namespace UnitTests { // Blocked by default - Assert::AreEqual(false, ipfilters.IsAllowed(L"192.168.0.100").GetValue()); + Assert::AreEqual(false, ipfilters.GetAllowed(L"192.168.0.100").GetValue()); // Allow IPv4 range Assert::AreEqual(true, ipfilters.AddFilter(L"192.168.0.1", L"255.255.255.0", IPFilterType::Allowed).Succeeded()); // This address should be allowed now because of above filter - Assert::AreEqual(true, ipfilters.IsAllowed(L"192.168.0.100").GetValue()); + Assert::AreEqual(true, ipfilters.GetAllowed(L"192.168.0.100").GetValue()); // Specifically block an address in the allowed range Assert::AreEqual(true, ipfilters.AddFilter(L"192.168.0.100", L"255.255.255.255", IPFilterType::Blocked).Succeeded()); // This address should now be blocked - Assert::AreEqual(false, ipfilters.IsAllowed(L"192.168.0.100").GetValue()); + Assert::AreEqual(false, ipfilters.GetAllowed(L"192.168.0.100").GetValue()); // These should be allowed - Assert::AreEqual(true, ipfilters.IsAllowed(L"192.168.0.99").GetValue()); - Assert::AreEqual(true, ipfilters.IsAllowed(L"192.168.0.101").GetValue()); + Assert::AreEqual(true, ipfilters.GetAllowed(L"192.168.0.99").GetValue()); + Assert::AreEqual(true, ipfilters.GetAllowed(L"192.168.0.101").GetValue()); } { // Blocked by default - Assert::AreEqual(false, ipfilters.IsAllowed(L"fe80:c11a:3a9c:ef11:e795::f000").GetValue()); + Assert::AreEqual(false, ipfilters.GetAllowed(L"fe80:c11a:3a9c:ef11:e795::f000").GetValue()); // Allow IPv6 range Assert::AreEqual(true, ipfilters.AddFilter(L"fe80:c11a:3a9c:ef11:e795::", @@ -229,7 +229,7 @@ namespace UnitTests IPFilterType::Allowed).Succeeded()); // This address should be allowed now because of above filter - Assert::AreEqual(true, ipfilters.IsAllowed(L"fe80:c11a:3a9c:ef11:e795::f000").GetValue()); + Assert::AreEqual(true, ipfilters.GetAllowed(L"fe80:c11a:3a9c:ef11:e795::f000").GetValue()); // Specifically block an address in the allowed range Assert::AreEqual(true, ipfilters.AddFilter(L"fe80:c11a:3a9c:ef11:e795::f000", @@ -237,7 +237,7 @@ namespace UnitTests IPFilterType::Blocked).Succeeded()); // This address should now be blocked - Assert::AreEqual(false, ipfilters.IsAllowed(L"fe80:c11a:3a9c:ef11:e795::f000").GetValue()); + Assert::AreEqual(false, ipfilters.GetAllowed(L"fe80:c11a:3a9c:ef11:e795::f000").GetValue()); } } }; diff --git a/Test/UnitTests/PeerAccessControlTests.cpp b/Test/UnitTests/PeerAccessControlTests.cpp index bc97d45c..48520ca9 100644 --- a/Test/UnitTests/PeerAccessControlTests.cpp +++ b/Test/UnitTests/PeerAccessControlTests.cpp @@ -35,7 +35,7 @@ namespace UnitTests // Peer not allowed Assert::AreEqual(false, - pac.IsAllowed(QuantumGate::UUID(L"3c0c4c02-5ebc-f99a-0b5e-acdd238b1e54")).GetValue()); + pac.GetAllowed(QuantumGate::UUID(L"3c0c4c02-5ebc-f99a-0b5e-acdd238b1e54")).GetValue()); // Add peer { @@ -51,7 +51,7 @@ namespace UnitTests } // Peer allowed - Assert::AreEqual(true, pac.IsAllowed(QuantumGate::UUID(L"3c0c4c02-5ebc-f99a-0b5e-acdd238b1e54")).GetValue()); + Assert::AreEqual(true, pac.GetAllowed(QuantumGate::UUID(L"3c0c4c02-5ebc-f99a-0b5e-acdd238b1e54")).GetValue()); // Add peer invalid/unset UUID { @@ -106,7 +106,7 @@ namespace UnitTests // Peer allowed Assert::AreEqual(true, - pac.IsAllowed(QuantumGate::UUID(L"e938164b-52c1-69d4-0b84-75d3d11dbfad")).GetValue()); + pac.GetAllowed(QuantumGate::UUID(L"e938164b-52c1-69d4-0b84-75d3d11dbfad")).GetValue()); // Update peer that already exists { @@ -119,7 +119,7 @@ namespace UnitTests // Peer not allowed anymore Assert::AreEqual(false, - pac.IsAllowed(QuantumGate::UUID(L"e938164b-52c1-69d4-0b84-75d3d11dbfad")).GetValue()); + pac.GetAllowed(QuantumGate::UUID(L"e938164b-52c1-69d4-0b84-75d3d11dbfad")).GetValue()); // Update peer that doesn't exists { @@ -187,13 +187,13 @@ namespace UnitTests // Unknown peer allowed because of default setting Assert::AreEqual(true, - pac.IsAllowed(QuantumGate::UUID(L"3c0c4c02-5ebc-f99a-0b5e-acdd238b1e54")).GetValue()); + pac.GetAllowed(QuantumGate::UUID(L"3c0c4c02-5ebc-f99a-0b5e-acdd238b1e54")).GetValue()); pac.SetAccessDefault(PeerAccessDefault::NotAllowed); // Unknown peer not allowed because of default setting Assert::AreEqual(false, - pac.IsAllowed(QuantumGate::UUID(L"3c0c4c02-5ebc-f99a-0b5e-acdd238b1e54")).GetValue()); + pac.GetAllowed(QuantumGate::UUID(L"3c0c4c02-5ebc-f99a-0b5e-acdd238b1e54")).GetValue()); // Add peer { @@ -210,7 +210,7 @@ namespace UnitTests // Peer allowed because it's now known Assert::AreEqual(true, - pac.IsAllowed(QuantumGate::UUID(L"3c0c4c02-5ebc-f99a-0b5e-acdd238b1e54")).GetValue()); + pac.GetAllowed(QuantumGate::UUID(L"3c0c4c02-5ebc-f99a-0b5e-acdd238b1e54")).GetValue()); // Add peer that's not allowed @@ -228,13 +228,13 @@ namespace UnitTests // Not allowed because of peer setting Assert::AreEqual(false, - pac.IsAllowed(QuantumGate::UUID(L"e938164b-52c1-69d4-0b84-75d3d11dbfad")).GetValue()); + pac.GetAllowed(QuantumGate::UUID(L"e938164b-52c1-69d4-0b84-75d3d11dbfad")).GetValue()); pac.SetAccessDefault(PeerAccessDefault::Allowed); // Still not allowed Assert::AreEqual(false, - pac.IsAllowed(QuantumGate::UUID(L"e938164b-52c1-69d4-0b84-75d3d11dbfad")).GetValue()); + pac.GetAllowed(QuantumGate::UUID(L"e938164b-52c1-69d4-0b84-75d3d11dbfad")).GetValue()); pac.SetAccessDefault(PeerAccessDefault::NotAllowed); @@ -258,7 +258,7 @@ namespace UnitTests // Peer not allowed due to authentication required setting while peer doesn't have a public key Assert::AreEqual(false, - pac.IsAllowed(QuantumGate::UUID(L"e938164b-52c1-69d4-0b84-75d3d11dbfad")).GetValue()); + pac.GetAllowed(QuantumGate::UUID(L"e938164b-52c1-69d4-0b84-75d3d11dbfad")).GetValue()); settings.UpdateValue([](Settings& set) { @@ -267,7 +267,7 @@ namespace UnitTests // Peer is now allowed Assert::AreEqual(true, - pac.IsAllowed(QuantumGate::UUID(L"e938164b-52c1-69d4-0b84-75d3d11dbfad")).GetValue()); + pac.GetAllowed(QuantumGate::UUID(L"e938164b-52c1-69d4-0b84-75d3d11dbfad")).GetValue()); // Remove peer Assert::AreEqual(true, @@ -275,13 +275,13 @@ namespace UnitTests // Peer is not allowed due to access default Assert::AreEqual(false, - pac.IsAllowed(QuantumGate::UUID(L"e938164b-52c1-69d4-0b84-75d3d11dbfad")).GetValue()); + pac.GetAllowed(QuantumGate::UUID(L"e938164b-52c1-69d4-0b84-75d3d11dbfad")).GetValue()); pac.SetAccessDefault(PeerAccessDefault::Allowed); // Peer is allowed due to access default Assert::AreEqual(true, - pac.IsAllowed(QuantumGate::UUID(L"e938164b-52c1-69d4-0b84-75d3d11dbfad")).GetValue()); + pac.GetAllowed(QuantumGate::UUID(L"e938164b-52c1-69d4-0b84-75d3d11dbfad")).GetValue()); settings.UpdateValue([](Settings& set) { @@ -290,7 +290,7 @@ namespace UnitTests // Peer is not allowed due to authentication requirements Assert::AreEqual(false, - pac.IsAllowed(QuantumGate::UUID(L"e938164b-52c1-69d4-0b84-75d3d11dbfad")).GetValue()); + pac.GetAllowed(QuantumGate::UUID(L"e938164b-52c1-69d4-0b84-75d3d11dbfad")).GetValue()); } }; } \ No newline at end of file