mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-06-07 13:44:24 +00:00
- config: add GetSettingPath for JSON-based settings storage - setting.go: load/save settings from JSON file instead of DB; keep xrayTemplateConfig in DB; fix ResetSettings to not clear users - xray_setting.go: save xray template config to DB directly - install.sh: add Cloudflare SSL option (wildcard via DNS), allow user to input custom credentials on fresh install, fix existing install logic to preserve user config
31 lines
820 B
Go
31 lines
820 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 saveXrayTemplateConfigToDB(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
|
|
}
|