From d2ead10ddf831a054796254df23ab7c9c9000f26 Mon Sep 17 00:00:00 2001 From: cubemaze Date: Wed, 19 Jul 2023 23:41:42 +0800 Subject: [PATCH] fix: wrong typo --- api/panel/node.go | 12 ++++++------ core/xray/inbound.go | 11 +++++++---- core/xray/user.go | 2 +- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/api/panel/node.go b/api/panel/node.go index 0519a8d..6089eeb 100644 --- a/api/panel/node.go +++ b/api/panel/node.go @@ -72,20 +72,20 @@ type NodeInfo struct { } type V2rayExtraConfig struct { - EnableVless bool `json:"EnableVless"` + EnableVless string `json:"EnableVless"` VlessFlow string `json:"VlessFlow"` - EnableReality bool `json:"EnableReality"` + EnableReality string `json:"EnableReality"` RealityConfig *RealityConfig `json:"RealityConfig"` } type RealityConfig struct { Dest interface{} `yaml:"Dest" json:"Dest"` - Xver uint64 `yaml:"Xver" json:"Xver"` + Xver string `yaml:"Xver" json:"Xver"` ServerNames []string `yaml:"ServerNames" json:"ServerNames"` PrivateKey string `yaml:"PrivateKey" json:"PrivateKey"` MinClientVer string `yaml:"MinClientVer" json:"MinClientVer"` MaxClientVer string `yaml:"MaxClientVer" json:"MaxClientVer"` - MaxTimeDiff uint64 `yaml:"MaxTimeDiff" json:"MaxTimeDiff"` + MaxTimeDiff string `yaml:"MaxTimeDiff" json:"MaxTimeDiff"` ShortIds []string `yaml:"ShortIds" json:"ShortIds"` } @@ -155,9 +155,9 @@ func (c *Client) GetNodeInfo() (node *NodeInfo, err error) { if err != nil { return nil, fmt.Errorf("decode v2ray extra error: %s", err) } - if node.ExtraConfig.EnableReality { + if node.ExtraConfig.EnableReality == "true" { if node.ExtraConfig.RealityConfig == nil { - node.ExtraConfig.EnableReality = false + node.ExtraConfig.EnableReality = "false" } else { key := crypt.GenX25519Private([]byte(strconv.Itoa(c.NodeId) + c.NodeType + c.Token + node.ExtraConfig.RealityConfig.PrivateKey)) diff --git a/core/xray/inbound.go b/core/xray/inbound.go index acf0560..4f6cbe6 100644 --- a/core/xray/inbound.go +++ b/core/xray/inbound.go @@ -6,6 +6,7 @@ import ( "encoding/hex" "errors" "fmt" + "strconv" "github.com/Yuzuki616/V2bX/api/panel" "github.com/Yuzuki616/V2bX/conf" @@ -90,21 +91,23 @@ func buildInbound(config *conf.ControllerConfig, nodeInfo *panel.NodeInfo, tag s } case "remote": default: - if nodeInfo.ExtraConfig.EnableReality { + if nodeInfo.ExtraConfig.EnableReality == "true" { rc := nodeInfo.ExtraConfig.RealityConfig in.StreamSetting.Security = "reality" d, err := json.Marshal(rc.Dest) if err != nil { return nil, fmt.Errorf("marshal reality dest error: %s", err) } + Xver, _ := strconv.ParseUint(rc.Xver, 10, 64) + MaxTimeDiff, _ := strconv.ParseUint(rc.Xver, 10, 64) in.StreamSetting.REALITYSettings = &coreConf.REALITYConfig{ Dest: d, - Xver: rc.Xver, + Xver: Xver, ServerNames: rc.ServerNames, PrivateKey: rc.PrivateKey, MinClientVer: rc.MinClientVer, MaxClientVer: rc.MaxClientVer, - MaxTimeDiff: rc.MaxTimeDiff, + MaxTimeDiff: MaxTimeDiff, ShortIds: rc.ShortIds, } } else { @@ -138,7 +141,7 @@ func buildInbound(config *conf.ControllerConfig, nodeInfo *panel.NodeInfo, tag s } func buildV2ray(config *conf.ControllerConfig, nodeInfo *panel.NodeInfo, inbound *coreConf.InboundDetourConfig) error { - if nodeInfo.ExtraConfig.EnableVless { + if nodeInfo.ExtraConfig.EnableVless == "true" { //Set vless inbound.Protocol = "vless" if config.XrayOptions.EnableFallback { diff --git a/core/xray/user.go b/core/xray/user.go index f76f009..86d1f36 100644 --- a/core/xray/user.go +++ b/core/xray/user.go @@ -74,7 +74,7 @@ func (c *Core) AddUsers(p *vCore.AddUsersParams) (added int, err error) { users := make([]*protocol.User, 0, len(p.UserInfo)) switch p.NodeInfo.Type { case "v2ray": - if p.NodeInfo.ExtraConfig.EnableVless { + if p.NodeInfo.ExtraConfig.EnableVless == "true" { users = buildVlessUsers(p.Tag, p.UserInfo, p.NodeInfo.ExtraConfig.VlessFlow) } else { users = buildVmessUsers(p.Tag, p.UserInfo)