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

Method YAMLBuildTable

src/proxy/IPAllow.cc:541–573  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

539}
540
541swoc::Errata
542IpAllow::YAMLBuildTable(std::string const &content)
543{
544 YAML::Node root{YAML::Load(content)};
545 if (!root.IsMap()) {
546 return swoc::Errata("{} - top level object was not a map. All IP Addresses will be blocked", this);
547 }
548
549 // IP categories are optional. Load them if specified. Note that the rules,
550 // if they use categories, depend upon the categories being defined. So the
551 // categories have to be processed first before the rules are.
552 YAML::Node categories{root[YAML_TAG_CATEGORY_ROOT.data()]};
553 if (auto errata = this->YAMLLoadCategoryRoot(categories); !errata.is_ok()) {
554 return errata;
555 }
556
557 // Now load the IPAllow rules.
558 YAML::Node rules{root[YAML_TAG_ROOT.data()]};
559 if (!rules) {
560 return swoc::Errata("{} - root tag '{}' not found. All IP Addresses will be blocked", this, YAML_TAG_ROOT);
561 } else if (rules.IsSequence()) {
562 for (auto const &entry : rules) {
563 if (auto errata = this->YAMLLoadEntry(entry); !errata.is_ok()) {
564 return errata;
565 }
566 }
567 } else if (rules.IsMap()) {
568 return this->YAMLLoadEntry(rules); // singleton, just load it.
569 } else {
570 return swoc::Errata("{} - root tag '{}' is not an map or sequence. All IP Addresses will be blocked", this, YAML_TAG_ROOT);
571 }
572 return {};
573}
574
575swoc::Errata
576IpAllow::BuildCategories()

Callers 1

BuildTableMethod · 0.95

Calls 6

YAMLLoadCategoryRootMethod · 0.95
YAMLLoadEntryMethod · 0.95
LoadFunction · 0.85
ErrataClass · 0.85
dataMethod · 0.45
is_okMethod · 0.45

Tested by

no test coverage detected