feat(sub): add option to hide server settings in subscription (happ) (#5433)

* feat(settings): add option to hide server settings in subscription

* chore: regenerate codegen and add translations for subHideSettings

- Update frontend/src/generated/{types,schemas,zod,examples}.ts to include
  subHideSettings (bool) in AllSetting and AllSettingView
- Add subHideSettings / subHideSettingsDesc translation keys to all 11
  remaining locales: ar-EG, fa-IR, es-ES, id-ID, ja-JP, pt-BR, uk-UA,
  tr-TR, zh-TW, zh-CN, vi-VN

Co-authored-by: IgorKha <IgorKha@users.noreply.github.com>
Co-authored-by: Sanaei <MHSanaei@users.noreply.github.com>

* fix(sub): add subHideSettings default to settings map

Every other sub* setting has an entry in defaultValueMap; subHideSettings was missing, so GetSubHideSettings hit the 'key not in defaultValueMap' error path on a fresh install (only masked by the false fallback in sub.go). Add the default for consistency.
This commit is contained in:
IgorKha
2026-06-21 03:32:56 +05:00
committed by GitHub
parent 1a4aef3353
commit ce1d348ece
24 changed files with 69 additions and 4 deletions
+10 -3
View File
@@ -48,6 +48,7 @@ type SUBController struct {
subAnnounce string
subEnableRouting bool
subRoutingRules string
subHideSettings bool
subPath string
subJsonPath string
subClashPath string
@@ -87,6 +88,7 @@ func NewSUBController(
subAnnounce string,
subEnableRouting bool,
subRoutingRules string,
subHideSettings bool,
) *SUBController {
sub := NewSubService(remarkTemplate)
a := &SUBController{
@@ -96,6 +98,7 @@ func NewSUBController(
subAnnounce: subAnnounce,
subEnableRouting: subEnableRouting,
subRoutingRules: subRoutingRules,
subHideSettings: subHideSettings,
subPath: subPath,
subJsonPath: jsonPath,
subClashPath: clashPath,
@@ -178,7 +181,7 @@ func (a *SUBController) subs(c *gin.Context) {
if profileUrl == "" {
profileUrl = fmt.Sprintf("%s://%s%s", scheme, hostWithPort, c.Request.RequestURI)
}
a.ApplyCommonHeaders(c, header, a.updateInterval, a.subTitle, a.subSupportUrl, profileUrl, a.subAnnounce, a.subEnableRouting, a.subRoutingRules)
a.ApplyCommonHeaders(c, header, a.updateInterval, a.subTitle, a.subSupportUrl, profileUrl, a.subAnnounce, a.subEnableRouting, a.subRoutingRules, a.subHideSettings)
if a.subEncrypt {
c.String(200, base64.StdEncoding.EncodeToString([]byte(result.String())))
@@ -357,7 +360,7 @@ func (a *SUBController) subJsons(c *gin.Context) {
if profileUrl == "" {
profileUrl = fmt.Sprintf("%s://%s%s", scheme, hostWithPort, c.Request.RequestURI)
}
a.ApplyCommonHeaders(c, header, a.updateInterval, a.subTitle, a.subSupportUrl, profileUrl, a.subAnnounce, a.subEnableRouting, a.subRoutingRules)
a.ApplyCommonHeaders(c, header, a.updateInterval, a.subTitle, a.subSupportUrl, profileUrl, a.subAnnounce, a.subEnableRouting, a.subRoutingRules, a.subHideSettings)
c.String(200, jsonSub)
}
@@ -374,7 +377,7 @@ func (a *SUBController) subClashs(c *gin.Context) {
if profileUrl == "" {
profileUrl = fmt.Sprintf("%s://%s%s", scheme, hostWithPort, c.Request.RequestURI)
}
a.ApplyCommonHeaders(c, header, a.updateInterval, a.subTitle, a.subSupportUrl, profileUrl, a.subAnnounce, a.subEnableRouting, a.subRoutingRules)
a.ApplyCommonHeaders(c, header, a.updateInterval, a.subTitle, a.subSupportUrl, profileUrl, a.subAnnounce, a.subEnableRouting, a.subRoutingRules, a.subHideSettings)
if a.subTitle != "" {
// Clash clients commonly use Content-Disposition to choose the imported profile name.
c.Writer.Header().Set("Content-Disposition", fmt.Sprintf(`attachment; filename*=UTF-8''%s`, url.PathEscape(a.subTitle)))
@@ -394,6 +397,7 @@ func (a *SUBController) ApplyCommonHeaders(
profileAnnounce string,
profileEnableRouting bool,
profileRoutingRules string,
profileHideSettings bool,
) {
c.Writer.Header().Set("Subscription-Userinfo", header)
c.Writer.Header().Set("Profile-Update-Interval", updateInterval)
@@ -417,4 +421,7 @@ func (a *SUBController) ApplyCommonHeaders(
if profileRoutingRules != "" {
c.Writer.Header().Set("Routing", profileRoutingRules)
}
if profileHideSettings {
c.Writer.Header().Set("Hide-Settings", "1")
}
}