mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-10-13 11:39:13 +00:00
31 lines
844 B
Go
31 lines
844 B
Go
package service
|
|
|
|
import (
|
|
_ "embed"
|
|
"encoding/json"
|
|
|
|
"github.com/mhsanaei/3x-ui/v2/util/common"
|
|
"github.com/mhsanaei/3x-ui/v2/xray"
|
|
)
|
|
|
|
// XraySettingService provides business logic for Xray configuration management.
|
|
// It handles validation and storage of Xray template configurations.
|
|
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
|
|
}
|