Chore: use generics as possible
This commit is contained in:
@ -18,7 +18,7 @@ type Fallback struct {
|
||||
*outbound.Base
|
||||
disableUDP bool
|
||||
filter string
|
||||
single *singledo.Single
|
||||
single *singledo.Single[[]C.Proxy]
|
||||
providers []provider.ProxyProvider
|
||||
failedTimes *atomic.Int32
|
||||
failedTime *atomic.Int64
|
||||
@ -115,11 +115,11 @@ func (f *Fallback) Unwrap(metadata *C.Metadata) C.Proxy {
|
||||
}
|
||||
|
||||
func (f *Fallback) proxies(touch bool) []C.Proxy {
|
||||
elm, _, _ := f.single.Do(func() (any, error) {
|
||||
elm, _, _ := f.single.Do(func() ([]C.Proxy, error) {
|
||||
return getProvidersProxies(f.providers, touch, f.filter), nil
|
||||
})
|
||||
|
||||
return elm.([]C.Proxy)
|
||||
return elm
|
||||
}
|
||||
|
||||
func (f *Fallback) findAliveProxy(touch bool) C.Proxy {
|
||||
@ -141,7 +141,7 @@ func NewFallback(option *GroupCommonOption, providers []provider.ProxyProvider)
|
||||
Interface: option.Interface,
|
||||
RoutingMark: option.RoutingMark,
|
||||
}),
|
||||
single: singledo.NewSingle(defaultGetProxiesDuration),
|
||||
single: singledo.NewSingle[[]C.Proxy](defaultGetProxiesDuration),
|
||||
providers: providers,
|
||||
disableUDP: option.DisableUDP,
|
||||
filter: option.Filter,
|
||||
|
Reference in New Issue
Block a user