You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by "SolidWallOfCode (via GitHub)" <gi...@apache.org> on 2023/06/17 14:45:07 UTC

[GitHub] [trafficserver] SolidWallOfCode commented on a diff in pull request #9845: Extract apply_ip_allow_filter

SolidWallOfCode commented on code in PR #9845:
URL: https://github.com/apache/trafficserver/pull/9845#discussion_r1233073461


##########
proxy/http/HttpSM.cc:
##########
@@ -5258,6 +5258,70 @@ HttpSM::get_outbound_sni() const
   return zret;
 }
 
+bool
+HttpSM::apply_ip_allow_filter()
+{
+  bool result{true};
+  // Method allowed on dest IP address check
+  IpAllow::ACL acl = IpAllow::match(get_server_ip(), IpAllow::DST_ADDR);
+
+  if (ip_allow_is_request_forbidden(acl)) {
+    ip_allow_deny_request(acl);
+    result = false;
+  } else if (HttpTransact::is_server_negative_cached(&t_state) == true &&
+             t_state.txn_conf->connect_attempts_max_retries_down_server <= 0) {
+    call_transact_and_set_next_state(HttpTransact::OriginDown);
+    result = false;
+  }
+
+  return result;
+}
+
+bool
+HttpSM::ip_allow_is_request_forbidden(const IpAllow::ACL &acl)
+{
+  bool result{false};
+  if (acl.isValid()) {
+    if (acl.isDenyAll()) {
+      result = true;
+    } else if (!acl.isAllowAll()) {
+      if (get_request_method() != -1) {

Review Comment:
   Important style point - if calling a local method, use `this->`. E.g. `this->get_request_method()`. Knowing what's part of the class and what's global at a glance is very useful.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org