diff options
| author | Alireza Ahmadi <alireza7@gmail.com> | 2023-12-08 20:45:21 +0300 |
|---|---|---|
| committer | Alireza Ahmadi <alireza7@gmail.com> | 2023-12-08 20:45:21 +0300 |
| commit | 5fbf8f0d535b131ad6de22a0d1dda0f2167d5ee0 (patch) | |
| tree | c2da678a5d851fe5349644468427c5ba45e24d3d /web/service/xray.go | |
| parent | bcc897640e68f7a731d39bee04c8930d7d7196c6 (diff) | |
Expand multiDomain to externalProxy #1300
Diffstat (limited to 'web/service/xray.go')
| -rw-r--r-- | web/service/xray.go | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/web/service/xray.go b/web/service/xray.go index 1d046a44..7233cec5 100644 --- a/web/service/xray.go +++ b/web/service/xray.go @@ -135,19 +135,24 @@ func (s *XrayService) GetXrayConfig() (*xray.Config, error) { inbound.Settings = string(modifiedSettings) } - // Unmarshal stream JSON - var stream map[string]interface{} - json.Unmarshal([]byte(inbound.StreamSettings), &stream) - - // Remove the "settings" field under "tlsSettings" and "realitySettings" - tlsSettings, ok1 := stream["tlsSettings"].(map[string]interface{}) - realitySettings, ok2 := stream["realitySettings"].(map[string]interface{}) - if ok1 || ok2 { - if ok1 { - delete(tlsSettings, "settings") - } else if ok2 { - delete(realitySettings, "settings") + if len(inbound.StreamSettings) > 0 { + // Unmarshal stream JSON + var stream map[string]interface{} + json.Unmarshal([]byte(inbound.StreamSettings), &stream) + + // Remove the "settings" field under "tlsSettings" and "realitySettings" + tlsSettings, ok1 := stream["tlsSettings"].(map[string]interface{}) + realitySettings, ok2 := stream["realitySettings"].(map[string]interface{}) + if ok1 || ok2 { + if ok1 { + delete(tlsSettings, "settings") + } else if ok2 { + delete(realitySettings, "settings") + } } + + delete(stream, "externalProxy") + newStream, err := json.MarshalIndent(stream, "", " ") if err != nil { return nil, err |
