You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by "bneradt (via GitHub)" <gi...@apache.org> on 2023/02/11 00:05:11 UTC

[GitHub] [trafficserver] bneradt commented on a diff in pull request #9358: tunnel_route: Support local inbound and proxy protocol ports

bneradt commented on code in PR #9358:
URL: https://github.com/apache/trafficserver/pull/9358#discussion_r1103410108


##########
iocore/net/P_SNIActionPerformer.h:
##########
@@ -89,12 +89,73 @@ class HTTP2BufferWaterMark : public ActionItem
 
 class TunnelDestination : public ActionItem
 {
+  // ID of the configured variable. This will be used to know which function
+  // should be called when processing the tunnel destination.
+  enum OpId : int32_t {
+    DEFAULT = -1,                 // No specific variable set.
+    MATCH_GROUPS,                 // Deal with configured groups.
+    MAP_WITH_RECV_PORT,           // Use port from inbound local
+    MAP_WITH_PROXY_PROTOCOL_PORT, // Use port from the proxy protocol
+    MAX                           // Always at the end and do not change the value of the above items.
+  };
+  const std::string MAP_WITH_RECV_PORT_STR           = "{inbound_local_port}";
+  const std::string MAP_WITH_PROXY_PROTOCOL_PORT_STR = "{proxy_protocol_port}";
+
 public:
   TunnelDestination(const std::string_view &dest, SNIRoutingType type, YamlSNIConfig::TunnelPreWarm prewarm,
                     const std::vector<int> &alpn)
     : destination(dest), type(type), tunnel_prewarm(prewarm), alpn_ids(alpn)
   {
-    need_fix = (destination.find_first_of('$') != std::string::npos);
+    std::size_t var_start_pos{0}; // keep the starting position of the variable.
+    if (destination.find_first_of('$') != std::string::npos) {
+      fnArrIndex = OpId::MATCH_GROUPS;
+    } else if (var_start_pos = destination.find(MAP_WITH_RECV_PORT_STR); var_start_pos != std::string::npos) {
+      fnArrIndex = OpId::MAP_WITH_RECV_PORT;
+    } else if (var_start_pos = destination.find(MAP_WITH_PROXY_PROTOCOL_PORT_STR); var_start_pos != std::string::npos) {
+      fnArrIndex = OpId::MAP_WITH_PROXY_PROTOCOL_PORT;
+    }
+

Review Comment:
   It's initialized to `OpId::DEFAULT` at line 273, which is -1. At line 170 this is checked.



-- 
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