mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 11:42:43 +08:00
refactor: field name
This commit is contained in:
parent
bbbe371ea9
commit
b9f270162a
|
@ -13,7 +13,7 @@ type GroupBase struct {
|
|||
*outbound.Base
|
||||
filter *regexp2.Regexp
|
||||
providers []provider.ProxyProvider
|
||||
flags map[string]uint
|
||||
versions map[string]uint
|
||||
proxies map[string][]C.Proxy
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ func NewGroupBase(opt GroupBaseOption) *GroupBase {
|
|||
Base: outbound.NewBase(opt.BaseOption),
|
||||
filter: filter,
|
||||
providers: opt.providers,
|
||||
flags: map[string]uint{},
|
||||
versions: map[string]uint{},
|
||||
proxies: map[string][]C.Proxy{},
|
||||
}
|
||||
}
|
||||
|
@ -52,21 +52,20 @@ func (gb *GroupBase) GetProxies(touch bool) []C.Proxy {
|
|||
}
|
||||
return proxies
|
||||
}
|
||||
//TODO("Touch Flag 没变的")
|
||||
//TODO("Touch Version 没变的")
|
||||
for _, pd := range gb.providers {
|
||||
vt := pd.VehicleType()
|
||||
if vt == types.Compatible {
|
||||
if pd.VehicleType() == types.Compatible {
|
||||
if touch {
|
||||
gb.proxies[pd.Name()] = pd.ProxiesWithTouch()
|
||||
} else {
|
||||
gb.proxies[pd.Name()] = pd.Proxies()
|
||||
}
|
||||
|
||||
gb.flags[pd.Name()] = pd.Flag()
|
||||
gb.versions[pd.Name()] = pd.Version()
|
||||
continue
|
||||
}
|
||||
|
||||
if flag, ok := gb.flags[pd.Name()]; !ok || flag != pd.Flag() {
|
||||
if version, ok := gb.versions[pd.Name()]; !ok || version != pd.Version() {
|
||||
var (
|
||||
proxies []C.Proxy
|
||||
newProxies []C.Proxy
|
||||
|
@ -85,7 +84,7 @@ func (gb *GroupBase) GetProxies(touch bool) []C.Proxy {
|
|||
}
|
||||
|
||||
gb.proxies[pd.Name()] = newProxies
|
||||
gb.flags[pd.Name()] = pd.Flag()
|
||||
gb.versions[pd.Name()] = pd.Version()
|
||||
}
|
||||
}
|
||||
var proxies []C.Proxy
|
||||
|
|
|
@ -33,11 +33,11 @@ type proxySetProvider struct {
|
|||
*fetcher
|
||||
proxies []C.Proxy
|
||||
healthCheck *HealthCheck
|
||||
flag uint
|
||||
version uint
|
||||
}
|
||||
|
||||
func (pp *proxySetProvider) Flag() uint {
|
||||
return pp.flag
|
||||
func (pp *proxySetProvider) Version() uint {
|
||||
return pp.version
|
||||
}
|
||||
|
||||
func (pp *proxySetProvider) MarshalJSON() ([]byte, error) {
|
||||
|
@ -123,10 +123,10 @@ func NewProxySetProvider(name string, interval time.Duration, filter string, veh
|
|||
onUpdate := func(elm any) {
|
||||
ret := elm.([]C.Proxy)
|
||||
pd.setProxies(ret)
|
||||
if pd.flag == math.MaxUint {
|
||||
pd.flag = 0
|
||||
if pd.version == math.MaxUint {
|
||||
pd.version = 0
|
||||
} else {
|
||||
pd.flag++
|
||||
pd.version++
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -182,11 +182,11 @@ type compatibleProvider struct {
|
|||
name string
|
||||
healthCheck *HealthCheck
|
||||
proxies []C.Proxy
|
||||
flag uint
|
||||
version uint
|
||||
}
|
||||
|
||||
func (cp *compatibleProvider) Flag() uint {
|
||||
return cp.flag
|
||||
func (cp *compatibleProvider) Version() uint {
|
||||
return cp.version
|
||||
}
|
||||
|
||||
func (cp *compatibleProvider) MarshalJSON() ([]byte, error) {
|
||||
|
|
|
@ -70,7 +70,7 @@ type ProxyProvider interface {
|
|||
// Commonly used in DialContext and DialPacketConn
|
||||
ProxiesWithTouch() []constant.Proxy
|
||||
HealthCheck()
|
||||
Flag() uint
|
||||
Version() uint
|
||||
}
|
||||
|
||||
// Rule Type
|
||||
|
|
Loading…
Reference in New Issue
Block a user