mirror of
https://github.com/nadoo/glider.git
synced 2025-02-23 01:15:41 +08:00
check: set checklatencysamples
default to 10 (#282)
This commit is contained in:
parent
fa97a44e8d
commit
f96ad73c7d
16
README.md
16
README.md
@ -93,10 +93,10 @@ glider -config CONFIG_PATH
|
|||||||
glider -verbose -listen :8443 -forward SCHEME://HOST:PORT
|
glider -verbose -listen :8443 -forward SCHEME://HOST:PORT
|
||||||
```
|
```
|
||||||
|
|
||||||
**Help:** `glider -help`
|
**Help:**
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>click to see details</summary>
|
<summary>`glider -help` click to see details</summary>
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
Usage: glider [-listen URL]... [-forward URL]... [OPTION]...
|
Usage: glider [-listen URL]... [-forward URL]... [OPTION]...
|
||||||
@ -115,6 +115,8 @@ OPTION:
|
|||||||
check disabled fowarders only
|
check disabled fowarders only
|
||||||
-checkinterval int
|
-checkinterval int
|
||||||
fowarder check interval(seconds) (default 30)
|
fowarder check interval(seconds) (default 30)
|
||||||
|
-checklatencysamples int
|
||||||
|
use the average latency of the latest N checks (default 10)
|
||||||
-checktimeout int
|
-checktimeout int
|
||||||
fowarder check timeout(seconds) (default 10)
|
fowarder check timeout(seconds) (default 10)
|
||||||
-checktolerance int
|
-checktolerance int
|
||||||
@ -191,7 +193,7 @@ URL:
|
|||||||
-forward socks5://serverA:1080,socks5://serverB:1080 (proxy chain)
|
-forward socks5://serverA:1080,socks5://serverB:1080 (proxy chain)
|
||||||
|
|
||||||
SCHEME:
|
SCHEME:
|
||||||
listen : http kcp mixed pxyproto redir redir6 smux socks5 ss tcp tls tproxy trojan trojanc udp unix vless ws wss
|
listen : http kcp mixed pxyproto redir redir6 smux sni socks5 ss tcp tls tproxy trojan trojanc udp unix vless ws wss
|
||||||
forward: direct http kcp reject simple-obfs smux socks4 socks4a socks5 ss ssh ssr tcp tls trojan trojanc udp unix vless vmess ws wss
|
forward: direct http kcp reject simple-obfs smux socks4 socks4a socks5 ss ssh ssr tcp tls trojan trojanc udp unix vless vmess ws wss
|
||||||
|
|
||||||
Note: use 'glider -scheme all' or 'glider -scheme SCHEME' to see help info for the scheme.
|
Note: use 'glider -scheme all' or 'glider -scheme SCHEME' to see help info for the scheme.
|
||||||
@ -222,10 +224,10 @@ glider 0.16.0, https://github.com/nadoo/glider
|
|||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
**Schemes:** `glider -scheme all`
|
**Schemes:**
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>click to see details</summary>
|
<summary>`glider -scheme all` click to see details</summary>
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
KCP scheme:
|
KCP scheme:
|
||||||
@ -337,10 +339,10 @@ TLS and Websocket with a specified proxy protocol:
|
|||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
**Examples:** `glider -example`
|
**Examples:**
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>click to see details</summary>
|
<summary>`glider -example` click to see details</summary>
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
Examples:
|
Examples:
|
||||||
|
@ -66,7 +66,7 @@ check=disable: disable health check`)
|
|||||||
flag.IntVar(&conf.Strategy.CheckInterval, "checkinterval", 30, "fowarder check interval(seconds)")
|
flag.IntVar(&conf.Strategy.CheckInterval, "checkinterval", 30, "fowarder check interval(seconds)")
|
||||||
flag.IntVar(&conf.Strategy.CheckTimeout, "checktimeout", 10, "fowarder check timeout(seconds)")
|
flag.IntVar(&conf.Strategy.CheckTimeout, "checktimeout", 10, "fowarder check timeout(seconds)")
|
||||||
flag.IntVar(&conf.Strategy.CheckTolerance, "checktolerance", 0, "fowarder check tolerance(ms), switch only when new_latency < old_latency - tolerance, only used in lha mode")
|
flag.IntVar(&conf.Strategy.CheckTolerance, "checktolerance", 0, "fowarder check tolerance(ms), switch only when new_latency < old_latency - tolerance, only used in lha mode")
|
||||||
flag.IntVar(&conf.Strategy.CheckLatencySamples, "checklatencysamples", 1, "use the average latency of the latest N checks")
|
flag.IntVar(&conf.Strategy.CheckLatencySamples, "checklatencysamples", 10, "use the average latency of the latest N checks")
|
||||||
flag.BoolVar(&conf.Strategy.CheckDisabledOnly, "checkdisabledonly", false, "check disabled fowarders only")
|
flag.BoolVar(&conf.Strategy.CheckDisabledOnly, "checkdisabledonly", false, "check disabled fowarders only")
|
||||||
flag.IntVar(&conf.Strategy.MaxFailures, "maxfailures", 3, "max failures to change forwarder status to disabled")
|
flag.IntVar(&conf.Strategy.MaxFailures, "maxfailures", 3, "max failures to change forwarder status to disabled")
|
||||||
flag.IntVar(&conf.Strategy.DialTimeout, "dialtimeout", 3, "dial timeout(seconds)")
|
flag.IntVar(&conf.Strategy.DialTimeout, "dialtimeout", 3, "dial timeout(seconds)")
|
||||||
|
@ -208,6 +208,9 @@ checktimeout=10
|
|||||||
# switch forwarder only when new_latency < old_latency - tolerance, used in lha mode
|
# switch forwarder only when new_latency < old_latency - tolerance, used in lha mode
|
||||||
checktolerance=100
|
checktolerance=100
|
||||||
|
|
||||||
|
# use the average latency of the latest N checks
|
||||||
|
checklatencysamples=10
|
||||||
|
|
||||||
# check disabled fowarders only
|
# check disabled fowarders only
|
||||||
checkdisabledonly=false
|
checkdisabledonly=false
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ func NewConfFromFile(ruleFile string) (*Config, error) {
|
|||||||
f.StringVar(&p.Strategy.Check, "check", "http://www.msftconnecttest.com/connecttest.txt#expect=200", "check=tcp[://HOST:PORT]: tcp port connect check\ncheck=http://HOST[:PORT][/URI][#expect=STRING_IN_RESP_LINE]\ncheck=file://SCRIPT_PATH: run a check script, healthy when exitcode=0, environment variables: FORWARDER_ADDR\ncheck=disable: disable health check")
|
f.StringVar(&p.Strategy.Check, "check", "http://www.msftconnecttest.com/connecttest.txt#expect=200", "check=tcp[://HOST:PORT]: tcp port connect check\ncheck=http://HOST[:PORT][/URI][#expect=STRING_IN_RESP_LINE]\ncheck=file://SCRIPT_PATH: run a check script, healthy when exitcode=0, environment variables: FORWARDER_ADDR\ncheck=disable: disable health check")
|
||||||
f.IntVar(&p.Strategy.CheckInterval, "checkinterval", 30, "fowarder check interval(seconds)")
|
f.IntVar(&p.Strategy.CheckInterval, "checkinterval", 30, "fowarder check interval(seconds)")
|
||||||
f.IntVar(&p.Strategy.CheckTimeout, "checktimeout", 10, "fowarder check timeout(seconds)")
|
f.IntVar(&p.Strategy.CheckTimeout, "checktimeout", 10, "fowarder check timeout(seconds)")
|
||||||
f.IntVar(&p.Strategy.CheckLatencySamples, "checklatencysamples", 1, "use the average latency of the latest N checks")
|
f.IntVar(&p.Strategy.CheckLatencySamples, "checklatencysamples", 10, "use the average latency of the latest N checks")
|
||||||
f.IntVar(&p.Strategy.CheckTolerance, "checktolerance", 0, "fowarder check tolerance(ms), switch only when new_latency < old_latency - tolerance, only used in lha mode")
|
f.IntVar(&p.Strategy.CheckTolerance, "checktolerance", 0, "fowarder check tolerance(ms), switch only when new_latency < old_latency - tolerance, only used in lha mode")
|
||||||
f.BoolVar(&p.Strategy.CheckDisabledOnly, "checkdisabledonly", false, "check disabled fowarders only")
|
f.BoolVar(&p.Strategy.CheckDisabledOnly, "checkdisabledonly", false, "check disabled fowarders only")
|
||||||
f.IntVar(&p.Strategy.MaxFailures, "maxfailures", 3, "max failures to change forwarder status to disabled")
|
f.IntVar(&p.Strategy.MaxFailures, "maxfailures", 3, "max failures to change forwarder status to disabled")
|
||||||
|
@ -276,8 +276,8 @@ func (p *FwdrGroup) check(fwdr *Forwarder, checker Checker) {
|
|||||||
func (p *FwdrGroup) setLatency(fwdr *Forwarder, elapsed time.Duration) {
|
func (p *FwdrGroup) setLatency(fwdr *Forwarder, elapsed time.Duration) {
|
||||||
newLatency := int64(elapsed)
|
newLatency := int64(elapsed)
|
||||||
if cnt := p.config.CheckLatencySamples; cnt > 1 {
|
if cnt := p.config.CheckLatencySamples; cnt > 1 {
|
||||||
if lastLagency := fwdr.Latency(); lastLagency > 0 {
|
if lastLatency := fwdr.Latency(); lastLatency > 0 {
|
||||||
newLatency = (lastLagency*(int64(cnt)-1) + int64(elapsed)) / int64(cnt)
|
newLatency = (lastLatency*(int64(cnt)-1) + int64(elapsed)) / int64(cnt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fwdr.SetLatency(newLatency)
|
fwdr.SetLatency(newLatency)
|
||||||
|
Loading…
Reference in New Issue
Block a user