From 5f07a9fab99b62cbdc7cf934fdca6e4e5331be32 Mon Sep 17 00:00:00 2001 From: Helene Durand Date: Mon, 19 Feb 2024 16:17:10 +0100 Subject: [PATCH] BUG/MINOR: allow set-src and set-dst in tcp-request connection --- configuration/tcp_request_rule.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/configuration/tcp_request_rule.go b/configuration/tcp_request_rule.go index e8dd9691..71e21b94 100644 --- a/configuration/tcp_request_rule.go +++ b/configuration/tcp_request_rule.go @@ -26,6 +26,7 @@ import ( "github.com/haproxytech/config-parser/v5/common" parser_errors "github.com/haproxytech/config-parser/v5/errors" "github.com/haproxytech/config-parser/v5/parsers/actions" + http_actions "github.com/haproxytech/config-parser/v5/parsers/http/actions" tcp_actions "github.com/haproxytech/config-parser/v5/parsers/tcp/actions" tcp_types "github.com/haproxytech/config-parser/v5/parsers/tcp/types" "github.com/haproxytech/config-parser/v5/types" @@ -784,6 +785,22 @@ func SerializeTCPRequestRule(f models.TCPRequestRule) (rule types.TCPType, err e CondTest: f.CondTest, }, }, nil + case models.TCPRequestRuleActionSetDashSrc: + return &tcp_types.Connection{ + Action: &http_actions.SetSrc{ + Expr: common.Expression{Expr: strings.Split(f.Expr, " ")}, + Cond: f.Cond, + CondTest: f.CondTest, + }, + }, nil + case models.TCPRequestRuleActionSetDashDst: + return &tcp_types.Connection{ + Action: &actions.SetDst{ + Expr: common.Expression{Expr: strings.Split(f.Expr, " ")}, + Cond: f.Cond, + CondTest: f.CondTest, + }, + }, nil } return nil, NewConfError(ErrValidationError, fmt.Sprintf("unsupported action '%T' in tcp_request_rule", f.Action)) case models.TCPRequestRuleTypeContent: