forked from Cellenza/CopilotHackaton
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathSearchInDictionary.cpp
More file actions
44 lines (38 loc) · 958 Bytes
/
Copy pathSearchInDictionary.cpp
File metadata and controls
44 lines (38 loc) · 958 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "pch.h"
#include "Blacklist.h"
#include "SearchInDictionary.h"
bool SearchInDictionary::Execute(const std::map<std::string, int>& dimensions, int valueToFind)
{
for (const auto& [key, value] : dimensions)
{
if (value == valueToFind)
{
return VerifyIpAddress(key);
}
}
return false;
}
bool SearchInDictionary::VerifyIpAddress(std::string_view key)
{
if ((std::count(key.begin(), key.end(), '.') == 3) && (Blacklist::IsWhiteList(key) || !Blacklist::IsBlacklisted(key)))
{
return true;
}
else if (std::count(key.begin(), key.end(), ':') == 7)
{
return true;
}
return false;
}
bool SearchInDictionary::VerifyIpAddressSimple(std::string_view key)
{
if (std::count(key.begin(), key.end(), '.') == 3)
{
return true;
}
else if (std::count(key.begin(), key.end(), ':') == 7)
{
return true;
}
return false;
}