(trafficserver) branch master updated: traffic_ctl: Remove the hardcoded big buffer and use a stream buffer (#10870)

2023-12-01 Thread dmeden
This is an automated email from the ASF dual-hosted git repository.

dmeden pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
 new 3e131d6a38 traffic_ctl: Remove the hardcoded big buffer and use a 
stream buffer (#10870)
3e131d6a38 is described below

commit 3e131d6a38b57844e0b84d24ff70d276ef55
Author: Damian Meden 
AuthorDate: Fri Dec 1 12:21:47 2023 +0100

traffic_ctl: Remove the hardcoded big buffer and use a stream buffer 
(#10870)

instead.
On small responses this will just use the fixed buffer, if response
contains more than the fixed buffer then it will save the data into a
stringstream and reuse the already allocated buffer.
---
 include/shared/rpc/IPCSocketClient.h |  4 +-
 include/shared/rpc/RPCClient.h   | 23 +++---
 src/mgmt/rpc/server/unit_tests/test_rpcserver.cc | 14 ++--
 src/shared/rpc/IPCSocketClient.cc| 98 
 4 files changed, 106 insertions(+), 33 deletions(-)

diff --git a/include/shared/rpc/IPCSocketClient.h 
b/include/shared/rpc/IPCSocketClient.h
index d738734a2a..73b49b499c 100644
--- a/include/shared/rpc/IPCSocketClient.h
+++ b/include/shared/rpc/IPCSocketClient.h
@@ -55,8 +55,8 @@ struct IPCSocketClient {
   /// Send all the passed string to the socket.
   self_reference send(std::string_view data);
 
-  /// Read all the content from the socket till the passed buffer is full.
-  ReadStatus read_all(swoc::FixedBufferWriter );
+  /// Read all the content from the socket till the message is complete.
+  ReadStatus read_all(std::string );
 
   /// Closes the socket.
   void
diff --git a/include/shared/rpc/RPCClient.h b/include/shared/rpc/RPCClient.h
index 0408550e6f..d0e41fe172 100644
--- a/include/shared/rpc/RPCClient.h
+++ b/include/shared/rpc/RPCClient.h
@@ -26,6 +26,8 @@
 
 #include 
 #include 
+#include 
+
 #include 
 
 #include "shared/rpc/IPCSocketClient.h"
@@ -38,10 +40,6 @@ namespace shared::rpc
 ///
 class RPCClient
 {
-  // Large buffer, as we may query a full list of records(metrics can be a lot 
bigger).
-  // TODO: should we add a parameter to increase the buffer? or maybe a record 
limit on the server's side?
-  static constexpr size_t BUFFER_SIZE{3560};
-
 public:
   RPCClient() : _client(Layout::get()->runtimedir + "/jsonrpc20.sock") {}
 
@@ -53,22 +51,27 @@ public:
   invoke(std::string_view req)
   {
 std::string err_text; // for error messages.
-std::unique_ptr buf(new char[BUFFER_SIZE]);
-swoc::FixedBufferWriter bw{buf.get(), BUFFER_SIZE};
 try {
   _client.connect();
   if (!_client.is_closed()) {
+std::string resp;
 _client.send(req);
-switch (_client.read_all(bw)) {
+switch (_client.read_all(resp)) {
 case IPCSocketClient::ReadStatus::NO_ERROR: {
   _client.disconnect();
-  return {bw.data(), bw.size()};
+  return resp;
 }
 case IPCSocketClient::ReadStatus::BUFFER_FULL:
-  swoc::bwprint(err_text, "Buffer full, not enough space to read the 
response. Buffer size: {}", BUFFER_SIZE);
+  // we don't expect this to happen as client will not let us know 
about
+  // this for now. Keep this in case we decide to put a limit on
+  // responses.
+  ink_assert(!"Buffer full, not enough space to read the response.");
+  break;
+case IPCSocketClient::ReadStatus::STREAM_ERROR:
+  err_text = "STREAM_ERROR: Error while reading response.";
   break;
 default:
-  err_text = "Something happened, we can't read the response";
+  err_text = "Something happened, we can't read the response. Unknown 
error.";
   break;
 }
   } else {
diff --git a/src/mgmt/rpc/server/unit_tests/test_rpcserver.cc 
b/src/mgmt/rpc/server/unit_tests/test_rpcserver.cc
index 652ef11f8e..c08183e34a 100644
--- a/src/mgmt/rpc/server/unit_tests/test_rpcserver.cc
+++ b/src/mgmt/rpc/server/unit_tests/test_rpcserver.cc
@@ -190,21 +190,21 @@ struct ScopedLocalSocket : shared::rpc::IPCSocketClient {
   std::string
   read()
   {
-swoc::LocalBufferWriter<32000> bw;
-auto ret = super::read_all(bw);
+std::string buf;
+auto ret = super::read_all(buf);
 if (ret == ReadStatus::NO_ERROR) {
-  return {bw.data(), bw.size()};
+  return buf;
 }
 return {};
   }
-  // small wrapper function to deal with the bw.
+  // small wrapper function to deal with the flow.
   std::string
   query(std::string_view msg)
   {
-swoc::LocalBufferWriter<32000> bw;
-auto ret = connect().send(msg).read_all(bw);
+std::string buf;
+auto ret = connect().send(msg).read_all(buf);
 if (ret == ReadStatus::NO_ERROR) {
-  return {bw.data(), bw.size()};
+  return buf;
 }
 
 return {};
diff --git a/src/shared/rpc/IPCSocketClient.cc 

(trafficserver) branch master updated: Reenable management control for ts logging (#10883)

2023-12-01 Thread lzx404243
This is an automated email from the ASF dual-hosted git repository.

lzx404243 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
 new 515b610d45 Reenable management control for ts logging (#10883)
515b610d45 is described below

commit 515b610d458c8262fe486df0010a900093959fdd
Author: Zhengxi Li 
AuthorDate: Fri Dec 1 11:25:43 2023 -0500

Reenable management control for ts logging (#10883)
---
 src/traffic_server/traffic_server.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/traffic_server/traffic_server.cc 
b/src/traffic_server/traffic_server.cc
index 99c7fef3d8..0835228b7a 100644
--- a/src/traffic_server/traffic_server.cc
+++ b/src/traffic_server/traffic_server.cc
@@ -2172,7 +2172,7 @@ main(int /* argc ATS_UNUSED */, const char **argv)
 }
 
 // initialize logging (after event and net processor)
-Log::init(Log::NO_REMOTE_MANAGEMENT);
+Log::init();
 
 (void)parsePluginConfig();
 



(trafficserver) branch master updated: add new config option to support CUBIC (#10888)

2023-12-01 Thread duke8253
This is an automated email from the ASF dual-hosted git repository.

duke8253 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
 new 0776a0d8ba add new config option to support CUBIC (#10888)
0776a0d8ba is described below

commit 0776a0d8ba40e5392fc6d7fa60beb11bbdc96267
Author: Fei Deng 
AuthorDate: Fri Dec 1 11:34:49 2023 -0500

add new config option to support CUBIC (#10888)
---
 doc/admin-guide/files/records.yaml.en.rst | 11 +++
 include/iocore/net/quic/QUICConfig.h  |  5 +
 src/iocore/net/QUICNetProcessor.cc|  4 +---
 src/iocore/net/quic/QUICConfig.cc | 14 ++
 src/records/RecordsConfig.cc  |  2 ++
 5 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/doc/admin-guide/files/records.yaml.en.rst 
b/doc/admin-guide/files/records.yaml.en.rst
index fc0415eaa4..4dc2b8ae06 100644
--- a/doc/admin-guide/files/records.yaml.en.rst
+++ b/doc/admin-guide/files/records.yaml.en.rst
@@ -4785,6 +4785,17 @@ removed in the future without prior notice.
 
Disables HTTP/0.9 over QUIC by default.
 
+.. ts:cv:: CONFIG proxy.config.quic.cc_algorithm INT 0
+
+   Specified the congestion control algorithm.
+
+   = ==
+   Value Description
+   = ==
+   ``0`` RENO (default).
+   ``1`` CUBIC.
+   = ==
+
 
 UDP Configuration
 =
diff --git a/include/iocore/net/quic/QUICConfig.h 
b/include/iocore/net/quic/QUICConfig.h
index a48a24c583..ca77da8c4b 100644
--- a/include/iocore/net/quic/QUICConfig.h
+++ b/include/iocore/net/quic/QUICConfig.h
@@ -24,6 +24,7 @@
 #pragma once
 
 #include 
+#include 
 
 #include "iocore/eventsystem/ConfigProcessor.h"
 #include "../../../../src/iocore/net/P_SSLCertLookup.h"
@@ -87,6 +88,8 @@ public:
 
   bool disable_http_0_9() const;
 
+  quiche_cc_algorithm get_cc_algorithm() const;
+
 private:
   static int _connection_table_size;
   // TODO: make configurable
@@ -140,6 +143,8 @@ private:
   uint32_t _max_send_udp_payload_size_out = 0;
 
   uint32_t _disable_http_0_9 = 1;
+
+  uint32_t _cc_algorithm = 0;
 };
 
 class QUICConfig
diff --git a/src/iocore/net/QUICNetProcessor.cc 
b/src/iocore/net/QUICNetProcessor.cc
index 57322f504a..57fe6eeac6 100644
--- a/src/iocore/net/QUICNetProcessor.cc
+++ b/src/iocore/net/QUICNetProcessor.cc
@@ -34,8 +34,6 @@
 #include "iocore/net/quic/QUICConfig.h"
 #include "iocore/net/QUICMultiCertConfigLoader.h"
 
-#include 
-
 //
 // Global Data
 //
@@ -99,7 +97,7 @@ QUICNetProcessor::start(int, size_t stacksize)
   quiche_config_set_initial_max_streams_uni(this->_quiche_config, 
params->initial_max_streams_uni_in());
   quiche_config_set_disable_active_migration(this->_quiche_config, 
params->disable_active_migration());
   quiche_config_set_active_connection_id_limit(this->_quiche_config, 
params->active_cid_limit_in());
-  quiche_config_set_cc_algorithm(this->_quiche_config, QUICHE_CC_RENO);
+  quiche_config_set_cc_algorithm(this->_quiche_config, 
params->get_cc_algorithm());
 
 #ifdef TLS1_3_VERSION_DRAFT_TXT
   // FIXME: remove this when TLS1_3_VERSION_DRAFT_TXT is removed
diff --git a/src/iocore/net/quic/QUICConfig.cc 
b/src/iocore/net/quic/QUICConfig.cc
index cf6c8bc454..23d3c50b58 100644
--- a/src/iocore/net/quic/QUICConfig.cc
+++ b/src/iocore/net/quic/QUICConfig.cc
@@ -161,6 +161,7 @@ QUICConfigParams::initialize()
   REC_EstablishStaticConfigInt32U(this->_max_send_udp_payload_size_in, 
"proxy.config.quic.max_send_udp_payload_size_in");
   REC_EstablishStaticConfigInt32U(this->_max_send_udp_payload_size_out, 
"proxy.config.quic.max_send_udp_payload_size_out");
   REC_EstablishStaticConfigInt32U(this->_disable_http_0_9, 
"proxy.config.quic.disable_http_0_9");
+  REC_EstablishStaticConfigInt32U(this->_cc_algorithm, 
"proxy.config.quic.cc_algorithm");
 
   this->_client_ssl_ctx = quic_init_client_ssl_ctx(this);
 }
@@ -419,6 +420,19 @@ QUICConfigParams::disable_http_0_9() const
   return this->_disable_http_0_9;
 }
 
+quiche_cc_algorithm
+QUICConfigParams::get_cc_algorithm() const
+{
+  switch (this->_cc_algorithm) {
+  case 0:
+return QUICHE_CC_RENO;
+  case 1:
+return QUICHE_CC_CUBIC;
+  default:
+return QUICHE_CC_RENO;
+  }
+}
+
 //
 // QUICConfig
 //
diff --git a/src/records/RecordsConfig.cc b/src/records/RecordsConfig.cc
index 75ed50f58d..4173656c74 100644
--- a/src/records/RecordsConfig.cc
+++ b/src/records/RecordsConfig.cc
@@ -1422,6 +1422,8 @@ static const RecordElement RecordsConfig[] =
   ,
   {RECT_CONFIG, "proxy.config.quic.disable_http_0_9", RECD_INT, "1", 
RECU_DYNAMIC, RR_NULL, RECC_STR, "[0-1]", RECA_NULL}
   ,
+  {RECT_CONFIG, "proxy.config.quic.cc_algorithm", RECD_INT, "0", RECU_DYNAMIC, 
RR_NULL, RECC_STR, "[0-1]", 

(trafficserver) branch master updated (266debe2e8 -> ccf298988e)

2023-12-01 Thread rrm
This is an automated email from the ASF dual-hosted git repository.

rrm pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


from 266debe2e8 yapf: use yapf instead of autopep8 (#10860)
 add ccf298988e Minor an/a replacement in strategies.yaml (#10894)

No new revisions were added by this update.

Summary of changes:
 doc/admin-guide/files/strategies.yaml.en.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)



(trafficserver) branch master updated: Coverity 1523673: Resource leak in test_MMH (#10890)

2023-12-01 Thread bcall
This is an automated email from the ASF dual-hosted git repository.

bcall pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
 new 07020b1a5e Coverity 1523673: Resource leak in test_MMH (#10890)
07020b1a5e is described below

commit 07020b1a5e3d378af2e6160664c49a382b19e2c5
Author: Bryan Call 
AuthorDate: Fri Dec 1 08:31:50 2023 -0800

Coverity 1523673: Resource leak in test_MMH (#10890)
---
 src/tscore/unit_tests/test_MMH.cc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/tscore/unit_tests/test_MMH.cc 
b/src/tscore/unit_tests/test_MMH.cc
index 72781ec64e..d7756e3eff 100644
--- a/src/tscore/unit_tests/test_MMH.cc
+++ b/src/tscore/unit_tests/test_MMH.cc
@@ -152,4 +152,6 @@ TEST_CASE("MMH", "[libts][MMH]")
   ats_free(free_s1);
   ats_free(free_s2);
   ats_free(free_s3);
+
+  fclose(fp);
 }



(trafficserver) branch master updated: Coverity 1497333: Resource leak in object in LogConfig (#10891)

2023-12-01 Thread bcall
This is an automated email from the ASF dual-hosted git repository.

bcall pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
 new 84f3efe8cf Coverity 1497333: Resource leak in object in LogConfig 
(#10891)
84f3efe8cf is described below

commit 84f3efe8cf8f33434f4769e976b5bda09273a706
Author: Bryan Call 
AuthorDate: Fri Dec 1 08:31:29 2023 -0800

Coverity 1497333: Resource leak in object in LogConfig (#10891)

hostname wasn't freed and minor cleanup
---
 include/proxy/logging/LogConfig.h | 46 ++-
 include/proxy/logging/LogLimits.h |  4 ++--
 src/proxy/logging/LogConfig.cc| 40 --
 3 files changed, 27 insertions(+), 63 deletions(-)

diff --git a/include/proxy/logging/LogConfig.h 
b/include/proxy/logging/LogConfig.h
index 8a02bb1e49..3561fa5ade 100644
--- a/include/proxy/logging/LogConfig.h
+++ b/include/proxy/logging/LogConfig.h
@@ -158,7 +158,6 @@ public:
*/
   void register_rolled_log_auto_delete(std::string_view logname, int 
rolling_min_count);
 
-public:
   bool initialized = false;
   bool reconfiguration_needed  = false;
   bool logging_space_exhausted = false;
@@ -171,31 +170,31 @@ public:
   LogFilterList filter_list;
   LogFormatList format_list;
 
-  int log_buffer_size;
-  bool log_fast_buffer;
-  int max_secs_per_buffer;
-  int max_space_mb_for_logs;
-  int max_space_mb_headroom;
-  int logfile_perm;
+  uint32_t log_buffer_size  = 10 * LOG_KILOBYTE;
+  bool log_fast_buffer  = false;
+  int max_secs_per_buffer   = 5;
+  int max_space_mb_for_logs = 100;
+  int max_space_mb_headroom = 10;
+  int logfile_perm  = 0644;
 
-  int preproc_threads;
+  int preproc_threads = 1;
 
-  Log::RollingEnabledValues rolling_enabled;
-  int rolling_interval_sec;
-  int rolling_offset_hr;
-  int rolling_size_mb;
-  int rolling_min_count;
-  int rolling_max_count;
-  bool rolling_allow_empty;
-  bool auto_delete_rolled_files;
+  Log::RollingEnabledValues rolling_enabled = Log::NO_ROLLING;
+  int rolling_interval_sec  = 86400;
+  int rolling_offset_hr = 0;
+  int rolling_size_mb   = 10;
+  int rolling_min_count = 0;
+  int rolling_max_count = 0;
+  bool rolling_allow_empty  = false;
+  bool auto_delete_rolled_files = false;
 
-  int sampling_frequency;
-  int file_stat_frequency;
-  int space_used_frequency;
+  int sampling_frequency   = 1;
+  int file_stat_frequency  = 16;
+  int space_used_frequency = 900;
 
-  int ascii_buffer_size;
-  int max_line_size;
-  int logbuffer_max_iobuf_index;
+  int ascii_buffer_size = 4 * 9216;
+  int max_line_size = 9216;
+  int logbuffer_max_iobuf_index = BUFFER_SIZE_INDEX_32K;
 
   char *hostname   = nullptr;
   char *logfile_dir= nullptr;
@@ -204,9 +203,6 @@ public:
 private:
   bool evaluate_config();
 
-  void setup_default_values();
-
-private:
   bool m_disk_full  = false;
   bool m_disk_low   = false;
   bool m_partition_full = false;
diff --git a/include/proxy/logging/LogLimits.h 
b/include/proxy/logging/LogLimits.h
index d5e7505b94..568f19386c 100644
--- a/include/proxy/logging/LogLimits.h
+++ b/include/proxy/logging/LogLimits.h
@@ -34,5 +34,5 @@ enum {
   LOG_MAX_FORMATTED_LINE   = 10240
 };
 
-#define LOG_KILOBYTE ((int64_t)1024)
-#define LOG_MEGABYTE ((int64_t)1048576)
+constexpr int64_t LOG_KILOBYTE = 1024;
+constexpr int64_t LOG_MEGABYTE = 1048576;
diff --git a/src/proxy/logging/LogConfig.cc b/src/proxy/logging/LogConfig.cc
index 4ef25ef8cf..bd80f6b91c 100644
--- a/src/proxy/logging/LogConfig.cc
+++ b/src/proxy/logging/LogConfig.cc
@@ -66,40 +66,6 @@
 #define DIAGS_LOG_FILENAME"diags.log"
 #define MANAGER_LOG_FILENAME  "manager.log"
 
-void
-LogConfig::setup_default_values()
-{
-  hostname  = ats_strdup(Machine::instance()->host_name.c_str());
-  log_buffer_size   = static_cast(10 * LOG_KILOBYTE);
-  log_fast_buffer   = false;
-  max_secs_per_buffer   = 5;
-  max_space_mb_for_logs = 100;
-  max_space_mb_headroom = 10;
-  error_log_filename= ats_strdup("error.log");
-  logfile_perm  = 0644;
-  logfile_dir   = ats_strdup(".");
-
-  preproc_threads = 1;
-
-  rolling_enabled  = Log::NO_ROLLING;
-  rolling_interval_sec = 86400; // 24 hours
-  rolling_offset_hr= 0;
-  rolling_size_mb  = 10;
-  rolling_min_count= 0;
-  rolling_max_count= 0;
-  rolling_allow_empty  = false;
-  auto_delete_rolled_files = true;
-  roll_log_files_now   = false;
-
-  sampling_frequency   = 1;
-  file_stat_frequency  = 16;
-  space_used_frequency = 900;
-
-  ascii_buffer_size = 4 * 9216;
-  max_line_size = 9216; // size of pipe buffer for SunOS 5.6
-  

(trafficserver) branch master updated: ja3_fingerprint: add modify-incoming option (#10886)

2023-12-01 Thread bneradt
This is an automated email from the ASF dual-hosted git repository.

bneradt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
 new 8057371ea9 ja3_fingerprint: add modify-incoming option (#10886)
8057371ea9 is described below

commit 8057371ea9f40e0890ed62b76fb951a44fec8d54
Author: Brian Neradt 
AuthorDate: Fri Dec 1 16:09:17 2023 -0600

ja3_fingerprint: add modify-incoming option (#10886)

This adds the optional modify-incoming argument to the
ja3_fingerprint.so plugin. This argument alters the header modification
behavior to add the X-JA3-* headers to the incoming client request
rather than to the outgoing proxy request. This allows other plugins
later in the plugin.config file to view the added headers as if they
were added by the client, which can be helpful to some plugins.
---
 plugins/ja3_fingerprint/README | 10 +++
 plugins/ja3_fingerprint/ja3_fingerprint.cc | 85 --
 .../ja3_fingerprint/ja3_fingerprint.test.py| 46 +++-
 .../ja3_fingerprint/modify-incoming-client.gold| 10 +++
 .../ja3_fingerprint/modify-incoming-proxy.gold | 11 +++
 .../ja3_fingerprint/modify-sent-client.gold| 10 +++
 .../ja3_fingerprint/modify-sent-proxy.gold | 15 
 7 files changed, 145 insertions(+), 42 deletions(-)

diff --git a/plugins/ja3_fingerprint/README b/plugins/ja3_fingerprint/README
index 491a68bdff..7a9e5d9448 100644
--- a/plugins/ja3_fingerprint/README
+++ b/plugins/ja3_fingerprint/README
@@ -17,6 +17,16 @@ The following optional arguments can be used to configure 
the plugin's behavior:
 
 Add flag --ja3raw if `X-JA3-Raw` is desired in addition to `X-JA3-Sig`.
 Add flag --ja3log if local logging in standard logging directory is desired.
+Add flag --modify-incoming if it is desired that the plugin modify the incoming
+client request headers rather than the sent (proxy) request headers.
+Regardless, the origin will receive the configured `X-JA3-*` headers. Using
+this option allows other plugins that are configured later than
+`ja3_fingerprint.so` in the `plugin.config` file to see the `X-JA3-*`
+headers as if they were sent by the client.  This option is only applicable
+for ja3_fingerprint configured as a global plugin (i.e., a `plugin.config`
+plugin) not as a remap plugin.  This is because remap plugins by definition
+are enaged upon remap completion and by that point it is too late to
+meaningfully modify the client request headers.
 
 3. plugin.config
 In plugin.config, supply name of the plugin and any desired options. For 
example:
diff --git a/plugins/ja3_fingerprint/ja3_fingerprint.cc 
b/plugins/ja3_fingerprint/ja3_fingerprint.cc
index 82f081b64b..90e2c2b784 100644
--- a/plugins/ja3_fingerprint/ja3_fingerprint.cc
+++ b/plugins/ja3_fingerprint/ja3_fingerprint.cc
@@ -16,25 +16,19 @@
   limitations under the License.
  */
 
-#include 
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
 
-#include 
-#include 
-#include 
 #include 
 #include 
-#include 
 #include 
-#include 
 
+#include "ts/apidefs.h"
 #include "ts/ts.h"
 #include "ts/remap.h"
 
@@ -51,10 +45,11 @@
 
 const char *PLUGIN_NAME = "ja3_fingerprint";
 static DbgCtl dbg_ctl{PLUGIN_NAME};
-static TSTextLogObject pluginlog;
-static int ja3_idx= -1;
-static int enable_raw = 0;
-static int enable_log = 0;
+static TSTextLogObject pluginlog  = nullptr;
+static int ja3_idx= -1;
+static int global_raw_enabled = 0;
+static int global_log_enabled = 0;
+static int global_modify_incoming_enabled = 0;
 
 // GREASE table as in ja3
 static const std::unordered_set GREASE_table = {0x0a0a, 0x1a1a, 
0x2a2a, 0x3a3a, 0x4a4a, 0x5a5a, 0x6a6a, 0x7a7a,
@@ -67,9 +62,9 @@ struct ja3_data {
 };
 
 struct ja3_remap_info {
-  int raw= false;
-  int log= false;
-  TSCont handler = nullptr;
+  int raw_enabled = false;
+  int log_enabled = false;
+  TSCont handler  = nullptr;
 
   ~ja3_remap_info()
   {
@@ -259,6 +254,12 @@ client_hello_ja3_handler(TSCont contp, TSEvent event, void 
*edata)
 static int
 req_hdr_ja3_handler(TSCont contp, TSEvent event, void *edata)
 {
+  TSEvent expected_event = global_modify_incoming_enabled ? 
TS_EVENT_HTTP_READ_REQUEST_HDR : TS_EVENT_HTTP_SEND_REQUEST_HDR;
+  if (event != expected_event) {
+TSError("[%s] req_hdr_ja3_handler(): Unexpected event, got %d, expected 
%d", PLUGIN_NAME, event, expected_event);
+TSAssert(event == expected_event);
+  }
+
   TSHttpTxn txnp = nullptr;
   TSHttpSsn ssnp = nullptr;
   TSVConn vconn  = nullptr;
@@ -273,15 +274,19 @@ req_hdr_ja3_handler(TSCont contp, TSEvent event, void 
*edata)
   ja3_data *data = static_cast(TSUserArgGet(vconn, ja3_idx));
   if (data) {
 // Decide global or remap
-ja3_remap_info *info = 

(trafficserver) branch master updated: Fixing the git pre-commit hook for yapf (#10895)

2023-12-01 Thread bneradt
This is an automated email from the ASF dual-hosted git repository.

bneradt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
 new 947da7729d Fixing the git pre-commit hook for yapf (#10895)
947da7729d is described below

commit 947da7729d4f9ceffda7a283104b6ffdb3a18502
Author: Brian Neradt 
AuthorDate: Fri Dec 1 16:07:30 2023 -0600

Fixing the git pre-commit hook for yapf (#10895)

The REPO_ROOT calculation has to be updated for the pre-commit hook for
the yapf functionality.
---
 tools/git/pre-commit | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/git/pre-commit b/tools/git/pre-commit
index 33e9aaa26e..834ca7152d 100755
--- a/tools/git/pre-commit
+++ b/tools/git/pre-commit
@@ -63,7 +63,7 @@ trap "rm -f $clang_patch_file $yapf_patch_file 
$cmake_format_patch_file" 0 1 2 3
 
 # Loop over all files that are changed, and produce a diff file
 source ${YAPF_VENV}/bin/activate
-REPO_ROOT=$(cd $(dirname $0) && git rev-parse --show-toplevel)
+REPO_ROOT=$(cd $(dirname $0)/../.. && git rev-parse --show-toplevel)
 YAPF_CONFIG=${REPO_ROOT}/.style.yapf
 git diff-index --cached --diff-filter=ACMR --name-only HEAD | grep -vE 
"lib/(catch2|fastlz|swoc|yamlcpp)" | while read file; do
 case "$file" in