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:
2025-07-22 04:09:00 +00:00
parent 83a728a415
commit 80d91efca4
15 changed files with 329 additions and 424 deletions

View File

@@ -1,13 +1,13 @@
package parser
import (
"encoding/base64"
"errors"
"strconv"
"strings"
"unicode/utf8"
P "github.com/bestnite/sub2clash/model/proxy"
"github.com/bestnite/sub2clash/utils"
)
func hasPrefix(proxy string, prefixes []string) bool {
@@ -49,7 +49,7 @@ func isLikelyBase64(s string) bool {
}
}
decoded, err := DecodeBase64(s)
decoded, err := utils.DecodeBase64(s, true)
if err != nil {
return false
}
@@ -60,23 +60,6 @@ func isLikelyBase64(s string) bool {
return true
}
func DecodeBase64(s string) (string, error) {
s = strings.TrimSpace(s)
if strings.Contains(s, "-") || strings.Contains(s, "_") {
s = strings.ReplaceAll(s, "-", "+")
s = strings.ReplaceAll(s, "_", "/")
}
if len(s)%4 != 0 {
s += strings.Repeat("=", 4-len(s)%4)
}
decodeStr, err := base64.StdEncoding.DecodeString(s)
if err != nil {
return "", err
}
return string(decodeStr), nil
}
type ParseConfig struct {
UseUDP bool
}