From 47547bb08d31e1e9087821f3310fbcda4216cc59 Mon Sep 17 00:00:00 2001 From: nadoo <287492+nadoo@users.noreply.github.com> Date: Sun, 6 Jan 2019 21:01:20 +0800 Subject: [PATCH] config: change checkduration to checkinterval --- README.md | 2 +- conf.go | 3 +-- config/README.md | 6 +++--- config/examples/4.multiple_forwarders/glider.conf | 4 ++-- config/examples/5.rule_default_direct/office.rule | 2 +- config/examples/6.rule_default_forwarder/glider.conf | 2 +- .../examples/7.rule_multiple_rule_files/rules.d/home.rule | 2 +- .../examples/7.rule_multiple_rule_files/rules.d/office.rule | 2 +- config/examples/8.transparent_proxy_with_dnsmasq/README.md | 2 +- .../examples/8.transparent_proxy_with_dnsmasq/glider.conf | 2 +- .../examples/9.transparent_proxy_without_dnsmasq/README.md | 2 +- .../9.transparent_proxy_without_dnsmasq/rules.d/home.rule | 2 +- .../9.transparent_proxy_without_dnsmasq/rules.d/office.rule | 2 +- config/glider.conf.example | 4 ++-- config/rules.d/office.rule.example | 2 +- rule/config.go | 3 +-- 16 files changed, 20 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 23524a0..54d848c 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,7 @@ glider -config CONFIGPATH -listen :8080 -verbose ```bash glider v0.6.10 usage: - -checkduration int + -checkinterval int proxy check interval(seconds) (default 30) -checkwebsite string proxy check HTTP(NOT HTTPS) website address, format: HOST[:PORT], default port: 80 (default "www.apple.com") diff --git a/conf.go b/conf.go index df1ebc1..57539be 100644 --- a/conf.go +++ b/conf.go @@ -39,8 +39,7 @@ func confInit() { flag.StringSliceUniqVar(&conf.Forward, "forward", nil, "forward url, format: SCHEME://[USER|METHOD:PASSWORD@][HOST]:PORT?PARAMS[,SCHEME://[USER|METHOD:PASSWORD@][HOST]:PORT?PARAMS]") flag.StringVar(&conf.StrategyConfig.Strategy, "strategy", "rr", "forward strategy, default: rr") flag.StringVar(&conf.StrategyConfig.CheckWebSite, "checkwebsite", "www.apple.com", "proxy check HTTP(NOT HTTPS) website address, format: HOST[:PORT], default port: 80") - // TODO: change to checkinterval - flag.IntVar(&conf.StrategyConfig.CheckInterval, "checkduration", 30, "proxy check interval(seconds)") + flag.IntVar(&conf.StrategyConfig.CheckInterval, "checkinterval", 30, "proxy check interval(seconds)") flag.IntVar(&conf.StrategyConfig.MaxFailures, "maxfailures", 3, "max failures to change forwarder status to disabled") flag.StringVar(&conf.StrategyConfig.IntFace, "interface", "", "source ip or source interface") diff --git a/config/README.md b/config/README.md index 9796877..ed31011 100644 --- a/config/README.md +++ b/config/README.md @@ -31,8 +31,8 @@ strategy=rr # MUST be a HTTP website server address, format: HOST[:PORT]. HTTPS NOT SUPPORTED. checkwebsite=www.apple.com -# check duration -checkduration=30 +# check interval +checkinterval=30 # Setup a dns forwarding server @@ -58,7 +58,7 @@ forward=ss://method:pass@1.1.1.1:8443 forward=http://192.168.2.1:8080,socks5://192.168.2.2:1080 strategy=rr checkwebsite=www.apple.com -checkduration=30 +checkinterval=30 # DNS SERVER for domains in this rule file dnsserver=208.67.222.222:53 diff --git a/config/examples/4.multiple_forwarders/glider.conf b/config/examples/4.multiple_forwarders/glider.conf index 91252f9..2c982f1 100644 --- a/config/examples/4.multiple_forwarders/glider.conf +++ b/config/examples/4.multiple_forwarders/glider.conf @@ -17,5 +17,5 @@ strategy=rr # MUST be a HTTP website server address, format: HOST[:PORT]. HTTPS NOT SUPPORTED. checkwebsite=www.apple.com -# check duration(seconds) -checkduration=30 +# check interval(seconds) +checkinterval=30 diff --git a/config/examples/5.rule_default_direct/office.rule b/config/examples/5.rule_default_direct/office.rule index 5b1330d..9999085 100644 --- a/config/examples/5.rule_default_direct/office.rule +++ b/config/examples/5.rule_default_direct/office.rule @@ -9,7 +9,7 @@ forward=http://1.1.1.1:8080 strategy=rr checkwebsite=www.apple.com -checkduration=30 +checkinterval=30 # matches abc.com and *.abc.com diff --git a/config/examples/6.rule_default_forwarder/glider.conf b/config/examples/6.rule_default_forwarder/glider.conf index e98b807..90240ec 100644 --- a/config/examples/6.rule_default_forwarder/glider.conf +++ b/config/examples/6.rule_default_forwarder/glider.conf @@ -14,7 +14,7 @@ forward=http://1.1.1.1:8080 strategy=rr checkwebsite=www.apple.com -checkduration=30 +checkinterval=30 # NOTE HERE: diff --git a/config/examples/7.rule_multiple_rule_files/rules.d/home.rule b/config/examples/7.rule_multiple_rule_files/rules.d/home.rule index 06759cb..0c84e64 100644 --- a/config/examples/7.rule_multiple_rule_files/rules.d/home.rule +++ b/config/examples/7.rule_multiple_rule_files/rules.d/home.rule @@ -11,7 +11,7 @@ forward=http://forwarder5:8080,socks6://forwarder3:1080 strategy=rr checkwebsite=www.apple.com -checkduration=30 +checkinterval=30 # matches 192.168.0.0/16 diff --git a/config/examples/7.rule_multiple_rule_files/rules.d/office.rule b/config/examples/7.rule_multiple_rule_files/rules.d/office.rule index 3ff311f..5294968 100644 --- a/config/examples/7.rule_multiple_rule_files/rules.d/office.rule +++ b/config/examples/7.rule_multiple_rule_files/rules.d/office.rule @@ -11,7 +11,7 @@ forward=http://forwarder2:8080,socks5://forwarder3:1080 strategy=rr checkwebsite=www.apple.com -checkduration=30 +checkinterval=30 # matches 172.16.0.0/24 diff --git a/config/examples/8.transparent_proxy_with_dnsmasq/README.md b/config/examples/8.transparent_proxy_with_dnsmasq/README.md index 56e8118..b38c251 100644 --- a/config/examples/8.transparent_proxy_with_dnsmasq/README.md +++ b/config/examples/8.transparent_proxy_with_dnsmasq/README.md @@ -12,7 +12,7 @@ dns=:5353 dnsserver=8.8.8.8:53 strategy=rr checkwebsite=www.apple.com -checkduration=30 +checkinterval=30 ``` #### Create a ipset manually diff --git a/config/examples/8.transparent_proxy_with_dnsmasq/glider.conf b/config/examples/8.transparent_proxy_with_dnsmasq/glider.conf index 491c4f2..1632525 100644 --- a/config/examples/8.transparent_proxy_with_dnsmasq/glider.conf +++ b/config/examples/8.transparent_proxy_with_dnsmasq/glider.conf @@ -13,4 +13,4 @@ dnsserver=8.8.8.8:53 strategy=rr checkwebsite=www.apple.com -checkduration=30 +checkinterval=30 diff --git a/config/examples/9.transparent_proxy_without_dnsmasq/README.md b/config/examples/9.transparent_proxy_without_dnsmasq/README.md index e730a64..06820ab 100644 --- a/config/examples/9.transparent_proxy_without_dnsmasq/README.md +++ b/config/examples/9.transparent_proxy_without_dnsmasq/README.md @@ -38,7 +38,7 @@ forward=http://forwarder1:8080,socks5://forwarder2:1080 forward=http://1.1.1.1:8080 strategy=rr checkwebsite=www.apple.com -checkduration=30 +checkinterval=30 # specify a different dns server(if need) dnsserver=208.67.222.222:53 diff --git a/config/examples/9.transparent_proxy_without_dnsmasq/rules.d/home.rule b/config/examples/9.transparent_proxy_without_dnsmasq/rules.d/home.rule index 0660982..b863aba 100644 --- a/config/examples/9.transparent_proxy_without_dnsmasq/rules.d/home.rule +++ b/config/examples/9.transparent_proxy_without_dnsmasq/rules.d/home.rule @@ -11,7 +11,7 @@ forward=http://forwarder5:8080,socks5://forwarder3:1080 strategy=rr checkwebsite=www.apple.com -checkduration=30 +checkinterval=30 # as a ipset manager ipset=glider diff --git a/config/examples/9.transparent_proxy_without_dnsmasq/rules.d/office.rule b/config/examples/9.transparent_proxy_without_dnsmasq/rules.d/office.rule index 1f91f9f..23b9e45 100644 --- a/config/examples/9.transparent_proxy_without_dnsmasq/rules.d/office.rule +++ b/config/examples/9.transparent_proxy_without_dnsmasq/rules.d/office.rule @@ -10,7 +10,7 @@ forward=http://forwarder2:8080,socks5://forwarder3:1080 # High Availability mode: ha strategy=rr checkwebsite=www.apple.com -checkduration=30 +checkinterval=30 # specify a different dns server(if need) dnsserver=208.67.222.222:53 diff --git a/config/glider.conf.example b/config/glider.conf.example index 796b0ad..5926a23 100644 --- a/config/glider.conf.example +++ b/config/glider.conf.example @@ -152,8 +152,8 @@ strategy=rr # MUST be a HTTP website server address, format: HOST[:PORT]. HTTPS NOT SUPPORTED. checkwebsite=www.apple.com -# check duration(seconds) -checkduration=30 +# check interval(seconds) +checkinterval=30 # DNS FORWARDING SERVER diff --git a/config/rules.d/office.rule.example b/config/rules.d/office.rule.example index 4147d83..cd20390 100644 --- a/config/rules.d/office.rule.example +++ b/config/rules.d/office.rule.example @@ -15,7 +15,7 @@ strategy=rr # FORWARDER CHECK SETTINGS checkwebsite=www.apple.com -checkduration=30 +checkinterval=30 # DNS SERVER for domains in this rule file dnsserver=208.67.222.222:53 diff --git a/rule/config.go b/rule/config.go index 9763e09..113d015 100644 --- a/rule/config.go +++ b/rule/config.go @@ -34,8 +34,7 @@ func NewConfFromFile(ruleFile string) (*Config, error) { f.StringSliceUniqVar(&p.Forward, "forward", nil, "forward url, format: SCHEME://[USER|METHOD:PASSWORD@][HOST]:PORT?PARAMS[,SCHEME://[USER|METHOD:PASSWORD@][HOST]:PORT?PARAMS]") f.StringVar(&p.StrategyConfig.Strategy, "strategy", "rr", "forward strategy, default: rr") f.StringVar(&p.StrategyConfig.CheckWebSite, "checkwebsite", "www.apple.com", "proxy check HTTP(NOT HTTPS) website address, format: HOST[:PORT], default port: 80") - // TODO: change to checkinterval - f.IntVar(&p.StrategyConfig.CheckInterval, "checkduration", 30, "proxy check interval(seconds)") + f.IntVar(&p.StrategyConfig.CheckInterval, "checkinterval", 30, "proxy check interval(seconds)") f.StringVar(&p.StrategyConfig.IntFace, "interface", "", "source ip or source interface") f.StringSliceUniqVar(&p.DNSServers, "dnsserver", nil, "remote dns server")