Validate target id

This commit is contained in:
Viktor Liu
2026-02-08 23:42:07 +08:00
parent 1c8f92a96f
commit 7f11e3205d
2 changed files with 41 additions and 0 deletions

View File

@@ -2,6 +2,7 @@ package reverseproxy
import (
"errors"
"fmt"
"net"
"net/url"
"strconv"
@@ -328,6 +329,15 @@ func (r *ReverseProxy) Validate() error {
return errors.New("at least one target is required")
}
for i, target := range r.Targets {
if target.TargetType != TargetTypePeer && target.TargetType != TargetTypeResource {
return fmt.Errorf("target %d has invalid target_type %q, must be %q or %q", i, target.TargetType, TargetTypePeer, TargetTypeResource)
}
if target.TargetId == "" {
return fmt.Errorf("target %d has empty target_id", i)
}
}
return nil
}