diff options
| author | Alireza Ahmadi <alireza7@gmail.com> | 2023-12-10 14:57:39 +0300 |
|---|---|---|
| committer | Alireza Ahmadi <alireza7@gmail.com> | 2023-12-10 14:57:39 +0300 |
| commit | 4cb67fd1c3129b83f3750f863caba081453f42b1 (patch) | |
| tree | 85c7e5c47f4415f775729aff26b60796590ef34a /web/service/xray_setting.go | |
| parent | 655e17e162129087263e85dfe9d5ba49c0a7044f (diff) | |
[xray] show xray errors #1300
Diffstat (limited to 'web/service/xray_setting.go')
| -rw-r--r-- | web/service/xray_setting.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/web/service/xray_setting.go b/web/service/xray_setting.go new file mode 100644 index 00000000..4550bde2 --- /dev/null +++ b/web/service/xray_setting.go @@ -0,0 +1,28 @@ +package service + +import ( + _ "embed" + "encoding/json" + "x-ui/util/common" + "x-ui/xray" +) + +type XraySettingService struct { + SettingService +} + +func (s *XraySettingService) SaveXraySetting(newXraySettings string) error { + if err := s.CheckXrayConfig(newXraySettings); err != nil { + return err + } + return s.SettingService.saveSetting("xrayTemplateConfig", newXraySettings) +} + +func (s *XraySettingService) CheckXrayConfig(XrayTemplateConfig string) error { + xrayConfig := &xray.Config{} + err := json.Unmarshal([]byte(XrayTemplateConfig), xrayConfig) + if err != nil { + return common.NewError("xray template config invalid:", err) + } + return nil +} |
