Github user SolidWallOfCode commented on a diff in the pull request:

    https://github.com/apache/trafficserver/pull/769#discussion_r82400518
  
    --- Diff: proxy/IPAllow.h ---
    @@ -129,34 +129,55 @@ class IpAllow : public ConfigInfo
       {
         return &ALL_METHOD_ACL;
       }
    +  
    +  /// @return The previous accept check state
    +  static bool enableAcceptCheck(bool state) {
    +    bool temp = accept_check_p;
    +    accept_check_p = state;
    +    return temp;
    +  }
    +  /// @return The current accept check state
    +  static bool isAcceptCheckEnabled() {
    +    return accept_check_p;
    +  }
     
       typedef ConfigProcessor::scoped_config<IpAllow, IpAllow> scoped_config;
     
     private:
       static int configid;
       static const AclRecord ALL_METHOD_ACL;
    +  static bool accept_check_p;
     
    +  void PrintMap(IpMap * map);
       int BuildTable();
     
       char config_file_path[PATH_NAME_MAX];
       const char *module_name;
       const char *action;
    -  IpMap _map;
    -  Vec<AclRecord> _acls;
    +  IpMap _src_map;
    +  IpMap _dest_map;
    +  Vec<AclRecord> _src_acls;
    +  Vec<AclRecord> _dest_acls;
     };
     
     inline AclRecord *
    -IpAllow::match(IpEndpoint const *ip) const
    +IpAllow::match(IpEndpoint const *ip, bool is_dest_ip) const
     {
    -  return this->match(&ip->sa);
    +  return this->match(&ip->sa, is_dest_ip);
     }
     
     inline AclRecord *
    -IpAllow::match(sockaddr const *ip) const
    +IpAllow::match(sockaddr const *ip, bool is_dest_ip) const
     {
       void *raw;
    -  if (_map.contains(ip, &raw)) {
    -    return static_cast<AclRecord *>(raw);
    +  if(is_dest_ip) {
    --- End diff --
    
    I think
    ```
    IpAllow::match(sockaddr const* ip, match_key_t key) {
    void *raw = NULL;
    this->map(key).contains(ip, &raw);
    return static_cast<AclRecord*>(raw);
    ```
    
    Then define
    ```
    IpMap& map(match_key_t key) { return key == SRC_ADDR ? _src_map : 
_dest_map; }
    ```
    
    This could be used elsewhere instead of the current ternary operator for 
cleaner code.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to