REALITY config: Add `target` as an alias of `dest`

https://t.me/projectXtls/364
This commit is contained in:
RPRX 2024-10-05 00:13:46 +00:00 committed by GitHub
parent c7534c4e36
commit 75729ce779
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -474,6 +474,7 @@ type REALITYConfig struct {
Show bool `json:"show"`
MasterKeyLog string `json:"masterKeyLog"`
Dest json.RawMessage `json:"dest"`
Target json.RawMessage `json:"target"`
Type string `json:"type"`
Xver uint64 `json:"xver"`
ServerNames []string `json:"serverNames"`
@ -495,6 +496,9 @@ func (c *REALITYConfig) Build() (proto.Message, error) {
config.Show = c.Show
config.MasterKeyLog = c.MasterKeyLog
var err error
if c.Dest == nil {
c.Dest = c.Target
}
if c.Dest != nil {
var i uint16
var s string
@ -522,7 +526,7 @@ func (c *REALITYConfig) Build() (proto.Message, error) {
}
}
if c.Type == "" {
return nil, errors.New(`please fill in a valid value for "dest"`)
return nil, errors.New(`please fill in a valid value for "dest" or "target"`)
}
if c.Xver > 2 {
return nil, errors.New(`invalid PROXY protocol version, "xver" only accepts 0, 1, 2`)