mirror of
https://github.com/bestnite/sub2clash.git
synced 2025-10-26 09:11:01 +00:00
Refactor subscription handling by removing SubConfig model, updating BuildSub function to use ConvertConfig, and enhancing Base64 decoding across parsers. Update routes and frontend to support new configuration format.
This commit is contained in:
@@ -12,14 +12,14 @@ import (
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
func SubHandler(model M.ClashType, template string) func(c *gin.Context) {
|
||||
func ConvertHandler(template string) func(c *gin.Context) {
|
||||
return func(c *gin.Context) {
|
||||
query, err := M.ParseSubQuery(c)
|
||||
query, err := M.ParseConvertQuery(c)
|
||||
if err != nil {
|
||||
c.String(http.StatusBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
sub, err := common.BuildSub(model, query, template, config.GlobalConfig.CacheExpire, config.GlobalConfig.RequestRetryTimes)
|
||||
sub, err := common.BuildSub(query.ClashType, query, template, config.GlobalConfig.CacheExpire, config.GlobalConfig.RequestRetryTimes)
|
||||
if err != nil {
|
||||
c.String(http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
@@ -142,7 +142,6 @@ func UpdateLinkHandler(c *gin.Context) {
|
||||
}
|
||||
|
||||
func GetRawConfHandler(c *gin.Context) {
|
||||
|
||||
hash := c.Param("hash")
|
||||
password := c.Query("password")
|
||||
|
||||
@@ -176,11 +175,11 @@ func GetRawConfHandler(c *gin.Context) {
|
||||
host := c.Request.Host
|
||||
targetPath := strings.TrimPrefix(shortLink.Url, "/")
|
||||
requestURL := fmt.Sprintf("%s://%s/%s", scheme, host, targetPath)
|
||||
|
||||
|
||||
client := &http.Client{
|
||||
Timeout: 30 * time.Second, // 30秒超时
|
||||
}
|
||||
|
||||
|
||||
response, err := client.Get(requestURL)
|
||||
if err != nil {
|
||||
respondWithError(c, http.StatusInternalServerError, "请求错误: "+err.Error())
|
||||
@@ -198,7 +197,6 @@ func GetRawConfHandler(c *gin.Context) {
|
||||
}
|
||||
|
||||
func GetRawConfUriHandler(c *gin.Context) {
|
||||
|
||||
hash := c.Query("hash")
|
||||
password := c.Query("password")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user