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

Method YAMLLoadCategoryDefinition

src/proxy/IPAllow.cc:636–677  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

634}
635
636swoc::Errata
637IpAllow::YAMLLoadCategoryDefinition(const YAML::Node &entry)
638{
639 /* Parse this into ip_category_map:
640 *
641 * - name: <category name>
642 * ip_addrs:
643 * - <ip range>
644 * - <ip range>
645 * - <ip range>
646 */
647 if (!entry.IsMap()) {
648 return swoc::Errata(ERRATA_ERROR, "{} {} - Category definition must be a map.", this, entry.Mark());
649 }
650
651 if (auto name_node = entry[YAML_TAG_CATEGORY_NAME]; name_node) {
652 if (!name_node.IsScalar()) {
653 return swoc::Errata(ERRATA_ERROR, "{} {} - Category name must be a string.", this, name_node.Mark());
654 }
655 std::string const &name(name_node.Scalar());
656 if (auto ip_addrs_node = entry[YAML_TAG_CATEGORY_IP_ADDRS]; ip_addrs_node) {
657 if (ip_addrs_node.IsSequence()) {
658 for (auto const &ip_addr_node : ip_addrs_node) {
659 if (auto errata = this->YAMLLoadCategoryIpRange(ip_addr_node, ip_category_map[name]); !errata.is_ok()) {
660 errata.note(R"(In category definition at {})", entry.Mark());
661 return errata;
662 }
663 }
664 } else {
665 if (auto errata = this->YAMLLoadCategoryIpRange(ip_addrs_node, ip_category_map[name]); !errata.is_ok()) {
666 errata.note(R"(In category definition at {})", entry.Mark());
667 return errata;
668 }
669 }
670 } else { // No ip_addrs.
671 return swoc::Errata(ERRATA_ERROR, "{} {} - IP Addresses must be specified.", this, entry.Mark());
672 }
673 } else { // No name
674 return swoc::Errata(ERRATA_ERROR, "{} {} - Category name must be specified.", this, entry.Mark());
675 }
676 return {};
677}
678
679swoc::Errata
680IpAllow::YAMLLoadCategoryIpRange(const YAML::Node &node, swoc::IPSpace<bool> &space)

Callers 1

YAMLLoadCategoryRootMethod · 0.95

Calls 5

ErrataClass · 0.85
MarkMethod · 0.45
is_okMethod · 0.45
noteMethod · 0.45

Tested by

no test coverage detected