From 62d280590628d11c6294da12d2eb57ab09272d45 Mon Sep 17 00:00:00 2001 From: yuzuki999 Date: Mon, 22 May 2023 11:20:09 +0800 Subject: [PATCH] fix bug for reality dest --- conf/conf_test.go | 7 +++++++ conf/node.go | 18 ++++++++---------- example/config.yml.example | 2 +- node/inbound.go | 6 +++++- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/conf/conf_test.go b/conf/conf_test.go index 8f52a95..3f8404a 100644 --- a/conf/conf_test.go +++ b/conf/conf_test.go @@ -1 +1,8 @@ package conf + +import "testing" + +func TestConf_LoadFromPath(t *testing.T) { + c := New() + t.Log(c.LoadFromPath("../example/config.yml.example")) +} diff --git a/conf/node.go b/conf/node.go index 40b2da9..f5e2e72 100644 --- a/conf/node.go +++ b/conf/node.go @@ -1,7 +1,5 @@ package conf -import "github.com/goccy/go-json" - type NodeConfig struct { ApiConfig *ApiConfig `yaml:"ApiConfig"` ControllerConfig *ControllerConfig `yaml:"ControllerConfig"` @@ -95,12 +93,12 @@ type CertConfig struct { } type RealityConfig struct { - Dest json.RawMessage `yaml:"Dest"` - Xver uint64 `yaml:"Xver"` - ServerNames []string `yaml:"ServerNames"` - PrivateKey string `yaml:"PrivateKey"` - MinClientVer string `yaml:"MinClientVer"` - MaxClientVer string `yaml:"MaxClientVer"` - MaxTimeDiff uint64 `yaml:"MaxTimeDiff"` - ShortIds []string `yaml:"ShortIds"` + Dest interface{} `yaml:"Dest"` + Xver uint64 `yaml:"Xver"` + ServerNames []string `yaml:"ServerNames"` + PrivateKey string `yaml:"PrivateKey"` + MinClientVer string `yaml:"MinClientVer"` + MaxClientVer string `yaml:"MaxClientVer"` + MaxTimeDiff uint64 `yaml:"MaxTimeDiff"` + ShortIds []string `yaml:"ShortIds"` } diff --git a/example/config.yml.example b/example/config.yml.example index e47cef0..ee9db2c 100644 --- a/example/config.yml.example +++ b/example/config.yml.example @@ -31,7 +31,7 @@ Nodes: EnableReality: false # Enable reality RealityConfig: # This config like RealityObject for xray-core, please check https://xtls.github.io/config/transport.html#realityobject Dest: 80 # Same fallback dest - Xver: "example.com:443" # Same fallback xver + Xver: 0 # Same fallback xver ServerNames: - "example.com" - "www.example.com" diff --git a/node/inbound.go b/node/inbound.go index ae94b70..d8ae9fc 100644 --- a/node/inbound.go +++ b/node/inbound.go @@ -86,8 +86,12 @@ func BuildInbound(config *conf.ControllerConfig, nodeInfo *panel.NodeInfo, tag s } else if config.EnableReality { // Reality inbound.StreamSetting.Security = "reality" + d, err := json.Marshal(config.RealityConfig.Dest) + if err != nil { + return nil, fmt.Errorf("marshal reality dest error: %s", err) + } inbound.StreamSetting.REALITYSettings = &coreConf.REALITYConfig{ - Dest: config.RealityConfig.Dest, + Dest: d, Xver: config.RealityConfig.Xver, ServerNames: config.RealityConfig.ServerNames, PrivateKey: config.RealityConfig.PrivateKey,