| 573 | } |
| 574 | |
| 575 | swoc::Errata |
| 576 | IpAllow::BuildCategories() |
| 577 | { |
| 578 | std::error_code ec; |
| 579 | if (ip_categories_config_file.empty()) { |
| 580 | return {}; |
| 581 | } |
| 582 | |
| 583 | Note("%s loading categores file %s ...", ts::filename::IP_ALLOW, ip_categories_config_file.c_str()); |
| 584 | std::string content{swoc::file::load(ip_categories_config_file, ec)}; |
| 585 | swoc::Errata errata; |
| 586 | if (ec.value() == 0) { |
| 587 | try { |
| 588 | errata = this->YAMLBuildCategories(content); |
| 589 | } catch (std::exception &ex) { |
| 590 | return swoc::Errata(ec, ERRATA_ERROR, "{} - Invalid IP Categories {} content: {}", this, ip_categories_config_file, |
| 591 | ex.what()); |
| 592 | } |
| 593 | if (!errata.is_ok()) { |
| 594 | errata.note("While parsing ip categories file: {}", ip_categories_config_file); |
| 595 | return errata; |
| 596 | } |
| 597 | } else { |
| 598 | return swoc::Errata(ERRATA_ERROR, "{} Failed to load {}", this, ec); |
| 599 | } |
| 600 | Note("%s done loading categores file %s ...", ts::filename::IP_ALLOW, ip_categories_config_file.c_str()); |
| 601 | return {}; |
| 602 | } |
| 603 | |
| 604 | swoc::Errata |
| 605 | IpAllow::YAMLBuildCategories(std::string const &content) |
no test coverage detected