You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ma...@apache.org on 2018/08/29 05:51:32 UTC

[trafficserver] 02/04: Fix HQ to replace AclRecord with IpAllow::ACL

This is an automated email from the ASF dual-hosted git repository.

masaori pushed a commit to branch quic-latest
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit cfa1d0da9a00b61b3fa75c984e59f76439ce517e
Author: Masaori Koshiba <ma...@apache.org>
AuthorDate: Wed Aug 29 14:48:46 2018 +0900

    Fix HQ to replace AclRecord with IpAllow::ACL
---
 proxy/hq/HQSessionAccept.cc | 11 ++++++-----
 proxy/hq/QUICSimpleApp.cc   | 10 +++-------
 proxy/hq/QUICSimpleApp.h    |  4 +++-
 3 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/proxy/hq/HQSessionAccept.cc b/proxy/hq/HQSessionAccept.cc
index 4f9299f..e16b6c5 100644
--- a/proxy/hq/HQSessionAccept.cc
+++ b/proxy/hq/HQSessionAccept.cc
@@ -25,7 +25,7 @@
 
 #include "P_Net.h"
 #include "I_Machine.h"
-#include "../IPAllow.h"
+#include "IPAllow.h"
 #include "QUICSimpleApp.h"
 
 HQSessionAccept::HQSessionAccept(const HttpSessionAccept::Options &_o) : SessionAccept(nullptr), options(_o)
@@ -38,13 +38,14 @@ HQSessionAccept::~HQSessionAccept() {}
 bool
 HQSessionAccept::accept(NetVConnection *netvc, MIOBuffer *iobuf, IOBufferReader *reader)
 {
-  sockaddr const *client_ip           = netvc->get_remote_addr();
-  const AclRecord *session_acl_record = testIpAllowPolicy(client_ip);
-  if (!session_acl_record) {
+  sockaddr const *client_ip = netvc->get_remote_addr();
+  IpAllow::ACL session_acl  = IpAllow::match(client_ip, IpAllow::SRC_ADDR);
+  if (!session_acl.isValid()) {
     ip_port_text_buffer ipb;
     Warning("QUIC client '%s' prohibited by ip-allow policy", ats_ip_ntop(client_ip, ipb, sizeof(ipb)));
     return false;
   }
+
   netvc->attributes = this->options.transport_type;
 
   if (is_debug_tag_set("hq")) {
@@ -55,7 +56,7 @@ HQSessionAccept::accept(NetVConnection *netvc, MIOBuffer *iobuf, IOBufferReader
           ats_ip_nptop(client_ip, ipb, sizeof(ipb)), netvc->attributes);
   }
 
-  new QUICSimpleApp(static_cast<QUICNetVConnection *>(netvc));
+  new QUICSimpleApp(static_cast<QUICNetVConnection *>(netvc), std::move(session_acl));
 
   return true;
 }
diff --git a/proxy/hq/QUICSimpleApp.cc b/proxy/hq/QUICSimpleApp.cc
index 7dc5027..6d77af7 100644
--- a/proxy/hq/QUICSimpleApp.cc
+++ b/proxy/hq/QUICSimpleApp.cc
@@ -29,18 +29,14 @@
 
 #include "HQClientSession.h"
 #include "HQClientTransaction.h"
-#include "../IPAllow.h"
 
 static constexpr char tag[]   = "quic_simple_app";
 static constexpr char tag_v[] = "v_quic_simple_app";
 
-QUICSimpleApp::QUICSimpleApp(QUICNetVConnection *client_vc) : QUICApplication(client_vc)
+QUICSimpleApp::QUICSimpleApp(QUICNetVConnection *client_vc, IpAllow::ACL session_acl) : QUICApplication(client_vc)
 {
-  sockaddr const *client_ip           = client_vc->get_remote_addr();
-  const AclRecord *session_acl_record = SessionAccept::testIpAllowPolicy(client_ip);
-
-  this->_client_session             = new HQClientSession(client_vc);
-  this->_client_session->acl_record = session_acl_record;
+  this->_client_session      = new HQClientSession(client_vc);
+  this->_client_session->acl = std::move(session_acl);
   this->_client_session->new_connection(client_vc, nullptr, nullptr, false);
 
   this->_qc->stream_manager()->set_default_application(this);
diff --git a/proxy/hq/QUICSimpleApp.h b/proxy/hq/QUICSimpleApp.h
index 12804eb..492aed3 100644
--- a/proxy/hq/QUICSimpleApp.h
+++ b/proxy/hq/QUICSimpleApp.h
@@ -23,6 +23,8 @@
 
 #pragma once
 
+#include "IPAllow.h"
+
 #include "QUICApplication.h"
 
 class QUICNetVConnection;
@@ -36,7 +38,7 @@ class HQClientSession;
 class QUICSimpleApp : public QUICApplication
 {
 public:
-  QUICSimpleApp(QUICNetVConnection *client_vc);
+  QUICSimpleApp(QUICNetVConnection *client_vc, IpAllow::ACL session_acl);
   ~QUICSimpleApp();
 
   int main_event_handler(int event, Event *data);