chore: support KeyReplacer in Structure Decoder
This commit is contained in:
@ -99,7 +99,6 @@ type HysteriaOption struct {
|
||||
Down string `proxy:"down"`
|
||||
DownSpeed int `proxy:"down-speed,omitempty"` // compatible with Stash
|
||||
Auth string `proxy:"auth,omitempty"`
|
||||
OldAuthString string `proxy:"auth_str,omitempty"`
|
||||
AuthString string `proxy:"auth-str,omitempty"`
|
||||
Obfs string `proxy:"obfs,omitempty"`
|
||||
SNI string `proxy:"sni,omitempty"`
|
||||
|
@ -9,14 +9,10 @@ import (
|
||||
C "github.com/Dreamacro/clash/constant"
|
||||
)
|
||||
|
||||
func ParseProxy(mapping map[string]any) (C.Proxy, error) {
|
||||
newMapping := make(map[string]any)
|
||||
for key := range mapping {
|
||||
newMapping[strings.ReplaceAll(key, "_", "-")] = mapping[key]
|
||||
}
|
||||
mapping = newMapping
|
||||
var keyReplacer = strings.NewReplacer("_", "-")
|
||||
|
||||
decoder := structure.NewDecoder(structure.Option{TagName: "proxy", WeaklyTypedInput: true})
|
||||
func ParseProxy(mapping map[string]any) (C.Proxy, error) {
|
||||
decoder := structure.NewDecoder(structure.Option{TagName: "proxy", WeaklyTypedInput: true, KeyReplacer: keyReplacer})
|
||||
proxyType, existType := mapping["type"].(string)
|
||||
if !existType {
|
||||
return nil, fmt.Errorf("missing type")
|
||||
|
Reference in New Issue
Block a user