@@ -340,6 +340,20 @@ func ParseTCPRequestRule(f types.TCPType) (rule *models.TCPRequestRule, err erro
340340 rule .Expr = a .Expr .String ()
341341 rule .Cond = a .Cond
342342 rule .CondTest = a .CondTest
343+ case * actions.SetVar :
344+ rule .Action = models .TCPRequestRuleActionSetDashVar
345+ rule .VarScope = a .VarScope
346+ rule .VarName = a .VarName
347+ rule .Expr = a .Expr .String ()
348+ rule .Cond = a .Cond
349+ rule .CondTest = a .CondTest
350+ case * actions.SetVarFmt :
351+ rule .Action = models .TCPRequestRuleActionSetDashVarDashFmt
352+ rule .VarName = a .VarName
353+ rule .VarFormat = strings .Join (a .Fmt .Expr , " " )
354+ rule .VarScope = a .VarScope
355+ rule .Cond = a .Cond
356+ rule .CondTest = a .CondTest
343357 case * actions.UnsetVar :
344358 rule .Action = models .TCPRequestRuleActionUnsetDashVar
345359 rule .VarScope = a .Scope
@@ -380,12 +394,12 @@ func ParseTCPRequestRule(f types.TCPType) (rule *models.TCPRequestRule, err erro
380394 rule .Cond = a .Cond
381395 rule .CondTest = a .CondTest
382396 case * actions.SetPriorityClass :
383- rule .Action = "set-priority-class"
397+ rule .Action = models . TCPRequestRuleActionSetDashPriorityDashClass
384398 rule .Expr = a .Expr .String ()
385399 rule .Cond = a .Cond
386400 rule .CondTest = a .CondTest
387401 case * actions.SetPriorityOffset :
388- rule .Action = "set-priority-offset"
402+ rule .Action = models . TCPRequestRuleActionSetDashPriorityDashOffset
389403 rule .Expr = a .Expr .String ()
390404 rule .Cond = a .Cond
391405 rule .CondTest = a .CondTest
@@ -439,6 +453,16 @@ func ParseTCPRequestRule(f types.TCPType) (rule *models.TCPRequestRule, err erro
439453 rule .Expr = a .Expr .String ()
440454 rule .Cond = a .Cond
441455 rule .CondTest = a .CondTest
456+ case * tcp_actions.SetSrc :
457+ rule .Action = models .TCPRequestRuleActionSetDashSrc
458+ rule .Expr = a .Expr .String ()
459+ rule .Cond = a .Cond
460+ rule .CondTest = a .CondTest
461+ case * actions.SetSrcPort :
462+ rule .Action = models .TCPRequestRuleActionSetDashSrcDashPort
463+ rule .Expr = a .Expr .String ()
464+ rule .Cond = a .Cond
465+ rule .CondTest = a .CondTest
442466 case * actions.SetVar :
443467 rule .Action = models .TCPRequestRuleActionSetDashVar
444468 rule .VarScope = a .VarScope
@@ -485,11 +509,6 @@ func ParseTCPRequestRule(f types.TCPType) (rule *models.TCPRequestRule, err erro
485509 rule .MarkValue = a .Value
486510 rule .Cond = a .Cond
487511 rule .CondTest = a .CondTest
488- case * actions.SetSrcPort :
489- rule .Action = models .TCPRequestRuleActionSetDashSrcDashPort
490- rule .Expr = a .Expr .String ()
491- rule .Cond = a .Cond
492- rule .CondTest = a .CondTest
493512 case * actions.SetTos :
494513 rule .Action = models .TCPRequestRuleActionSetDashTos
495514 rule .TosValue = a .Value
@@ -576,6 +595,36 @@ func ParseTCPRequestRule(f types.TCPType) (rule *models.TCPRequestRule, err erro
576595 rule .GptValue = a .Expr .String ()
577596 rule .Cond = a .Cond
578597 rule .CondTest = a .CondTest
598+ case * actions.SetDst :
599+ rule .Action = models .TCPRequestRuleActionSetDashDst
600+ rule .Expr = a .Expr .String ()
601+ rule .Cond = a .Cond
602+ rule .CondTest = a .CondTest
603+ case * actions.SetDstPort :
604+ rule .Action = models .TCPRequestRuleActionSetDashDstDashPort
605+ rule .Expr = a .Expr .String ()
606+ rule .Cond = a .Cond
607+ rule .CondTest = a .CondTest
608+ case * actions.SetMark :
609+ rule .Action = models .TCPRequestRuleActionSetDashMark
610+ rule .MarkValue = a .Value
611+ rule .Cond = a .Cond
612+ rule .CondTest = a .CondTest
613+ case * tcp_actions.SetSrc :
614+ rule .Action = models .TCPRequestRuleActionSetDashSrc
615+ rule .Expr = a .Expr .String ()
616+ rule .Cond = a .Cond
617+ rule .CondTest = a .CondTest
618+ case * actions.SetSrcPort :
619+ rule .Action = models .TCPRequestRuleActionSetDashSrcDashPort
620+ rule .Expr = a .Expr .String ()
621+ rule .Cond = a .Cond
622+ rule .CondTest = a .CondTest
623+ case * actions.SetTos :
624+ rule .Action = models .TCPRequestRuleActionSetDashTos
625+ rule .TosValue = a .Value
626+ rule .Cond = a .Cond
627+ rule .CondTest = a .CondTest
579628 case * actions.SetVar :
580629 rule .Action = models .TCPRequestRuleActionSetDashVar
581630 rule .VarScope = a .VarScope
@@ -589,6 +638,13 @@ func ParseTCPRequestRule(f types.TCPType) (rule *models.TCPRequestRule, err erro
589638 rule .VarName = a .Name
590639 rule .Cond = a .Cond
591640 rule .CondTest = a .CondTest
641+ case * actions.SetVarFmt :
642+ rule .Action = models .TCPRequestRuleActionSetDashVarDashFmt
643+ rule .VarName = a .VarName
644+ rule .VarFormat = strings .Join (a .Fmt .Expr , " " )
645+ rule .VarScope = a .VarScope
646+ rule .Cond = a .Cond
647+ rule .CondTest = a .CondTest
592648 case * actions.SilentDrop :
593649 rule .Action = models .TCPRequestRuleActionSilentDashDrop
594650 rule .Cond = a .Cond
@@ -775,6 +831,25 @@ func SerializeTCPRequestRule(f models.TCPRequestRule) (rule types.TCPType, err e
775831 CondTest : f .CondTest ,
776832 },
777833 }, nil
834+ case models .TCPRequestRuleActionSetDashVar :
835+ return & tcp_types.Connection {
836+ Action : & actions.SetVar {
837+ VarName : f .VarName ,
838+ VarScope : f .VarScope ,
839+ Expr : common.Expression {Expr : strings .Split (f .Expr , " " )},
840+ Cond : f .Cond ,
841+ CondTest : f .CondTest ,
842+ },
843+ }, nil
844+ case models .TCPRequestRuleActionUnsetDashVar :
845+ return & tcp_types.Connection {
846+ Action : & actions.UnsetVar {
847+ Name : f .VarName ,
848+ Scope : f .VarScope ,
849+ Cond : f .Cond ,
850+ CondTest : f .CondTest ,
851+ },
852+ }, nil
778853 case models .TCPRequestRuleActionSetDashVarDashFmt :
779854 return & tcp_types.Connection {
780855 Action : & actions.SetVarFmt {
@@ -801,6 +876,14 @@ func SerializeTCPRequestRule(f models.TCPRequestRule) (rule types.TCPType, err e
801876 CondTest : f .CondTest ,
802877 },
803878 }, nil
879+ case models .TCPRequestRuleActionSetDashDstDashPort :
880+ return & tcp_types.Connection {
881+ Action : & actions.SetDstPort {
882+ Expr : common.Expression {Expr : strings .Split (f .Expr , " " )},
883+ Cond : f .Cond ,
884+ CondTest : f .CondTest ,
885+ },
886+ }, nil
804887 }
805888 return nil , NewConfError (ErrValidationError , fmt .Sprintf ("unsupported action '%s' in tcp_request_rule" , f .Action ))
806889 case models .TCPRequestRuleTypeContent :
@@ -839,15 +922,15 @@ func SerializeTCPRequestRule(f models.TCPRequestRule) (rule types.TCPType, err e
839922 CondTest : f .CondTest ,
840923 },
841924 }, nil
842- case "set-priority-class" :
925+ case models . TCPRequestRuleActionSetDashPriorityDashClass :
843926 return & tcp_types.Content {
844927 Action : & actions.SetPriorityClass {
845928 Expr : common.Expression {Expr : strings .Split (f .Expr , " " )},
846929 Cond : f .Cond ,
847930 CondTest : f .CondTest ,
848931 },
849932 }, nil
850- case "set-priority-offset" :
933+ case models . TCPRequestRuleActionSetDashPriorityDashOffset :
851934 return & tcp_types.Content {
852935 Action : & actions.SetPriorityOffset {
853936 Expr : common.Expression {Expr : strings .Split (f .Expr , " " )},
@@ -903,7 +986,7 @@ func SerializeTCPRequestRule(f models.TCPRequestRule) (rule types.TCPType, err e
903986 },
904987 }, nil
905988 case models .TCPRequestRuleActionScDashAddDashGpc :
906- return & tcp_types.Connection {
989+ return & tcp_types.Content {
907990 Action : & actions.ScAddGpc {
908991 ID : f .ScIncID ,
909992 Idx : f .ScIdx ,
@@ -914,7 +997,7 @@ func SerializeTCPRequestRule(f models.TCPRequestRule) (rule types.TCPType, err e
914997 },
915998 }, nil
916999 case models .TCPRequestRuleActionScDashIncDashGpc :
917- return & tcp_types.Connection {
1000+ return & tcp_types.Content {
9181001 Action : & actions.ScIncGpc {
9191002 ID : f .ScIncID ,
9201003 Idx : f .ScIdx ,
@@ -939,7 +1022,7 @@ func SerializeTCPRequestRule(f models.TCPRequestRule) (rule types.TCPType, err e
9391022 },
9401023 }, nil
9411024 case models .TCPRequestRuleActionScDashSetDashGpt0 :
942- return & tcp_types.Connection {
1025+ return & tcp_types.Content {
9431026 Action : & actions.ScSetGpt0 {
9441027 ID : f .ScIncID ,
9451028 Expr : common.Expression {Expr : strings .Split (f .Expr , " " )},
@@ -963,6 +1046,14 @@ func SerializeTCPRequestRule(f models.TCPRequestRule) (rule types.TCPType, err e
9631046 CondTest : f .CondTest ,
9641047 },
9651048 }, nil
1049+ case models .TCPRequestRuleActionSetDashSrc :
1050+ return & tcp_types.Content {
1051+ Action : & http_actions.SetSrc {
1052+ Expr : common.Expression {Expr : strings .Split (f .Expr , " " )},
1053+ Cond : f .Cond ,
1054+ CondTest : f .CondTest ,
1055+ },
1056+ }, nil
9661057 case models .TCPRequestRuleActionSetDashVar :
9671058 return & tcp_types.Content {
9681059 Action : & actions.SetVar {
@@ -1026,31 +1117,31 @@ func SerializeTCPRequestRule(f models.TCPRequestRule) (rule types.TCPType, err e
10261117 },
10271118 }, nil
10281119 case models .TCPRequestRuleActionSetDashMark :
1029- return & tcp_types.Connection {
1120+ return & tcp_types.Content {
10301121 Action : & actions.SetMark {
10311122 Value : f .MarkValue ,
10321123 Cond : f .Cond ,
10331124 CondTest : f .CondTest ,
10341125 },
10351126 }, nil
10361127 case models .TCPRequestRuleActionSetDashSrcDashPort :
1037- return & tcp_types.Connection {
1128+ return & tcp_types.Content {
10381129 Action : & actions.SetSrcPort {
10391130 Expr : common.Expression {Expr : strings .Split (f .Expr , " " )},
10401131 Cond : f .Cond ,
10411132 CondTest : f .CondTest ,
10421133 },
10431134 }, nil
10441135 case models .TCPRequestRuleActionSetDashTos :
1045- return & tcp_types.Connection {
1136+ return & tcp_types.Content {
10461137 Action : & actions.SetTos {
10471138 Value : f .TosValue ,
10481139 Cond : f .Cond ,
10491140 CondTest : f .CondTest ,
10501141 },
10511142 }, nil
10521143 case models .TCPRequestRuleActionSetDashVarDashFmt :
1053- return & tcp_types.Connection {
1144+ return & tcp_types.Content {
10541145 Action : & actions.SetVarFmt {
10551146 Fmt : common.Expression {Expr : strings .Split (f .VarFormat , " " )},
10561147 VarName : f .VarName ,
@@ -1060,23 +1151,23 @@ func SerializeTCPRequestRule(f models.TCPRequestRule) (rule types.TCPType, err e
10601151 },
10611152 }, nil
10621153 case models .TCPRequestRuleActionSetDashNice :
1063- return & tcp_types.Connection {
1154+ return & tcp_types.Content {
10641155 Action : & actions.SetNice {
10651156 Value : strconv .FormatInt (f .NiceValue , 10 ),
10661157 Cond : f .Cond ,
10671158 CondTest : f .CondTest ,
10681159 },
10691160 }, nil
10701161 case models .TCPRequestRuleActionSetDashLogDashLevel :
1071- return & tcp_types.Connection {
1162+ return & tcp_types.Content {
10721163 Action : & actions.SetLogLevel {
10731164 Level : f .LogLevel ,
10741165 Cond : f .Cond ,
10751166 CondTest : f .CondTest ,
10761167 },
10771168 }, nil
10781169 case models .TCPRequestRuleActionSwitchDashMode :
1079- return & tcp_types.Connection {
1170+ return & tcp_types.Content {
10801171 Action : & tcp_actions.SwitchMode {
10811172 Proto : f .SwitchModeProto ,
10821173 Cond : f .Cond ,
@@ -1184,24 +1275,63 @@ func SerializeTCPRequestRule(f models.TCPRequestRule) (rule types.TCPType, err e
11841275 CondTest : f .CondTest ,
11851276 },
11861277 }, nil
1187- case "sc-inc-gpt0" :
1278+ case models . TCPRequestRuleActionScDashSetDashGpt0 :
11881279 return & tcp_types.Session {
11891280 Action : & actions.ScSetGpt0 {
11901281 ID : f .ScIncID ,
1191- Expr : common.Expression {Expr : [] string { f . GptValue } },
1282+ Expr : common.Expression {Expr : strings . Split ( f . Expr , " " ) },
11921283 Cond : f .Cond ,
11931284 CondTest : f .CondTest ,
11941285 },
11951286 }, nil
1196- case models .TCPRequestRuleActionScDashSetDashGpt0 :
1197- return & tcp_types.Connection {
1198- Action : & actions.ScSetGpt0 {
1199- ID : f .ScIncID ,
1287+ case models .TCPRequestRuleActionSetDashDst :
1288+ return & tcp_types.Session {
1289+ Action : & actions.SetDst {
1290+ Expr : common.Expression {Expr : strings .Split (f .Expr , " " )},
1291+ Cond : f .Cond ,
1292+ CondTest : f .CondTest ,
1293+ },
1294+ }, nil
1295+ case models .TCPRequestRuleActionSetDashDstDashPort :
1296+ return & tcp_types.Session {
1297+ Action : & actions.SetDstPort {
1298+ Expr : common.Expression {Expr : strings .Split (f .Expr , " " )},
1299+ Cond : f .Cond ,
1300+ CondTest : f .CondTest ,
1301+ },
1302+ }, nil
1303+ case models .TCPRequestRuleActionSetDashSrc :
1304+ return & tcp_types.Session {
1305+ Action : & http_actions.SetSrc {
12001306 Expr : common.Expression {Expr : strings .Split (f .Expr , " " )},
12011307 Cond : f .Cond ,
12021308 CondTest : f .CondTest ,
12031309 },
12041310 }, nil
1311+ case models .TCPRequestRuleActionSetDashSrcDashPort :
1312+ return & tcp_types.Session {
1313+ Action : & actions.SetSrcPort {
1314+ Expr : common.Expression {Expr : strings .Split (f .Expr , " " )},
1315+ Cond : f .Cond ,
1316+ CondTest : f .CondTest ,
1317+ },
1318+ }, nil
1319+ case models .TCPRequestRuleActionSetDashMark :
1320+ return & tcp_types.Session {
1321+ Action : & actions.SetDstPort {
1322+ Expr : common.Expression {Expr : strings .Split (f .Expr , " " )},
1323+ Cond : f .Cond ,
1324+ CondTest : f .CondTest ,
1325+ },
1326+ }, nil
1327+ case models .TCPRequestRuleActionSetDashTos :
1328+ return & tcp_types.Session {
1329+ Action : & actions.SetTos {
1330+ Value : f .TosValue ,
1331+ Cond : f .Cond ,
1332+ CondTest : f .CondTest ,
1333+ },
1334+ }, nil
12051335 case models .TCPRequestRuleActionSetDashVar :
12061336 return & tcp_types.Session {
12071337 Action : & actions.SetVar {
@@ -1221,6 +1351,16 @@ func SerializeTCPRequestRule(f models.TCPRequestRule) (rule types.TCPType, err e
12211351 CondTest : f .CondTest ,
12221352 },
12231353 }, nil
1354+ case models .TCPRequestRuleActionSetDashVarDashFmt :
1355+ return & tcp_types.Session {
1356+ Action : & actions.SetVarFmt {
1357+ Fmt : common.Expression {Expr : strings .Split (f .VarFormat , " " )},
1358+ VarName : f .VarName ,
1359+ VarScope : f .VarScope ,
1360+ Cond : f .Cond ,
1361+ CondTest : f .CondTest ,
1362+ },
1363+ }, nil
12241364 case models .TCPRequestRuleActionSilentDashDrop :
12251365 return & tcp_types.Session {
12261366 Action : & actions.SilentDrop {
0 commit comments