header-custom finalmask: Add UDP standalone handshake mode (#5945)

175502d807
This commit is contained in:
Иван
2026-04-15 23:21:23 +07:00
committed by GitHub
parent 175502d807
commit 05e259c8e4
13 changed files with 886 additions and 6 deletions

View File

@@ -1657,11 +1657,18 @@ func buildCustomTransformArg(arg CustomTransformArg) (*custom.ExprArg, error) {
}
type HeaderCustomUDP struct {
Mode string `json:"mode"`
Client []UDPItem `json:"client"`
Server []UDPItem `json:"server"`
}
func (c *HeaderCustomUDP) Build() (proto.Message, error) {
switch c.Mode {
case "", "prefix", "standalone":
default:
return nil, errors.New("unknown udp mode")
}
for _, item := range c.Client {
if err := validateCustomItemSpec(item.Capture, item.Packet, item.Rand, item.Reuse, item.Transform); err != nil {
return nil, err
@@ -1730,6 +1737,7 @@ func (c *HeaderCustomUDP) Build() (proto.Message, error) {
return &custom.UDPConfig{
Client: client,
Server: server,
Mode: c.Mode,
}, nil
}

View File

@@ -191,10 +191,12 @@ func TestHeaderCustomUDPBuild(t *testing.T) {
{
"reuse": "txid"
}
]
],
"mode": "standalone"
}`,
Parser: parser,
Output: &finalmaskcustom.UDPConfig{
Mode: "standalone",
Client: []*finalmaskcustom.UDPItem{
{
RandMax: 255,