| 330 | } |
| 331 | |
| 332 | swoc::Errata |
| 333 | IpAllow::YAMLLoadMethod(const YAML::Node &node, Record &rec) |
| 334 | { |
| 335 | swoc::TextView value{node.Scalar()}; |
| 336 | swoc::Vectray<swoc::TextView, 8> names; |
| 337 | // Process a single token. Required to deal with the variable number of tokens. |
| 338 | auto parse_method = [&](swoc::TextView value) -> void { |
| 339 | if (0 == strcasecmp(value, YAML_VALUE_METHODS_ALL)) { |
| 340 | rec._method_mask = ALL_METHOD_MASK; |
| 341 | } else { |
| 342 | int method_idx = hdrtoken_tokenize(value.data(), value.size()); |
| 343 | if (HTTP_WKSIDX_CONNECT <= method_idx && method_idx < HTTP_WKSIDX_CONNECT + HTTP_WKSIDX_METHODS_CNT) { |
| 344 | rec._method_mask |= ACL::MethodIdxToMask(method_idx); |
| 345 | } else { |
| 346 | names.push_back(value); |
| 347 | Dbg(dbg_ctl_ip_allow, "Found nonstandard method '%.*s' at line %d", int(value.size()), value.data(), node.Mark().line); |
| 348 | } |
| 349 | } |
| 350 | }; |
| 351 | |
| 352 | if (node.IsScalar()) { |
| 353 | parse_method(swoc::TextView(node.Scalar())); |
| 354 | } else if (node.IsSequence()) { |
| 355 | for (auto const &elt : node) { |
| 356 | if (elt.IsScalar()) { |
| 357 | parse_method(swoc::TextView(elt.Scalar())); |
| 358 | if (rec._method_mask == ALL_METHOD_MASK) { |
| 359 | break; // we're done here, nothing else matters. |
| 360 | } |
| 361 | } else { |
| 362 | return swoc::Errata(ERRATA_ERROR, "{} {} - item ignored, all values for '{}' must be strings.", this, elt.Mark(), |
| 363 | YAML_TAG_METHODS); |
| 364 | } |
| 365 | } |
| 366 | } else { |
| 367 | return swoc::Errata(ERRATA_ERROR, "{} {} - item ignored, value for '{}' must be a single string or a list of strings.", this, |
| 368 | node.Mark(), YAML_TAG_METHODS); |
| 369 | } |
| 370 | |
| 371 | // copy over to local memory if it's not all methods and there are non-standard ones. |
| 372 | if (rec._method_mask != ALL_METHOD_MASK && !names.empty()) { |
| 373 | rec._nonstandard_methods = _arena.alloc_span<swoc::TextView>(names.size()); |
| 374 | for (unsigned idx = 0; idx < names.size(); ++idx) { |
| 375 | rec._nonstandard_methods[idx] = this->localize(names[idx]); |
| 376 | } |
| 377 | } |
| 378 | return {}; |
| 379 | } |
| 380 | |
| 381 | swoc::Errata |
| 382 | IpAllow::YAMLLoadIPAddrRange(const YAML::Node &node, IpMap *map, IpAllow::Record const *record) |
no test coverage detected