Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'web/service/xraySettings.go')
-rw-r--r--web/service/xraySettings.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/web/service/xraySettings.go b/web/service/xraySettings.go
new file mode 100644
index 00000000..4550bde2
--- /dev/null
+++ b/web/service/xraySettings.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
+}