From dde0a4f2729d9c56c0b7c7581b77d98f8f46e108 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Tue, 4 Mar 2025 05:29:03 +0000 Subject: [PATCH] REALITY config: Add `password` as an alias of `publicKey` https://github.com/XTLS/Xray-core/issues/4458#issuecomment-2696181682 --- infra/conf/transport_internet.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 0de5bfcc..78bd76fe 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -502,6 +502,7 @@ type REALITYConfig struct { Fingerprint string `json:"fingerprint"` ServerName string `json:"serverName"` + Password string `json:"password"` PublicKey string `json:"publicKey"` ShortId string `json:"shortId"` SpiderX string `json:"spiderX"` @@ -610,11 +611,14 @@ func (c *REALITYConfig) Build() (proto.Message, error) { if len(c.ServerNames) != 0 { return nil, errors.New(`non-empty "serverNames", please use "serverName" instead`) } + if c.Password != "" { + c.PublicKey = c.Password + } if c.PublicKey == "" { - return nil, errors.New(`empty "publicKey"`) + return nil, errors.New(`empty "password"`) } if config.PublicKey, err = base64.RawURLEncoding.DecodeString(c.PublicKey); err != nil || len(config.PublicKey) != 32 { - return nil, errors.New(`invalid "publicKey": `, c.PublicKey) + return nil, errors.New(`invalid "password": `, c.PublicKey) } if len(c.ShortIds) != 0 { return nil, errors.New(`non-empty "shortIds", please use "shortId" instead`)