MCPcopy Create free account
hub / github.com/apache/trafficserver / IpAllow

Method IpAllow

src/proxy/IPAllow.cc:204–244  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

202//
203
204IpAllow::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
246BufferWriter &
247bwformat(BufferWriter &w, Spec const & /* spec ATS_UNUSED */, IpAllow::IpMap const &map)

Callers

nothing calls this directly

Calls 11

ats_scoped_strClass · 0.85
RecConfigReadConfigPathFunction · 0.85
ats_freeFunction · 0.85
ErrorClass · 0.50
getMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45
findMethod · 0.45
substrMethod · 0.45
lengthMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected