| 171 | } |
| 172 | |
| 173 | IpAllow::ACL |
| 174 | IpAllow::match(swoc::IPAddr const &addr, match_key_t key) |
| 175 | { |
| 176 | self_type *self = acquire(); |
| 177 | Record const *record = nullptr; |
| 178 | if (SRC_ADDR == key) { |
| 179 | if (auto spot = self->_src_map.find(addr); spot != self->_src_map.end()) { |
| 180 | auto r = std::get<1>(*spot); |
| 181 | // Special case - if checking in accept is enabled and the record is a deny all, |
| 182 | // then return a missing record instead to force an immediate deny. Otherwise it's delayed |
| 183 | // until after remap, to allow remap rules to tweak the result. |
| 184 | if (!(accept_check_p && r->_method_mask == 0 && r->_nonstandard_methods.empty())) { |
| 185 | record = r; |
| 186 | } |
| 187 | } |
| 188 | } else if (auto spot = self->_dst_map.find(addr); spot != self->_dst_map.end()) { |
| 189 | record = std::get<1>(*spot); |
| 190 | } |
| 191 | |
| 192 | if (record == nullptr) { |
| 193 | self->release(); // no record, don't keep a reference to the config. |
| 194 | return {}; |
| 195 | } |
| 196 | |
| 197 | return ACL{record, self}; // Note this keeps the config in memory. |
| 198 | } |
| 199 | |
| 200 | // |
| 201 | // End API functions |