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:
authorHo3ein <ho3ein.sanaei@gmail.com>2023-12-10 17:42:52 +0300
committerGitHub <noreply@github.com>2023-12-10 17:42:52 +0300
commite3f1d3c892a1af48f27fdc36f273a55f38d13b40 (patch)
treeb11d0c1ed3c15c8f6f891a5e6df8e021d5db8ab6 /web/service/xray_setting.go
parent36cf7c0a8fda915b51e75958ce729fd9a61a5c90 (diff)
parent9fbe80f87f950673058f0001b3704251fa8b9243 (diff)
huge changes
Diffstat (limited to 'web/service/xray_setting.go')
-rw-r--r--web/service/xray_setting.go28
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
+}