dbhat commented on a change in pull request #7516:
URL: https://github.com/apache/trafficserver/pull/7516#discussion_r604630193
##########
File path: plugins/header_rewrite/conditions.cc
##########
@@ -1333,4 +1344,71 @@ 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)
+ TSReturnCode tsSsn;
+ int fd;
+ struct tcp_info info;
+ socklen_t tcp_info_len = sizeof(info);
+ tsSsn = TSHttpTxnClientFdGet(res.txnp, &fd);
+ if (tsSsn != TS_SUCCESS || fd <= 0) {
Review comment:
Implemented (a) as follows:
```
if (TSHttpTxnIsInternal(res.txnp) == 1) {
TSDebug(PLUGIN_NAME, "No TCP-INFO available for internal transactions");
return;
}
```
--
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]