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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user