Skip to content

Commit 77a7cef

Browse files
committed
BUG/MINOR: add missing rst-ttl option to relevant keywords
1 parent d6a7a84 commit 77a7cef

33 files changed

+660
-288
lines changed

config-parser/parsers/actions/silent-drop.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@ package actions
1818

1919
import (
2020
stderrors "errors"
21+
"strconv"
2122
"strings"
2223

2324
"github.com/haproxytech/client-native/v6/config-parser/common"
25+
"github.com/haproxytech/client-native/v6/config-parser/errors"
2426
"github.com/haproxytech/client-native/v6/config-parser/types"
2527
)
2628

2729
type SilentDrop struct {
30+
RstTTL int64
2831
Cond string
2932
CondTest string
3033
Comment string
@@ -44,17 +47,31 @@ func (f *SilentDrop) Parse(parts []string, parserType types.ParserType, comment
4447
case types.TCP:
4548
command = parts[3:]
4649
}
47-
_, condition := common.SplitRequest(command)
50+
command, condition := common.SplitRequest(command)
4851
if len(condition) > 1 {
4952
f.Cond = condition[0]
5053
f.CondTest = strings.Join(condition[1:], " ")
5154
}
55+
if len(command) > 0 && command[0] == "rst-ttl" {
56+
if len(command) <= 1 {
57+
return stderrors.New("missing rst-ttl value")
58+
}
59+
rstTTL, err := strconv.ParseInt(command[1], 10, 64)
60+
if err != nil {
61+
return &errors.ParseError{Parser: "SilentDrop", Message: err.Error()}
62+
}
63+
f.RstTTL = rstTTL
64+
}
5265
return nil
5366
}
5467

5568
func (f *SilentDrop) String() string {
5669
var result strings.Builder
5770
result.WriteString("silent-drop")
71+
if f.RstTTL > 0 {
72+
result.WriteString(" rst-ttl ")
73+
result.WriteString(strconv.FormatInt(f.RstTTL, 10))
74+
}
5875
if f.Cond != "" {
5976
result.WriteString(" ")
6077
result.WriteString(f.Cond)

config-parser/tests/configs/haproxy_generated.cfg.go

Lines changed: 50 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)