Skip to content
This repository was archived by the owner on Sep 1, 2025. It is now read-only.

Commit 20a4eca

Browse files
committed
BUG/MINOR: tcp: fix parsing unknown tcp actions and add missing ones
1 parent 027124b commit 20a4eca

3 files changed

Lines changed: 13 additions & 3 deletions

File tree

parsers/tcp/types/connection.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Copyright 2019 HAProxy Technologies
33
44
Licensed under the Apache License, Version 2.0 (the "License");
5-
you may not use this file except in compliance with the License.
5+
you may not use this file 1cept in compliance with the License.
66
You may obtain a copy of the License at
77
88
http://www.apache.org/licenses/LICENSE-2.0
@@ -67,6 +67,8 @@ func (f *Connection) Parse(parts []string, comment string) error {
6767
err = f.ParseAction(&actions.TrackSc{}, parts)
6868
case "set-src":
6969
err = f.ParseAction(&tcpActions.SetSrc{}, parts)
70+
case "set-dst":
71+
err = f.ParseAction(&actions.SetDst{}, parts)
7072
case "silent-drop":
7173
err = f.ParseAction(&actions.SilentDrop{}, parts)
7274
case "set-mark":
@@ -75,6 +77,8 @@ func (f *Connection) Parse(parts []string, comment string) error {
7577
err = f.ParseAction(&actions.SetTos{}, parts)
7678
case "set-src-port":
7779
err = f.ParseAction(&actions.SetSrcPort{}, parts)
80+
case "set-dst-port":
81+
err = f.ParseAction(&actions.SetDstPort{}, parts)
7882
default:
7983
switch {
8084
case strings.HasPrefix(parts[2], "lua."):
@@ -85,8 +89,10 @@ func (f *Connection) Parse(parts []string, comment string) error {
8589
err = f.ParseAction(&actions.ScIncGpc1{}, parts)
8690
case strings.HasPrefix(parts[2], "sc-set-gpt0"):
8791
err = f.ParseAction(&actions.ScSetGpt0{}, parts)
88-
case strings.HasPrefix(parts[2], "set-var-fmt"):
89-
err = f.ParseAction(&actions.SetVarFmt{}, parts)
92+
case strings.HasPrefix(parts[2], "unset-var"):
93+
err = f.ParseAction(&actions.UnsetVar{}, parts)
94+
default:
95+
return fmt.Errorf("unsupported action %s", parts[2])
9096
}
9197
}
9298
return err

parsers/tcp/types/content.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ func (f *Content) Parse(parts []string, comment string) error { //nolint:gocyclo
109109
err = f.ParseAction(&actions.UnsetVar{}, parts)
110110
case strings.HasPrefix(parts[2], "do-resolve"):
111111
err = f.ParseAction(&actions.DoResolve{}, parts)
112+
default:
113+
return fmt.Errorf("unsupported action %s", parts[2])
112114
}
113115
}
114116
return err

parsers/tcp/types/session.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ func (f *Session) Parse(parts []string, comment string) error {
7575
err = f.ParseAction(&actions.SetVarFmt{}, parts)
7676
case strings.HasPrefix(parts[2], "unset-var"):
7777
err = f.ParseAction(&actions.UnsetVar{}, parts)
78+
default:
79+
return fmt.Errorf("unsupported action %s", parts[2])
7880
}
7981
}
8082
return err

0 commit comments

Comments
 (0)