mirror of
https://github.com/MetaCubeX/ClashMetaForAndroid.git
synced 2024-11-25 06:46:09 +03:00
code cleanup
This commit is contained in:
parent
309726dddd
commit
e164e219bd
@ -3,7 +3,6 @@ package tunnel
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/metacubex/mihomo/adapter"
|
||||
"github.com/metacubex/mihomo/adapter/outboundgroup"
|
||||
"github.com/metacubex/mihomo/constant/provider"
|
||||
"github.com/metacubex/mihomo/log"
|
||||
@ -19,7 +18,7 @@ func HealthCheck(name string) {
|
||||
return
|
||||
}
|
||||
|
||||
g, ok := p.(*adapter.Proxy).ProxyAdapter.(outboundgroup.ProxyGroup)
|
||||
g, ok := p.Adapter().(outboundgroup.ProxyGroup)
|
||||
if !ok {
|
||||
log.Warnln("Request health check for `%s`: invalid type %s", name, p.Type().String())
|
||||
|
||||
|
@ -6,8 +6,6 @@ import (
|
||||
|
||||
"github.com/dlclark/regexp2"
|
||||
|
||||
"github.com/metacubex/mihomo/adapter"
|
||||
|
||||
"github.com/metacubex/mihomo/adapter/outboundgroup"
|
||||
C "github.com/metacubex/mihomo/constant"
|
||||
"github.com/metacubex/mihomo/constant/provider"
|
||||
@ -61,7 +59,7 @@ func QueryProxyGroupNames(excludeNotSelectable bool) []string {
|
||||
return []string{}
|
||||
}
|
||||
|
||||
global := tunnel.Proxies()["GLOBAL"].(*adapter.Proxy).ProxyAdapter.(outboundgroup.ProxyGroup)
|
||||
global := tunnel.Proxies()["GLOBAL"].Adapter().(outboundgroup.ProxyGroup)
|
||||
proxies := global.Providers()[0].Proxies()
|
||||
result := make([]string, 0, len(proxies)+1)
|
||||
|
||||
@ -70,7 +68,7 @@ func QueryProxyGroupNames(excludeNotSelectable bool) []string {
|
||||
}
|
||||
|
||||
for _, p := range proxies {
|
||||
if _, ok := p.(*adapter.Proxy).ProxyAdapter.(outboundgroup.ProxyGroup); ok {
|
||||
if _, ok := p.Adapter().(outboundgroup.ProxyGroup); ok {
|
||||
if !excludeNotSelectable || p.Type() == C.Selector {
|
||||
result = append(result, p.Name())
|
||||
}
|
||||
@ -89,7 +87,7 @@ func QueryProxyGroup(name string, sortMode SortMode, uiSubtitlePattern *regexp2.
|
||||
return nil
|
||||
}
|
||||
|
||||
g, ok := p.(*adapter.Proxy).ProxyAdapter.(outboundgroup.ProxyGroup)
|
||||
g, ok := p.Adapter().(outboundgroup.ProxyGroup)
|
||||
if !ok {
|
||||
log.Warnln("Query group `%s`: invalid type %s", name, p.Type().String())
|
||||
|
||||
@ -138,14 +136,14 @@ func PatchSelector(selector, name string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
g, ok := p.(*adapter.Proxy).ProxyAdapter.(outboundgroup.ProxyGroup)
|
||||
g, ok := p.Adapter().(outboundgroup.ProxyGroup)
|
||||
if !ok {
|
||||
log.Warnln("Patch selector `%s`: invalid type %s", selector, p.Type().String())
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
s, ok := g.(*outboundgroup.Selector)
|
||||
s, ok := g.(outboundgroup.SelectAble)
|
||||
if !ok {
|
||||
log.Warnln("Patch selector `%s`: invalid type %s", selector, p.Type().String())
|
||||
|
||||
@ -172,7 +170,7 @@ func convertProxies(proxies []C.Proxy, uiSubtitlePattern *regexp2.Regexp) []*Pro
|
||||
subtitle := p.Type().String()
|
||||
|
||||
if uiSubtitlePattern != nil {
|
||||
if _, ok := p.(*adapter.Proxy).ProxyAdapter.(outboundgroup.ProxyGroup); !ok {
|
||||
if _, ok := p.Adapter().(outboundgroup.ProxyGroup); !ok {
|
||||
runes := []rune(name)
|
||||
match, err := uiSubtitlePattern.FindRunesMatch(runes)
|
||||
if err == nil && match != nil {
|
||||
@ -210,7 +208,7 @@ func collectProviders(providers []provider.ProxyProvider, uiSubtitlePattern *reg
|
||||
subtitle := px.Type().String()
|
||||
|
||||
if uiSubtitlePattern != nil {
|
||||
if _, ok := px.(*adapter.Proxy).ProxyAdapter.(outboundgroup.ProxyGroup); !ok {
|
||||
if _, ok := px.Adapter().(outboundgroup.ProxyGroup); !ok {
|
||||
runes := []rune(name)
|
||||
match, err := uiSubtitlePattern.FindRunesMatch(runes)
|
||||
if err == nil && match != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user