Skip to content

Commit 1d5890a

Browse files
committed
chore: cleanup import path for constant/provider
1 parent a3c023a commit 1d5890a

17 files changed

Lines changed: 104 additions & 105 deletions

File tree

adapter/outboundgroup/fallback.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
N "github.com/metacubex/mihomo/common/net"
1111
"github.com/metacubex/mihomo/common/utils"
1212
C "github.com/metacubex/mihomo/constant"
13-
"github.com/metacubex/mihomo/constant/provider"
13+
P "github.com/metacubex/mihomo/constant/provider"
1414
)
1515

1616
type Fallback struct {
@@ -150,7 +150,7 @@ func (f *Fallback) ForceSet(name string) {
150150
f.selected = name
151151
}
152152

153-
func NewFallback(option *GroupCommonOption, providers []provider.ProxyProvider) *Fallback {
153+
func NewFallback(option *GroupCommonOption, providers []P.ProxyProvider) *Fallback {
154154
return &Fallback{
155155
GroupBase: NewGroupBase(GroupBaseOption{
156156
Name: option.Name,

adapter/outboundgroup/groupbase.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ import (
1212
"github.com/metacubex/mihomo/common/atomic"
1313
"github.com/metacubex/mihomo/common/utils"
1414
C "github.com/metacubex/mihomo/constant"
15-
"github.com/metacubex/mihomo/constant/provider"
16-
types "github.com/metacubex/mihomo/constant/provider"
15+
P "github.com/metacubex/mihomo/constant/provider"
1716
"github.com/metacubex/mihomo/log"
1817
"github.com/metacubex/mihomo/tunnel"
1918

@@ -26,7 +25,7 @@ type GroupBase struct {
2625
filterRegs []*regexp2.Regexp
2726
excludeFilterRegs []*regexp2.Regexp
2827
excludeTypeArray []string
29-
providers []provider.ProxyProvider
28+
providers []P.ProxyProvider
3029
failedTestMux sync.Mutex
3130
failedTimes int
3231
failedTime time.Time
@@ -48,7 +47,7 @@ type GroupBaseOption struct {
4847
ExcludeType string
4948
TestTimeout int
5049
MaxFailedTimes int
51-
Providers []provider.ProxyProvider
50+
Providers []P.ProxyProvider
5251
}
5352

5453
func NewGroupBase(opt GroupBaseOption) *GroupBase {
@@ -125,7 +124,7 @@ func (gb *GroupBase) GetProxies(touch bool) []C.Proxy {
125124
}
126125
} else {
127126
for _, pd := range gb.providers {
128-
if pd.VehicleType() == types.Compatible { // compatible provider unneeded filter
127+
if pd.VehicleType() == P.Compatible { // compatible provider unneeded filter
129128
proxies = append(proxies, pd.Proxies()...)
130129
continue
131130
}

adapter/outboundgroup/loadbalance.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
N "github.com/metacubex/mihomo/common/net"
1515
"github.com/metacubex/mihomo/common/utils"
1616
C "github.com/metacubex/mihomo/constant"
17-
"github.com/metacubex/mihomo/constant/provider"
17+
P "github.com/metacubex/mihomo/constant/provider"
1818

1919
"golang.org/x/net/publicsuffix"
2020
)
@@ -239,7 +239,7 @@ func (lb *LoadBalance) MarshalJSON() ([]byte, error) {
239239
})
240240
}
241241

242-
func NewLoadBalance(option *GroupCommonOption, providers []provider.ProxyProvider, strategy string) (lb *LoadBalance, err error) {
242+
func NewLoadBalance(option *GroupCommonOption, providers []P.ProxyProvider, strategy string) (lb *LoadBalance, err error) {
243243
var strategyFn strategyFn
244244
switch strategy {
245245
case "consistent-hashing":

adapter/outboundgroup/parser.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/metacubex/mihomo/common/structure"
1212
"github.com/metacubex/mihomo/common/utils"
1313
C "github.com/metacubex/mihomo/constant"
14-
types "github.com/metacubex/mihomo/constant/provider"
14+
P "github.com/metacubex/mihomo/constant/provider"
1515
"github.com/metacubex/mihomo/log"
1616
)
1717

@@ -48,7 +48,7 @@ type GroupCommonOption struct {
4848
RoutingMark int `group:"routing-mark,omitempty"`
4949
}
5050

51-
func ParseProxyGroup(config map[string]any, proxyMap map[string]C.Proxy, providersMap map[string]types.ProxyProvider, AllProxies []string, AllProviders []string) (C.ProxyAdapter, error) {
51+
func ParseProxyGroup(config map[string]any, proxyMap map[string]C.Proxy, providersMap map[string]P.ProxyProvider, AllProxies []string, AllProviders []string) (C.ProxyAdapter, error) {
5252
decoder := structure.NewDecoder(structure.Option{TagName: "group", WeaklyTypedInput: true})
5353

5454
groupOption := &GroupCommonOption{
@@ -71,7 +71,7 @@ func ParseProxyGroup(config map[string]any, proxyMap map[string]C.Proxy, provide
7171

7272
groupName := groupOption.Name
7373

74-
providers := []types.ProxyProvider{}
74+
providers := []P.ProxyProvider{}
7575

7676
if groupOption.IncludeAll {
7777
groupOption.IncludeAllProviders = true
@@ -169,7 +169,7 @@ func ParseProxyGroup(config map[string]any, proxyMap map[string]C.Proxy, provide
169169
return nil, fmt.Errorf("%s: %w", groupName, err)
170170
}
171171

172-
providers = append([]types.ProxyProvider{pd}, providers...)
172+
providers = append([]P.ProxyProvider{pd}, providers...)
173173
providersMap[groupName] = pd
174174
}
175175

@@ -206,23 +206,23 @@ func getProxies(mapping map[string]C.Proxy, list []string) ([]C.Proxy, error) {
206206
return ps, nil
207207
}
208208

209-
func getProviders(mapping map[string]types.ProxyProvider, list []string) ([]types.ProxyProvider, error) {
210-
var ps []types.ProxyProvider
209+
func getProviders(mapping map[string]P.ProxyProvider, list []string) ([]P.ProxyProvider, error) {
210+
var ps []P.ProxyProvider
211211
for _, name := range list {
212212
p, ok := mapping[name]
213213
if !ok {
214214
return nil, fmt.Errorf("'%s' not found", name)
215215
}
216216

217-
if p.VehicleType() == types.Compatible {
217+
if p.VehicleType() == P.Compatible {
218218
return nil, fmt.Errorf("proxy group %s can't contains in `use`", name)
219219
}
220220
ps = append(ps, p)
221221
}
222222
return ps, nil
223223
}
224224

225-
func addTestUrlToProviders(providers []types.ProxyProvider, url string, expectedStatus utils.IntRanges[uint16], filter string, interval uint) {
225+
func addTestUrlToProviders(providers []P.ProxyProvider, url string, expectedStatus utils.IntRanges[uint16], filter string, interval uint) {
226226
if len(providers) == 0 || len(url) == 0 {
227227
return
228228
}

adapter/outboundgroup/patch_android.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@ package outboundgroup
44

55
import (
66
C "github.com/metacubex/mihomo/constant"
7-
"github.com/metacubex/mihomo/constant/provider"
7+
P "github.com/metacubex/mihomo/constant/provider"
88
)
99

1010
type ProxyGroup interface {
1111
C.ProxyAdapter
1212

13-
Providers() []provider.ProxyProvider
13+
Providers() []P.ProxyProvider
1414
Proxies() []C.Proxy
1515
Now() string
1616
}
1717

18-
func (f *Fallback) Providers() []provider.ProxyProvider {
18+
func (f *Fallback) Providers() []P.ProxyProvider {
1919
return f.providers
2020
}
2121

22-
func (lb *LoadBalance) Providers() []provider.ProxyProvider {
22+
func (lb *LoadBalance) Providers() []P.ProxyProvider {
2323
return lb.providers
2424
}
2525

@@ -35,7 +35,7 @@ func (lb *LoadBalance) Now() string {
3535
return ""
3636
}
3737

38-
func (r *Relay) Providers() []provider.ProxyProvider {
38+
func (r *Relay) Providers() []P.ProxyProvider {
3939
return r.providers
4040
}
4141

@@ -47,15 +47,15 @@ func (r *Relay) Now() string {
4747
return ""
4848
}
4949

50-
func (s *Selector) Providers() []provider.ProxyProvider {
50+
func (s *Selector) Providers() []P.ProxyProvider {
5151
return s.providers
5252
}
5353

5454
func (s *Selector) Proxies() []C.Proxy {
5555
return s.GetProxies(false)
5656
}
5757

58-
func (u *URLTest) Providers() []provider.ProxyProvider {
58+
func (u *URLTest) Providers() []P.ProxyProvider {
5959
return u.providers
6060
}
6161

adapter/outboundgroup/relay.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/metacubex/mihomo/component/dialer"
99
"github.com/metacubex/mihomo/component/proxydialer"
1010
C "github.com/metacubex/mihomo/constant"
11-
"github.com/metacubex/mihomo/constant/provider"
11+
P "github.com/metacubex/mihomo/constant/provider"
1212
"github.com/metacubex/mihomo/log"
1313
)
1414

@@ -149,7 +149,7 @@ func (r *Relay) Addr() string {
149149
return proxies[len(proxies)-1].Addr()
150150
}
151151

152-
func NewRelay(option *GroupCommonOption, providers []provider.ProxyProvider) *Relay {
152+
func NewRelay(option *GroupCommonOption, providers []P.ProxyProvider) *Relay {
153153
log.Warnln("The group [%s] with relay type is deprecated, please using dialer-proxy instead", option.Name)
154154
return &Relay{
155155
GroupBase: NewGroupBase(GroupBaseOption{

adapter/outboundgroup/selector.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"errors"
77

88
C "github.com/metacubex/mihomo/constant"
9-
"github.com/metacubex/mihomo/constant/provider"
9+
P "github.com/metacubex/mihomo/constant/provider"
1010
)
1111

1212
type Selector struct {
@@ -108,7 +108,7 @@ func (s *Selector) selectedProxy(touch bool) C.Proxy {
108108
return proxies[0]
109109
}
110110

111-
func NewSelector(option *GroupCommonOption, providers []provider.ProxyProvider) *Selector {
111+
func NewSelector(option *GroupCommonOption, providers []P.ProxyProvider) *Selector {
112112
return &Selector{
113113
GroupBase: NewGroupBase(GroupBaseOption{
114114
Name: option.Name,

adapter/outboundgroup/urltest.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/metacubex/mihomo/common/singledo"
1212
"github.com/metacubex/mihomo/common/utils"
1313
C "github.com/metacubex/mihomo/constant"
14-
"github.com/metacubex/mihomo/constant/provider"
14+
P "github.com/metacubex/mihomo/constant/provider"
1515
)
1616

1717
type urlTestOption func(*URLTest)
@@ -202,7 +202,7 @@ func parseURLTestOption(config map[string]any) []urlTestOption {
202202
return opts
203203
}
204204

205-
func NewURLTest(option *GroupCommonOption, providers []provider.ProxyProvider, options ...urlTestOption) *URLTest {
205+
func NewURLTest(option *GroupCommonOption, providers []P.ProxyProvider, options ...urlTestOption) *URLTest {
206206
urlTest := &URLTest{
207207
GroupBase: NewGroupBase(GroupBaseOption{
208208
Name: option.Name,

adapter/provider/parser.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/metacubex/mihomo/common/utils"
1111
"github.com/metacubex/mihomo/component/resource"
1212
C "github.com/metacubex/mihomo/constant"
13-
types "github.com/metacubex/mihomo/constant/provider"
13+
P "github.com/metacubex/mihomo/constant/provider"
1414

1515
"github.com/dlclark/regexp2"
1616
)
@@ -73,7 +73,7 @@ type proxyProviderSchema struct {
7373
Header map[string][]string `provider:"header,omitempty"`
7474
}
7575

76-
func ParseProxyProvider(name string, mapping map[string]any) (types.ProxyProvider, error) {
76+
func ParseProxyProvider(name string, mapping map[string]any) (P.ProxyProvider, error) {
7777
decoder := structure.NewDecoder(structure.Option{TagName: "provider", WeaklyTypedInput: true})
7878

7979
schema := &proxyProviderSchema{
@@ -104,7 +104,7 @@ func ParseProxyProvider(name string, mapping map[string]any) (types.ProxyProvide
104104
return nil, err
105105
}
106106

107-
var vehicle types.Vehicle
107+
var vehicle P.Vehicle
108108
switch schema.Type {
109109
case "file":
110110
path := C.Path.Resolve(schema.Path)

adapter/provider/provider.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
"github.com/metacubex/mihomo/component/profile/cachefile"
1717
"github.com/metacubex/mihomo/component/resource"
1818
C "github.com/metacubex/mihomo/constant"
19-
types "github.com/metacubex/mihomo/constant/provider"
19+
P "github.com/metacubex/mihomo/constant/provider"
2020
"github.com/metacubex/mihomo/tunnel/statistic"
2121

2222
"github.com/dlclark/regexp2"
@@ -68,8 +68,8 @@ func (bp *baseProvider) HealthCheck() {
6868
bp.healthCheck.check()
6969
}
7070

71-
func (bp *baseProvider) Type() types.ProviderType {
72-
return types.Proxy
71+
func (bp *baseProvider) Type() P.ProviderType {
72+
return P.Proxy
7373
}
7474

7575
func (bp *baseProvider) Proxies() []C.Proxy {
@@ -171,7 +171,7 @@ func (pp *proxySetProvider) Close() error {
171171
return pp.Fetcher.Close()
172172
}
173173

174-
func NewProxySetProvider(name string, interval time.Duration, payload []map[string]any, parser resource.Parser[[]C.Proxy], vehicle types.Vehicle, hc *HealthCheck) (*ProxySetProvider, error) {
174+
func NewProxySetProvider(name string, interval time.Duration, payload []map[string]any, parser resource.Parser[[]C.Proxy], vehicle P.Vehicle, hc *HealthCheck) (*ProxySetProvider, error) {
175175
pd := &proxySetProvider{
176176
baseProvider: baseProvider{
177177
name: name,
@@ -238,8 +238,8 @@ func (ip *inlineProvider) MarshalJSON() ([]byte, error) {
238238
})
239239
}
240240

241-
func (ip *inlineProvider) VehicleType() types.VehicleType {
242-
return types.Inline
241+
func (ip *inlineProvider) VehicleType() P.VehicleType {
242+
return P.Inline
243243
}
244244

245245
func (ip *inlineProvider) Update() error {
@@ -303,8 +303,8 @@ func (cp *compatibleProvider) Update() error {
303303
return nil
304304
}
305305

306-
func (cp *compatibleProvider) VehicleType() types.VehicleType {
307-
return types.Compatible
306+
func (cp *compatibleProvider) VehicleType() P.VehicleType {
307+
return P.Compatible
308308
}
309309

310310
func NewCompatibleProvider(name string, proxies []C.Proxy, hc *HealthCheck) (*CompatibleProvider, error) {

0 commit comments

Comments
 (0)