chore: add override fields
Some checks failed
Trigger CMFA Update / trigger-CMFA-update (push) Has been cancelled

This commit is contained in:
xishang0128 2024-06-16 18:19:04 +08:00
parent 40f40f6d24
commit 0738e18100
2 changed files with 21 additions and 31 deletions

View File

@ -28,7 +28,10 @@ type healthCheckSchema struct {
} }
type OverrideSchema struct { type OverrideSchema struct {
TFO *bool `provider:"tfo,omitempty"`
MPTcp *bool `provider:"mptcp,omitempty"`
UDP *bool `provider:"udp,omitempty"` UDP *bool `provider:"udp,omitempty"`
UDPOverTCP *bool `provider:"udp-over-tcp,omitempty"`
Up *string `provider:"up,omitempty"` Up *string `provider:"up,omitempty"`
Down *string `provider:"down,omitempty"` Down *string `provider:"down,omitempty"`
DialerProxy *string `provider:"dialer-proxy,omitempty"` DialerProxy *string `provider:"dialer-proxy,omitempty"`

View File

@ -6,6 +6,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"net/http" "net/http"
"reflect"
"runtime" "runtime"
"strings" "strings"
"time" "time"
@ -373,37 +374,23 @@ func proxiesParseAndFilter(filter string, excludeFilter string, excludeTypeArray
mapping["dialer-proxy"] = dialerProxy mapping["dialer-proxy"] = dialerProxy
} }
if override.UDP != nil { val := reflect.ValueOf(override)
mapping["udp"] = *override.UDP for i := 0; i < val.NumField(); i++ {
} field := val.Field(i)
if override.Up != nil { if field.IsNil() {
mapping["up"] = *override.Up continue
} }
if override.Down != nil { fieldName := strings.Split(val.Type().Field(i).Tag.Get("provider"), ",")[0]
mapping["down"] = *override.Down switch fieldName {
} case "additional-prefix":
if override.DialerProxy != nil { name := mapping["name"].(string)
mapping["dialer-proxy"] = *override.DialerProxy mapping["name"] = *field.Interface().(*string) + name
} case "additional-suffix":
if override.SkipCertVerify != nil { name := mapping["name"].(string)
mapping["skip-cert-verify"] = *override.SkipCertVerify mapping["name"] = name + *field.Interface().(*string)
} default:
if override.Interface != nil { mapping[fieldName] = field.Elem().Interface()
mapping["interface-name"] = *override.Interface }
}
if override.RoutingMark != nil {
mapping["routing-mark"] = *override.RoutingMark
}
if override.IPVersion != nil {
mapping["ip-version"] = *override.IPVersion
}
if override.AdditionalPrefix != nil {
name := mapping["name"].(string)
mapping["name"] = *override.AdditionalPrefix + name
}
if override.AdditionalSuffix != nil {
name := mapping["name"].(string)
mapping["name"] = name + *override.AdditionalSuffix
} }
proxy, err := adapter.ParseProxy(mapping) proxy, err := adapter.ParseProxy(mapping)