| 297 | } |
| 298 | |
| 299 | swoc::Errata |
| 300 | IpAllow::BuildTable() |
| 301 | { |
| 302 | // Table should be empty |
| 303 | ink_assert(_src_map.count() == 0 && _dst_map.count() == 0); |
| 304 | |
| 305 | std::error_code ec; |
| 306 | std::string content{swoc::file::load(ip_allow_config_file, ec)}; |
| 307 | swoc::Errata errata; |
| 308 | if (ec.value() == 0) { |
| 309 | try { |
| 310 | errata = this->YAMLBuildTable(content); |
| 311 | } catch (std::exception &ex) { |
| 312 | return swoc::Errata(ec, ERRATA_ERROR, "{} - Invalid config: {}", this, ex.what()); |
| 313 | } |
| 314 | if (!errata.is_ok()) { |
| 315 | errata.note("While parsing config file"); |
| 316 | return errata; |
| 317 | } |
| 318 | |
| 319 | if (_src_map.count() == 0 && _dst_map.count() == 0) { |
| 320 | return swoc::Errata(ERRATA_ERROR, "{} - No entries found. All IP Addresses will be blocked", this); |
| 321 | } |
| 322 | |
| 323 | if (dbg_ctl_ip_allow.on()) { |
| 324 | Print(); |
| 325 | } |
| 326 | } else { |
| 327 | return swoc::Errata(ERRATA_ERROR, "{} Failed to load {}. All IP Addresses will be blocked", this, ec); |
| 328 | } |
| 329 | return {}; |
| 330 | } |
| 331 | |
| 332 | swoc::Errata |
| 333 | IpAllow::YAMLLoadMethod(const YAML::Node &node, Record &rec) |
no test coverage detected