diff --git a/README.md b/README.md index c477a77..f14e684 100644 --- a/README.md +++ b/README.md @@ -93,10 +93,10 @@ glider -config CONFIG_PATH glider -verbose -listen :8443 -forward SCHEME://HOST:PORT ``` -**Help:** `glider -help` +**Help:**
-click to see details +`glider -help` click to see details ```bash Usage: glider [-listen URL]... [-forward URL]... [OPTION]... @@ -115,6 +115,8 @@ OPTION: check disabled fowarders only -checkinterval int fowarder check interval(seconds) (default 30) + -checklatencysamples int + use the average latency of the latest N checks (default 10) -checktimeout int fowarder check timeout(seconds) (default 10) -checktolerance int @@ -191,7 +193,7 @@ URL: -forward socks5://serverA:1080,socks5://serverB:1080 (proxy chain) 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 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
-**Schemes:** `glider -scheme all` +**Schemes:**
-click to see details +`glider -scheme all` click to see details ```bash KCP scheme: @@ -337,10 +339,10 @@ TLS and Websocket with a specified proxy protocol:
-**Examples:** `glider -example` +**Examples:**
-click to see details +`glider -example` click to see details ```bash Examples: diff --git a/config.go b/config.go index 271ec73..d032ba9 100644 --- a/config.go +++ b/config.go @@ -66,7 +66,7 @@ check=disable: disable health check`) 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.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.IntVar(&conf.Strategy.MaxFailures, "maxfailures", 3, "max failures to change forwarder status to disabled") flag.IntVar(&conf.Strategy.DialTimeout, "dialtimeout", 3, "dial timeout(seconds)") diff --git a/config/glider.conf.example b/config/glider.conf.example index 793a9a7..9843109 100644 --- a/config/glider.conf.example +++ b/config/glider.conf.example @@ -208,6 +208,9 @@ checktimeout=10 # switch forwarder only when new_latency < old_latency - tolerance, used in lha mode checktolerance=100 +# use the average latency of the latest N checks +checklatencysamples=10 + # check disabled fowarders only checkdisabledonly=false diff --git a/rule/config.go b/rule/config.go index 82deaeb..77e653f 100644 --- a/rule/config.go +++ b/rule/config.go @@ -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.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.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.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") diff --git a/rule/group.go b/rule/group.go index dd3aa12..7d3272a 100644 --- a/rule/group.go +++ b/rule/group.go @@ -276,8 +276,8 @@ func (p *FwdrGroup) check(fwdr *Forwarder, checker Checker) { func (p *FwdrGroup) setLatency(fwdr *Forwarder, elapsed time.Duration) { newLatency := int64(elapsed) if cnt := p.config.CheckLatencySamples; cnt > 1 { - if lastLagency := fwdr.Latency(); lastLagency > 0 { - newLatency = (lastLagency*(int64(cnt)-1) + int64(elapsed)) / int64(cnt) + if lastLatency := fwdr.Latency(); lastLatency > 0 { + newLatency = (lastLatency*(int64(cnt)-1) + int64(elapsed)) / int64(cnt) } } fwdr.SetLatency(newLatency)