dbhat commented on a change in pull request #7516:
URL: https://github.com/apache/trafficserver/pull/7516#discussion_r590669690
##########
File path: plugins/header_rewrite/conditions.cc
##########
@@ -1333,4 +1333,77 @@ ConditionSessionTransactCount::append_value(std::string
&s, Resources const &res
TSDebug(PLUGIN_NAME, "Appending SSN-TXN-COUNT %s to evaluation value
%.*s", _qualifier.c_str(), length, value);
s.append(value, length);
}
-}
\ No newline at end of file
+}
+
+void
+ConditionTcpInfo::initialize(Parser &p)
+{
+ Condition::initialize(p);
+ TSDebug(PLUGIN_NAME, "Initializing TCP Info");
+ MatcherType *match = new MatcherType(_cond_op);
+ std::string const &arg = p.get_arg();
+
+ match->set(strtol(arg.c_str(), nullptr, 10));
+ _matcher = match;
+}
+
+void
+ConditionTcpInfo::initialize_hooks()
+{
+ add_allowed_hook(TS_HTTP_TXN_START_HOOK);
+ add_allowed_hook(TS_HTTP_TXN_CLOSE_HOOK);
+ add_allowed_hook(TS_HTTP_SEND_RESPONSE_HDR_HOOK);
+}
+
+bool
+ConditionTcpInfo::eval(const Resources &res)
+{
+ std::string s;
+
+ append_value(s, res);
+ bool rval = static_cast<const Matchers<std::string> *>(_matcher)->test(s);
+
+ TSDebug(PLUGIN_NAME, "Evaluating TCP-Info: %s - rval: %d", s.c_str(), rval);
+
+ return rval;
+}
+
+void
+ConditionTcpInfo::append_value(std::string &s, Resources const &res)
+{
+#if defined(TCP_INFO) && defined(HAVE_STRUCT_TCP_INFO)
Review comment:
Decided to keep the check and insert "-" when TCP_INFO is not available
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]