1234567891011121314151617181920212223242526272829 |
- 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
- }
|