Andrew Geissler | 3b025e6 | 2019-02-01 10:33:54 -0600 | [diff] [blame] | 1 | #include "processing.hpp" |
| 2 | |
| 3 | #include <boost/algorithm/string/predicate.hpp> |
| 4 | |
| 5 | bool 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 Geissler | 82815da | 2019-02-04 12:19:41 -0600 | [diff] [blame^] | 24 | |
| 25 | bool 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 | } |