mirror of
https://github.com/nitezs/sub2clash.git
synced 2024-12-24 11:44:42 -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 {
|
if temp.ProxyGroups[i].IsCountryGrop {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
newProxies := make([]string, 0, len(temp.ProxyGroups[i].Proxies))
|
newProxies := make([]string, 0)
|
||||||
countryGroupMap := make(map[string]model.ProxyGroup)
|
countryGroupMap := make(map[string]model.ProxyGroup)
|
||||||
for _, v := range sub.ProxyGroups {
|
for _, v := range sub.ProxyGroups {
|
||||||
if v.IsCountryGrop {
|
if v.IsCountryGrop {
|
||||||
|
@ -15,12 +15,15 @@ type ProxyGroup struct {
|
|||||||
Tolerance int `yaml:"tolerance,omitempty"`
|
Tolerance int `yaml:"tolerance,omitempty"`
|
||||||
Lazy bool `yaml:"lazy"`
|
Lazy bool `yaml:"lazy"`
|
||||||
Size int `yaml:"-"`
|
Size int `yaml:"-"`
|
||||||
|
DisableUDP bool `yaml:"disable-udp,omitempty"`
|
||||||
|
Strategy string `yaml:"strategy,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SelectProxyGroup struct {
|
type SelectProxyGroup struct {
|
||||||
Name string `yaml:"name,omitempty"`
|
Name string `yaml:"name,omitempty"`
|
||||||
Type string `yaml:"type,omitempty"`
|
Type string `yaml:"type,omitempty"`
|
||||||
Proxies []string `yaml:"proxies,omitempty"`
|
Proxies []string `yaml:"proxies,omitempty"`
|
||||||
|
DisableUDP bool `yaml:"disable-udp,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UrlTestProxyGroup struct {
|
type UrlTestProxyGroup struct {
|
||||||
@ -31,6 +34,24 @@ type UrlTestProxyGroup struct {
|
|||||||
Interval int `yaml:"interval,omitempty"`
|
Interval int `yaml:"interval,omitempty"`
|
||||||
Tolerance int `yaml:"tolerance,omitempty"`
|
Tolerance int `yaml:"tolerance,omitempty"`
|
||||||
Lazy bool `yaml:"lazy"`
|
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) {
|
func (p ProxyGroup) MarshalYAML() (interface{}, error) {
|
||||||
@ -40,8 +61,9 @@ func (p ProxyGroup) MarshalYAML() (interface{}, error) {
|
|||||||
Name: p.Name,
|
Name: p.Name,
|
||||||
Type: p.Type,
|
Type: p.Type,
|
||||||
Proxies: p.Proxies,
|
Proxies: p.Proxies,
|
||||||
|
DisableUDP: p.DisableUDP,
|
||||||
}, nil
|
}, nil
|
||||||
case "url-test":
|
case "url-test", "fallback":
|
||||||
return UrlTestProxyGroup{
|
return UrlTestProxyGroup{
|
||||||
Name: p.Name,
|
Name: p.Name,
|
||||||
Type: p.Type,
|
Type: p.Type,
|
||||||
@ -50,9 +72,32 @@ func (p ProxyGroup) MarshalYAML() (interface{}, error) {
|
|||||||
Interval: p.Interval,
|
Interval: p.Interval,
|
||||||
Tolerance: p.Tolerance,
|
Tolerance: p.Tolerance,
|
||||||
Lazy: p.Lazy,
|
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
|
}, nil
|
||||||
}
|
}
|
||||||
return nil, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type ProxyGroupsSortByName []ProxyGroup
|
type ProxyGroupsSortByName []ProxyGroup
|
||||||
|
Loading…
Reference in New Issue
Block a user