From: Christopher Faulet Date: Wed, 23 Jun 2021 10:07:21 +0000 (+0200) Subject: MINOR: tcp-act: Add set-src/set-src-port for "tcp-request content" rules X-Git-Tag: v2.5-dev1~46 X-Git-Url: http://git.haproxy.org/?a=commitdiff_plain;h=19bbbe05629ea947dd60d5b96d96f0066b047b97;p=haproxy-2.5.git MINOR: tcp-act: Add set-src/set-src-port for "tcp-request content" rules If it possible to set source IP/Port from "tcp-request connection", "tcp-request session" and "http-request" rules but not from "tcp-request content" rules. There is no reason for this limitation and it may be a problem for anyone wanting to call a lua fetch to dynamically set source IP/Port from a TCP proxy. Indeed, to call a lua fetch, we must have a stream. And there is no stream when "tcp-request connection/session" rules are evaluated. Thanks to this patch, "set-src" and "set-src-port" action are now supported by "tcp_request content" rules. This patch is related to the issue #1303. It may be backported to all stable versions. --- diff --git a/doc/configuration.txt b/doc/configuration.txt index 4dd8fae..10a1948 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -12056,6 +12056,8 @@ tcp-request content [{if | unless} ] - sc-set-gpt0() { | } - set-dst - set-dst-port + - set-src + - set-src-port - set-var() - switch-mode http [ proto ] - unset-var() @@ -12106,6 +12108,9 @@ tcp-request content [{if | unless} ] The "set-dst" and "set-dst-port" are used to set respectively the destination IP and port. More information on how to use it at "http-request set-dst". + The "set-src" and "set-src-port" are used to set respectively the source IP + and port. More information on how to use it at "http-request set-src". + The "set-var" is used to set the content of a variable. The variable is declared inline. For "tcp-request session" rules, only session-level variables can be used, without any layer7 contents. diff --git a/src/tcp_act.c b/src/tcp_act.c index d55475c..a6f0596 100644 --- a/src/tcp_act.c +++ b/src/tcp_act.c @@ -318,6 +318,8 @@ static struct action_kw_list tcp_req_sess_actions = {ILH, { INITCALL1(STG_REGISTER, tcp_req_sess_keywords_register, &tcp_req_sess_actions); static struct action_kw_list tcp_req_cont_actions = {ILH, { + { "set-src", tcp_parse_set_src_dst }, + { "set-src-port", tcp_parse_set_src_dst }, { "set-dst" , tcp_parse_set_src_dst }, { "set-dst-port", tcp_parse_set_src_dst }, { "silent-drop", tcp_parse_silent_drop },