| 202 | // |
| 203 | |
| 204 | IpAllow::IpAllow(const char *ip_allow_config_var, const char *ip_categories_config_var) |
| 205 | : ip_allow_config_file(ats_scoped_str(RecConfigReadConfigPath(ip_allow_config_var)).get()) |
| 206 | { |
| 207 | int matching_policy = 0; |
| 208 | REC_ReadConfigInteger(matching_policy, "proxy.config.url_remap.acl_behavior_policy"); |
| 209 | if (matching_policy == 0) { |
| 210 | this->_is_legacy_action_policy = true; |
| 211 | } else { |
| 212 | this->_is_legacy_action_policy = false; |
| 213 | } |
| 214 | std::string const path = RecConfigReadConfigPath(ip_categories_config_var); |
| 215 | if (!path.empty()) { |
| 216 | ip_categories_config_file = ats_scoped_str(path).get(); |
| 217 | } |
| 218 | |
| 219 | RecString subjects_char; |
| 220 | REC_ReadConfigStringAlloc(subjects_char, "proxy.config.acl.subjects"); |
| 221 | std::string_view subjects_sv{subjects_char}; |
| 222 | int i = 0; |
| 223 | std::string_view::size_type s, e; |
| 224 | for (s = 0, e = 0; s < subjects_sv.size() && e != subjects_sv.npos; s = e + 1) { |
| 225 | e = subjects_sv.find(",", s); |
| 226 | std::string_view subject_sv = subjects_sv.substr(s, e); |
| 227 | if (i >= MAX_SUBJECTS) { |
| 228 | Error("Too many ACL subjects were provided"); |
| 229 | } |
| 230 | if (subject_sv == "PEER") { |
| 231 | subjects[i] = Subject::PEER; |
| 232 | ++i; |
| 233 | } else if (subject_sv == "PROXY") { |
| 234 | subjects[i] = Subject::PROXY; |
| 235 | ++i; |
| 236 | } else { |
| 237 | Dbg(dbg_ctl_ip_allow, "Unknown subject %.*s was ignored", static_cast<int>(subject_sv.length()), subject_sv.data()); |
| 238 | } |
| 239 | } |
| 240 | if (i < Subject::MAX_SUBJECTS) { |
| 241 | subjects[i] = Subject::MAX_SUBJECTS; |
| 242 | } |
| 243 | ats_free(subjects_char); |
| 244 | } |
| 245 | |
| 246 | BufferWriter & |
| 247 | bwformat(BufferWriter &w, Spec const & /* spec ATS_UNUSED */, IpAllow::IpMap const &map) |
nothing calls this directly
no test coverage detected