mirror of
https://github.com/nitezs/sub2clash.git
synced 2024-12-23 20:34:41 -05:00
fix: 修复模板中非select、url-test策略组被输出为null的问题
This commit is contained in:
parent
773424cdb0
commit
50877b1691
@ -249,7 +249,7 @@ func MergeSubAndTemplate(temp *model.Subscription, sub *model.Subscription) {
|
||||
if temp.ProxyGroups[i].IsCountryGrop {
|
||||
continue
|
||||
}
|
||||
newProxies := make([]string, 0, len(temp.ProxyGroups[i].Proxies))
|
||||
newProxies := make([]string, 0)
|
||||
countryGroupMap := make(map[string]model.ProxyGroup)
|
||||
for _, v := range sub.ProxyGroups {
|
||||
if v.IsCountryGrop {
|
||||
|
@ -15,12 +15,15 @@ type ProxyGroup struct {
|
||||
Tolerance int `yaml:"tolerance,omitempty"`
|
||||
Lazy bool `yaml:"lazy"`
|
||||
Size int `yaml:"-"`
|
||||
DisableUDP bool `yaml:"disable-udp,omitempty"`
|
||||
Strategy string `yaml:"strategy,omitempty"`
|
||||
}
|
||||
|
||||
type SelectProxyGroup struct {
|
||||
Name string `yaml:"name,omitempty"`
|
||||
Type string `yaml:"type,omitempty"`
|
||||
Proxies []string `yaml:"proxies,omitempty"`
|
||||
DisableUDP bool `yaml:"disable-udp,omitempty"`
|
||||
}
|
||||
|
||||
type UrlTestProxyGroup struct {
|
||||
@ -31,6 +34,24 @@ type UrlTestProxyGroup struct {
|
||||
Interval int `yaml:"interval,omitempty"`
|
||||
Tolerance int `yaml:"tolerance,omitempty"`
|
||||
Lazy bool `yaml:"lazy"`
|
||||
DisableUDP bool `yaml:"disable-udp,omitempty"`
|
||||
}
|
||||
|
||||
type LoadBalanceProxyGroup struct {
|
||||
Name string `yaml:"name,omitempty"`
|
||||
Type string `yaml:"type,omitempty"`
|
||||
Proxies []string `yaml:"proxies,omitempty"`
|
||||
DisableUDP bool `yaml:"disable-udp,omitempty"`
|
||||
Url string `yaml:"url,omitempty"`
|
||||
Interval int `yaml:"interval,omitempty"`
|
||||
Lazy bool `yaml:"lazy"`
|
||||
Strategy string `yaml:"strategy,omitempty"`
|
||||
}
|
||||
|
||||
type RelayProxyGroup struct {
|
||||
Name string `yaml:"name,omitempty"`
|
||||
Type string `yaml:"type,omitempty"`
|
||||
Proxies []string `yaml:"proxies,omitempty"`
|
||||
}
|
||||
|
||||
func (p ProxyGroup) MarshalYAML() (interface{}, error) {
|
||||
@ -40,8 +61,9 @@ func (p ProxyGroup) MarshalYAML() (interface{}, error) {
|
||||
Name: p.Name,
|
||||
Type: p.Type,
|
||||
Proxies: p.Proxies,
|
||||
DisableUDP: p.DisableUDP,
|
||||
}, nil
|
||||
case "url-test":
|
||||
case "url-test", "fallback":
|
||||
return UrlTestProxyGroup{
|
||||
Name: p.Name,
|
||||
Type: p.Type,
|
||||
@ -50,9 +72,32 @@ func (p ProxyGroup) MarshalYAML() (interface{}, error) {
|
||||
Interval: p.Interval,
|
||||
Tolerance: p.Tolerance,
|
||||
Lazy: p.Lazy,
|
||||
DisableUDP: p.DisableUDP,
|
||||
}, nil
|
||||
case "load-balance":
|
||||
return LoadBalanceProxyGroup{
|
||||
Name: p.Name,
|
||||
Type: p.Type,
|
||||
Proxies: p.Proxies,
|
||||
DisableUDP: p.DisableUDP,
|
||||
Url: p.Url,
|
||||
Interval: p.Interval,
|
||||
Lazy: p.Lazy,
|
||||
Strategy: p.Strategy,
|
||||
}, nil
|
||||
case "relay":
|
||||
return RelayProxyGroup{
|
||||
Name: p.Name,
|
||||
Type: p.Type,
|
||||
Proxies: p.Proxies,
|
||||
}, nil
|
||||
default:
|
||||
return SelectProxyGroup{
|
||||
Name: p.Name,
|
||||
Type: p.Type,
|
||||
Proxies: p.Proxies,
|
||||
}, nil
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
type ProxyGroupsSortByName []ProxyGroup
|
||||
|
Loading…
Reference in New Issue
Block a user