Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
wwqgtxx committed Sep 27, 2024
1 parent 309726d commit e164e21
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
3 changes: 1 addition & 2 deletions core/src/main/golang/native/tunnel/connectivity.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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())

Expand Down
16 changes: 7 additions & 9 deletions core/src/main/golang/native/tunnel/proxies.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)

Expand All @@ -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())
}
Expand All @@ -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())

Expand Down Expand Up @@ -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())

Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit e164e21

Please sign in to comment.