mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-07-26 06:16:12 +00:00
feat(sub): auto-detect subscription formats
This commit is contained in:
+54
-5
@@ -89,6 +89,31 @@ func (s *Server) initRouter() (*gin.Engine, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
subClashAutoDetect, err := s.settingService.GetSubClashAutoDetect()
|
||||
if err != nil {
|
||||
subClashAutoDetect = false
|
||||
}
|
||||
|
||||
subJsonAutoDetect, err := s.settingService.GetSubJsonAutoDetect()
|
||||
if err != nil {
|
||||
subJsonAutoDetect = false
|
||||
}
|
||||
|
||||
subJsonAlwaysArray, err := s.settingService.GetSubJsonAlwaysArray()
|
||||
if err != nil {
|
||||
subJsonAlwaysArray = false
|
||||
}
|
||||
|
||||
subJsonUserAgentRegex, err := s.settingService.GetSubJsonUserAgentRegex()
|
||||
if err != nil {
|
||||
subJsonUserAgentRegex = service.DefaultSubJsonUserAgentRegex
|
||||
}
|
||||
|
||||
subClashUserAgentRegex, err := s.settingService.GetSubClashUserAgentRegex()
|
||||
if err != nil {
|
||||
subClashUserAgentRegex = service.DefaultSubClashUserAgentRegex
|
||||
}
|
||||
|
||||
// Set base_path based on LinksPath for template rendering
|
||||
// Ensure LinksPath ends with "/" for proper asset URL generation
|
||||
basePath := LinksPath
|
||||
@@ -239,11 +264,35 @@ func (s *Server) initRouter() (*gin.Engine, error) {
|
||||
|
||||
g := engine.Group("/")
|
||||
|
||||
s.sub = NewSUBController(
|
||||
g, LinksPath, JsonPath, ClashPath, subJsonEnable, subClashEnable, Encrypt, RemarkTemplate, SubUpdates,
|
||||
SubJsonMux, SubJsonRules, SubJsonFinalMask, SubClashEnableRouting, SubClashRules, SubTitle, SubSupportUrl,
|
||||
SubProfileUrl, SubAnnounce, SubEnableRouting, SubRoutingRules, SubHideSettings,
|
||||
SubIncyEnableRouting, SubIncyRoutingRules)
|
||||
s.sub = NewSUBController(g,
|
||||
WithSUBPath(LinksPath),
|
||||
WithSUBJsonPath(JsonPath),
|
||||
WithSUBClashPath(ClashPath),
|
||||
WithSUBClashAutoDetect(subClashAutoDetect),
|
||||
WithSUBClashUserAgentRegex(subClashUserAgentRegex),
|
||||
WithSUBJsonAutoDetect(subJsonAutoDetect),
|
||||
WithSUBJsonUserAgentRegex(subJsonUserAgentRegex),
|
||||
WithSUBJsonAlwaysArray(subJsonAlwaysArray),
|
||||
WithSUBJsonEnabled(subJsonEnable),
|
||||
WithSUBClashEnabled(subClashEnable),
|
||||
WithSUBEncryption(Encrypt),
|
||||
WithSUBRemarkTemplate(RemarkTemplate),
|
||||
WithSUBUpdateInterval(SubUpdates),
|
||||
WithSUBJsonMux(SubJsonMux),
|
||||
WithSUBJsonRules(SubJsonRules),
|
||||
WithSUBJsonFinalMask(SubJsonFinalMask),
|
||||
WithSUBClashEnableRouting(SubClashEnableRouting),
|
||||
WithSUBClashRules(SubClashRules),
|
||||
WithSUBTitle(SubTitle),
|
||||
WithSUBSupportURL(SubSupportUrl),
|
||||
WithSUBProfileURL(SubProfileUrl),
|
||||
WithSUBAnnounce(SubAnnounce),
|
||||
WithSUBEnableRouting(SubEnableRouting),
|
||||
WithSUBRoutingRules(SubRoutingRules),
|
||||
WithSUBHideSettings(SubHideSettings),
|
||||
WithSUBIncyEnableRouting(SubIncyEnableRouting),
|
||||
WithSUBIncyRoutingRules(SubIncyRoutingRules),
|
||||
)
|
||||
|
||||
return engine, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user