mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 11:42:43 +08:00
Fix: rename delay --> interval
This commit is contained in:
parent
a0f077b091
commit
40a94be208
|
@ -109,10 +109,10 @@ Proxy:
|
|||
|
||||
Proxy Group:
|
||||
# url-test select which proxy will be used by benchmarking speed to a URL.
|
||||
- { name: "auto", type: url-test, proxies: ["ss1", "ss2", "vmess1"], url: http://www.gstatic.com/generate_204, delay: 300 }
|
||||
- { name: "auto", type: url-test, proxies: ["ss1", "ss2", "vmess1"], url: http://www.gstatic.com/generate_204, interval: 300 }
|
||||
|
||||
# fallback select an available policy by priority. The availability is tested by accessing an URL, just like an auto url-test group.
|
||||
- { name: "fallback-auto", type: fallback, proxies: ["ss1", "ss2", "vmess1"], url: http://www.gstatic.com/generate_204, delay: 300 }
|
||||
- { name: "fallback-auto", type: fallback, proxies: ["ss1", "ss2", "vmess1"], url: http://www.gstatic.com/generate_204, interval: 300 }
|
||||
|
||||
# select is used for selecting proxy or proxy group
|
||||
# you can use RESTful API to switch proxy, is recommended for use in GUI.
|
||||
|
|
|
@ -17,7 +17,7 @@ type Fallback struct {
|
|||
name string
|
||||
proxies []*proxy
|
||||
rawURL string
|
||||
delay time.Duration
|
||||
interval time.Duration
|
||||
done chan struct{}
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ type FallbackOption struct {
|
|||
Name string `proxy:"name"`
|
||||
Proxies []string `proxy:"proxies"`
|
||||
URL string `proxy:"url"`
|
||||
Delay int `proxy:"delay"`
|
||||
Interval int `proxy:"interval"`
|
||||
}
|
||||
|
||||
func (f *Fallback) Name() string {
|
||||
|
@ -68,7 +68,7 @@ func (f *Fallback) Close() {
|
|||
}
|
||||
|
||||
func (f *Fallback) loop() {
|
||||
tick := time.NewTicker(f.delay)
|
||||
tick := time.NewTicker(f.interval)
|
||||
go f.validTest()
|
||||
Loop:
|
||||
for {
|
||||
|
@ -115,7 +115,7 @@ func NewFallback(option FallbackOption, proxies []C.Proxy) (*Fallback, error) {
|
|||
return nil, errors.New("The number of proxies cannot be 0")
|
||||
}
|
||||
|
||||
delay := time.Duration(option.Delay) * time.Second
|
||||
interval := time.Duration(option.Interval) * time.Second
|
||||
warpperProxies := make([]*proxy, len(proxies))
|
||||
for idx := range proxies {
|
||||
warpperProxies[idx] = &proxy{
|
||||
|
@ -128,7 +128,7 @@ func NewFallback(option FallbackOption, proxies []C.Proxy) (*Fallback, error) {
|
|||
name: option.Name,
|
||||
proxies: warpperProxies,
|
||||
rawURL: option.URL,
|
||||
delay: delay,
|
||||
interval: interval,
|
||||
done: make(chan struct{}),
|
||||
}
|
||||
go Fallback.loop()
|
||||
|
|
|
@ -13,7 +13,7 @@ type URLTest struct {
|
|||
proxies []C.Proxy
|
||||
rawURL string
|
||||
fast C.Proxy
|
||||
delay time.Duration
|
||||
interval time.Duration
|
||||
done chan struct{}
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ type URLTestOption struct {
|
|||
Name string `proxy:"name"`
|
||||
Proxies []string `proxy:"proxies"`
|
||||
URL string `proxy:"url"`
|
||||
Delay int `proxy:"delay"`
|
||||
Interval int `proxy:"interval"`
|
||||
}
|
||||
|
||||
func (u *URLTest) Name() string {
|
||||
|
@ -45,7 +45,7 @@ func (u *URLTest) Close() {
|
|||
}
|
||||
|
||||
func (u *URLTest) loop() {
|
||||
tick := time.NewTicker(u.delay)
|
||||
tick := time.NewTicker(u.interval)
|
||||
go u.speedTest()
|
||||
Loop:
|
||||
for {
|
||||
|
@ -63,7 +63,7 @@ func (u *URLTest) speedTest() {
|
|||
wg.Add(len(u.proxies))
|
||||
c := make(chan interface{})
|
||||
fast := selectFast(c)
|
||||
timer := time.NewTimer(u.delay)
|
||||
timer := time.NewTimer(u.interval)
|
||||
|
||||
for _, p := range u.proxies {
|
||||
go func(p C.Proxy) {
|
||||
|
@ -100,13 +100,13 @@ func NewURLTest(option URLTestOption, proxies []C.Proxy) (*URLTest, error) {
|
|||
return nil, errors.New("The number of proxies cannot be 0")
|
||||
}
|
||||
|
||||
delay := time.Duration(option.Delay) * time.Second
|
||||
interval := time.Duration(option.Interval) * time.Second
|
||||
urlTest := &URLTest{
|
||||
name: option.Name,
|
||||
proxies: proxies[:],
|
||||
rawURL: option.URL,
|
||||
fast: proxies[0],
|
||||
delay: delay,
|
||||
interval: interval,
|
||||
done: make(chan struct{}),
|
||||
}
|
||||
go urlTest.loop()
|
||||
|
|
Loading…
Reference in New Issue
Block a user