mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2025-02-23 12:42:27 +08:00
Fix: rename delay --> interval
This commit is contained in:
parent
a0f077b091
commit
40a94be208
@ -109,10 +109,10 @@ Proxy:
|
|||||||
|
|
||||||
Proxy Group:
|
Proxy Group:
|
||||||
# url-test select which proxy will be used by benchmarking speed to a URL.
|
# 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.
|
# 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
|
# select is used for selecting proxy or proxy group
|
||||||
# you can use RESTful API to switch proxy, is recommended for use in GUI.
|
# you can use RESTful API to switch proxy, is recommended for use in GUI.
|
||||||
|
@ -14,18 +14,18 @@ type proxy struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Fallback struct {
|
type Fallback struct {
|
||||||
name string
|
name string
|
||||||
proxies []*proxy
|
proxies []*proxy
|
||||||
rawURL string
|
rawURL string
|
||||||
delay time.Duration
|
interval time.Duration
|
||||||
done chan struct{}
|
done chan struct{}
|
||||||
}
|
}
|
||||||
|
|
||||||
type FallbackOption struct {
|
type FallbackOption struct {
|
||||||
Name string `proxy:"name"`
|
Name string `proxy:"name"`
|
||||||
Proxies []string `proxy:"proxies"`
|
Proxies []string `proxy:"proxies"`
|
||||||
URL string `proxy:"url"`
|
URL string `proxy:"url"`
|
||||||
Delay int `proxy:"delay"`
|
Interval int `proxy:"interval"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Fallback) Name() string {
|
func (f *Fallback) Name() string {
|
||||||
@ -68,7 +68,7 @@ func (f *Fallback) Close() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *Fallback) loop() {
|
func (f *Fallback) loop() {
|
||||||
tick := time.NewTicker(f.delay)
|
tick := time.NewTicker(f.interval)
|
||||||
go f.validTest()
|
go f.validTest()
|
||||||
Loop:
|
Loop:
|
||||||
for {
|
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")
|
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))
|
warpperProxies := make([]*proxy, len(proxies))
|
||||||
for idx := range proxies {
|
for idx := range proxies {
|
||||||
warpperProxies[idx] = &proxy{
|
warpperProxies[idx] = &proxy{
|
||||||
@ -125,11 +125,11 @@ func NewFallback(option FallbackOption, proxies []C.Proxy) (*Fallback, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Fallback := &Fallback{
|
Fallback := &Fallback{
|
||||||
name: option.Name,
|
name: option.Name,
|
||||||
proxies: warpperProxies,
|
proxies: warpperProxies,
|
||||||
rawURL: option.URL,
|
rawURL: option.URL,
|
||||||
delay: delay,
|
interval: interval,
|
||||||
done: make(chan struct{}),
|
done: make(chan struct{}),
|
||||||
}
|
}
|
||||||
go Fallback.loop()
|
go Fallback.loop()
|
||||||
return Fallback, nil
|
return Fallback, nil
|
||||||
|
@ -9,19 +9,19 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type URLTest struct {
|
type URLTest struct {
|
||||||
name string
|
name string
|
||||||
proxies []C.Proxy
|
proxies []C.Proxy
|
||||||
rawURL string
|
rawURL string
|
||||||
fast C.Proxy
|
fast C.Proxy
|
||||||
delay time.Duration
|
interval time.Duration
|
||||||
done chan struct{}
|
done chan struct{}
|
||||||
}
|
}
|
||||||
|
|
||||||
type URLTestOption struct {
|
type URLTestOption struct {
|
||||||
Name string `proxy:"name"`
|
Name string `proxy:"name"`
|
||||||
Proxies []string `proxy:"proxies"`
|
Proxies []string `proxy:"proxies"`
|
||||||
URL string `proxy:"url"`
|
URL string `proxy:"url"`
|
||||||
Delay int `proxy:"delay"`
|
Interval int `proxy:"interval"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *URLTest) Name() string {
|
func (u *URLTest) Name() string {
|
||||||
@ -45,7 +45,7 @@ func (u *URLTest) Close() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (u *URLTest) loop() {
|
func (u *URLTest) loop() {
|
||||||
tick := time.NewTicker(u.delay)
|
tick := time.NewTicker(u.interval)
|
||||||
go u.speedTest()
|
go u.speedTest()
|
||||||
Loop:
|
Loop:
|
||||||
for {
|
for {
|
||||||
@ -63,7 +63,7 @@ func (u *URLTest) speedTest() {
|
|||||||
wg.Add(len(u.proxies))
|
wg.Add(len(u.proxies))
|
||||||
c := make(chan interface{})
|
c := make(chan interface{})
|
||||||
fast := selectFast(c)
|
fast := selectFast(c)
|
||||||
timer := time.NewTimer(u.delay)
|
timer := time.NewTimer(u.interval)
|
||||||
|
|
||||||
for _, p := range u.proxies {
|
for _, p := range u.proxies {
|
||||||
go func(p C.Proxy) {
|
go func(p C.Proxy) {
|
||||||
@ -100,14 +100,14 @@ func NewURLTest(option URLTestOption, proxies []C.Proxy) (*URLTest, error) {
|
|||||||
return nil, errors.New("The number of proxies cannot be 0")
|
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{
|
urlTest := &URLTest{
|
||||||
name: option.Name,
|
name: option.Name,
|
||||||
proxies: proxies[:],
|
proxies: proxies[:],
|
||||||
rawURL: option.URL,
|
rawURL: option.URL,
|
||||||
fast: proxies[0],
|
fast: proxies[0],
|
||||||
delay: delay,
|
interval: interval,
|
||||||
done: make(chan struct{}),
|
done: make(chan struct{}),
|
||||||
}
|
}
|
||||||
go urlTest.loop()
|
go urlTest.loop()
|
||||||
return urlTest, nil
|
return urlTest, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user