feat(settings): add subscription format controls

This commit is contained in:
Tomilla
2026-07-06 10:02:04 +08:00
parent 5a7b3b7370
commit 8bb9a8c6d5
32 changed files with 926 additions and 23 deletions
+19
View File
@@ -2,6 +2,7 @@ package controller
import (
"errors"
"net/http"
"strconv"
"time"
@@ -38,6 +39,10 @@ type updateSettingForm struct {
ClearSmtpPassword bool `json:"clearSmtpPassword" form:"clearSmtpPassword"`
}
type validateRegexForm struct {
Regex string `json:"regex" form:"regex"`
}
// SettingController handles settings and user management operations.
type SettingController struct {
settingService service.SettingService
@@ -61,6 +66,7 @@ func (a *SettingController) initRouter(g *gin.RouterGroup) {
g.POST("/all", a.getAllSetting)
g.POST("/defaultSettings", a.getDefaultSettings)
g.POST("/update", a.updateSetting)
g.POST("/validateRegex", a.validateRegex)
g.POST("/updateUser", a.updateUser)
g.POST("/restartPanel", a.restartPanel)
g.GET("/getDefaultJsonConfig", a.getDefaultXrayConfig)
@@ -72,6 +78,19 @@ func (a *SettingController) initRouter(g *gin.RouterGroup) {
g.POST("/testTgBot", a.testTgBot)
}
func (a *SettingController) validateRegex(c *gin.Context) {
form := &validateRegexForm{}
if err := c.ShouldBind(form); err != nil {
pureJsonMsg(c, http.StatusOK, false, err.Error())
return
}
if err := service.ValidateRegex(form.Regex); err != nil {
pureJsonMsg(c, http.StatusOK, false, err.Error())
return
}
pureJsonMsg(c, http.StatusOK, true, "")
}
// getAllSetting retrieves all current settings as the browser-safe view:
// secret values are redacted and surfaced as has* presence flags instead.
func (a *SettingController) getAllSetting(c *gin.Context) {