Skip to content

Commit 5ba56a3

Browse files
committed
BUG/MEDIUM: fix serialization of http-request sc-add-gpc and sc-inc-gpc
For sc-add-gpc, we were missing the int and exp field For sc-inc-gpc it was transformed into an sc-add-gpc
1 parent c145145 commit 5ba56a3

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

configuration/http_request_rule.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,15 +1133,22 @@ func SerializeHTTPRequestRule(f models.HTTPRequestRule, opt *options.Configurati
11331133
}
11341134
}
11351135
case "sc-add-gpc":
1136+
if len(f.ScExpr) > 0 && f.ScInt != nil {
1137+
return nil, NewConfError(ErrValidationError, "sc-add-gpc int and expr are exclusive")
1138+
}
1139+
if len(f.ScExpr) == 0 && f.ScInt == nil {
1140+
return nil, NewConfError(ErrValidationError, "sc-add-gpc int or expr has to be set")
1141+
}
11361142
rule = &actions.ScAddGpc{
11371143
ID: strconv.FormatInt(f.ScID, 10),
11381144
Idx: strconv.FormatInt(f.ScIdx, 10),
1145+
Int: f.ScInt,
1146+
Expr: common.Expression{Expr: strings.Split(f.ScExpr, " ")},
11391147
Cond: f.Cond,
11401148
CondTest: f.CondTest,
1141-
Comment: comment,
11421149
}
11431150
case "sc-inc-gpc":
1144-
rule = &actions.ScAddGpc{
1151+
rule = &actions.ScIncGpc{
11451152
ID: strconv.FormatInt(f.ScID, 10),
11461153
Idx: strconv.FormatInt(f.ScIdx, 10),
11471154
Cond: f.Cond,

0 commit comments

Comments
 (0)