blob: be7bf12344d873e5b877cf338b9d9b0aced0ac47 [file] [log] [blame]
Andrew Geissler3b025e62019-02-01 10:33:54 -06001#include "processing.hpp"
2
3#include <boost/algorithm/string/predicate.hpp>
4
5bool getWellKnown(
6 const boost::container::flat_map<std::string, std::string>& owners,
7 const std::string& request, std::string& wellKnown)
8{
9 // If it's already a well known name, just return
10 if (!boost::starts_with(request, ":"))
11 {
12 wellKnown = request;
13 return true;
14 }
15
16 auto it = owners.find(request);
17 if (it == owners.end())
18 {
19 return false;
20 }
21 wellKnown = it->second;
22 return true;
23}
Andrew Geissler82815da2019-02-04 12:19:41 -060024
25bool needToIntrospect(const std::string& processName,
26 const WhiteBlackList& whiteList,
27 const WhiteBlackList& blackList)
28{
29 auto inWhitelist =
30 std::find_if(whiteList.begin(), whiteList.end(),
31 [&processName](const auto& prefix) {
32 return boost::starts_with(processName, prefix);
33 }) != whiteList.end();
34
35 // This holds full service names, not prefixes
36 auto inBlacklist = blackList.find(processName) != blackList.end();
37
38 return inWhitelist && !inBlacklist;
39}