Skip to content
This repository was archived by the owner on Oct 8, 2024. It is now read-only.

Commit 06953af

Browse files
committed
add timeout setting & bug fix
1 parent b05ea18 commit 06953af

File tree

9 files changed

+55
-43
lines changed

9 files changed

+55
-43
lines changed

README.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,15 @@ request: http # http / https
6060
domain: # default: 127.0.0.1
6161
port: # default: 80
6262

63-
cron_interval: 15 # default: 15 minutes
63+
cron_interval: 15 # default: 15 minutes
6464
show_remote_speed: true # default false
6565

6666
healthcheck_timeout: # default 5
67+
healthcheck_connection: # default 100
6768

68-
speedtest: # default false
69-
speed_timout: # default 10
70-
connection: # default 5
69+
speedtest: # default false
70+
speed_timout: # default 10
71+
speed_connection: # default 5
7172
```
7273
7374
If your web server port is not the same as proxypoolCheck serving port, you should put web server port in configuration, and set an environment variable `PORT` for proxypoolCheck to serve. This will be really helpful when you are doing frp.

README_zh_CN.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,11 @@ cron_interval: 15 # default: 15 minutes
7272
show_remote_speed: true # default false
7373

7474
healthcheck_timout: # default 5
75+
healthcheck_connection: # default 100
7576

76-
speedtest: # default false
77-
connection: # default 5
78-
speed_timout: # default 10
77+
speedtest: # default false
78+
speed_connection: # default 5
79+
speed_timout: # default 10
7980
```
8081
8182
需要修改的参数:
@@ -90,9 +91,10 @@ speed_timout: # default 10
9091
- `show_remote_speed`:显示远程速度,默认false,但建议改成true(因为作者写的就是true)
9192
- `cron_interval`:工作间隔,默认15分钟
9293
- `speedtest`:是否开启测速,默认关闭。开启测速会消耗大量流量。
93-
- `connection`:测速并发连接数,默认值为 5。
94+
- `speed_connection`:测速并发连接数,默认值为 5。
9495
- `speed_timeout`:单个节点测速时间限制,默认值为 10,单位为秒。超过此时间限制的节点会测速失败
9596
- `healthcheck_timeout`:单个节点健康检测时间限制,默认值为 5,单位为秒。超过此时间限制的节点为无效节点
97+
- `healthcheck_connection`:节点健康检测并发连接数,默认值为 100。丢失大量可用节点时可大幅减少此项数值。
9698

9799

98100
如果您的Web服务器端口与proxypoolCheck服务端口不同,应该将web服务器端口放在配置中,并且设置环境变量`PORT`以供proxypoolCheck服务。当您使用frp时,这将非常有帮助。

config/config.go

+23-13
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,17 @@ var configFilePath = "config.yaml"
1313

1414
// ConfigOptions is a struct that represents config files
1515
type ConfigOptions struct {
16-
ServerUrl []string `json:"server_url" yaml:"server_url"`
17-
Request string `json:"request" yaml:"request"`
18-
Domain string `json:"domain" yaml:"domain"`
19-
Port string `json:"port" yaml:"port"`
20-
HealthCheckTimeout int `json:"healthcheck_timeout" yaml:"healthcheck_timeout"`
21-
SpeedTest bool `json:"speedtest" yaml:"speedtest"`
22-
Connection int `json:"connection" yaml:"connection"`
23-
SpeedTimeout int `json:"speed_timeout" yaml:"speed_timeout"`
24-
ShowRemoteSpeed bool `json:"show_remote_speed" yaml:"show_remote_speed"`
25-
CronInterval uint64 `json:"cron_interval" yaml:"cron_interval"`
16+
ServerUrl []string `json:"server_url" yaml:"server_url"`
17+
Request string `json:"request" yaml:"request"`
18+
Domain string `json:"domain" yaml:"domain"`
19+
Port string `json:"port" yaml:"port"`
20+
HealthCheckTimeout int `json:"healthcheck_timeout" yaml:"healthcheck_timeout"`
21+
HealthCheckConnection int `json:"healthcheck_connection" yaml:"healthcheck_connection"`
22+
SpeedTest bool `json:"speedtest" yaml:"speedtest"`
23+
SpeedConnection int `json:"speed_connection" yaml:"speed_connection"`
24+
SpeedTimeout int `json:"speed_timeout" yaml:"speed_timeout"`
25+
ShowRemoteSpeed bool `json:"show_remote_speed" yaml:"show_remote_speed"`
26+
CronInterval uint64 `json:"cron_interval" yaml:"cron_interval"`
2627
}
2728

2829
var Config ConfigOptions
@@ -56,11 +57,20 @@ func Parse(path string) error {
5657
if Config.Request == ""{
5758
Config.Request = "http"
5859
}
59-
if Config.Connection == 0{
60-
Config.Connection = 5
60+
if Config.HealthCheckTimeout == 0{
61+
Config.HealthCheckTimeout = 5
62+
}
63+
if Config.HealthCheckConnection == 0{
64+
Config.HealthCheckConnection = 100
65+
}
66+
if Config.SpeedConnection == 0{
67+
Config.SpeedConnection = 15
68+
}
69+
if Config.SpeedTimeout == 0 {
70+
Config.SpeedTimeout = 10
6171
}
6272
if Config.CronInterval == 0{
63-
Config.Connection = 15
73+
Config.CronInterval = 15
6474
}
6575
return nil
6676
}

config/config.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ cron_interval: 15 # default: 15 minutes
1212
show_remote_speed: true # default false
1313

1414
healthcheck_timeout: # default 5
15+
healthcheck_connection: # default 100
1516

1617
speedtest: # default false
17-
connection: # default 5
18+
speed_connection: # default 5
1819
speed_timeout: # default 10

doc/WhatsNew.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2021-06-03
2+
- 添加健康检测并发数设置(v0.3.0)
3+
- 更新依赖,修复 send on closed channel
4+
15
2021-04-20
26
- 添加自定义timeout
37
- 更严格的有效性检查标准

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.16
44

55
require (
66
github.com/PuerkitoBio/goquery v1.6.0 // indirect
7-
github.com/Sansui233/proxypool v0.7.1
7+
github.com/Sansui233/proxypool v0.7.3
88
github.com/antchfx/xmlquery v1.3.3 // indirect
99
github.com/antchfx/xpath v1.1.11 // indirect
1010
github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b // indirect

go.sum

+2-13
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ github.com/Dreamacro/go-shadowsocks2 v0.1.7/go.mod h1:8p5G4cAj5ZlXwUR+Ww63gfSikr
1010
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
1111
github.com/PuerkitoBio/goquery v1.6.0 h1:j7taAbelrdcsOlGeMenZxc2AWXD5fieT1/znArdnx94=
1212
github.com/PuerkitoBio/goquery v1.6.0/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
13-
github.com/Sansui233/proxypool v0.7.1 h1:4fwyQd3B4BxxtJdo1V9ix6y5RY6IxEMte5no2fNza/Y=
14-
github.com/Sansui233/proxypool v0.7.1/go.mod h1:Bob6EbDesHKNp6By0+EXCwclOkzF73AXtEk1ygcKRyw=
13+
github.com/Sansui233/proxypool v0.7.3 h1:VhOPDN9ATjOYtrRQXDfjTgdAs1kn9FwICzgdRlVF9ts=
14+
github.com/Sansui233/proxypool v0.7.3/go.mod h1:IU0kt7Ig3oDiGj4MqX0yBL9Bqc0whjvs+ZHlm6no35Y=
1515
github.com/StackExchange/wmi v0.0.0-20170410192909-ea383cf3ba6e/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
1616
github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g=
1717
github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
@@ -35,12 +35,10 @@ github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b h1:L/QXpzIa3pO
3535
github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b/go.mod h1:H0wQNHz2YrLsuXOZozoeDmnHXkNCRmMW0gwFWDfEZDA=
3636
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
3737
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
38-
github.com/cloudflare/cloudflare-go v0.13.5/go.mod h1:OgJ1r3tslnIyWr7kX2OCBKUbSnUIyFKEIlZex9qgmIo=
3938
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
4039
github.com/codegangsta/negroni v1.0.0/go.mod h1:v0y3T5G7Y1UlFfyxFn/QLRU4a2EuNau2iZY63YTKWo0=
4140
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
4241
github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
43-
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
4442
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
4543
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4644
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
@@ -234,7 +232,6 @@ github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd
234232
github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ=
235233
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
236234
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
237-
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
238235
github.com/memcachier/mc v2.0.1+incompatible h1:s8EDz0xrJLP8goitwZOoq1vA/sm0fPS4X3KAF0nyhWQ=
239236
github.com/memcachier/mc v2.0.1+incompatible/go.mod h1:7bkvFE61leUBvXz+yxsOnGBQSZpBSPIMUQSmmSHvuXc=
240237
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQE9x6ikvDFZS2mDVS3drnohI=
@@ -247,7 +244,6 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN
247244
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
248245
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
249246
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
250-
github.com/olekukonko/tablewriter v0.0.4/go.mod h1:zq6QwlOf5SlnkVbMSr5EoBv3636FWnp+qbPhuoO21uA=
251247
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
252248
github.com/onsi/ginkgo v1.10.1 h1:q/mM8GF/n0shIN8SaAZ0V+jnLPzen6WIVZdiwrRlMlo=
253249
github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
@@ -279,15 +275,13 @@ github.com/rollbar/rollbar-go v1.2.0/go.mod h1:czC86b8U4xdUH7W2C6gomi2jutLm8qK0O
279275
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
280276
github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU=
281277
github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc=
282-
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
283278
github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca h1:NugYot0LIVPxTvN8n+Kvkn6TrbMyxQiuvKdEwFdR9vI=
284279
github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca/go.mod h1:uugorj2VCxiV1x+LzaIdVa9b4S4qGAcH6cbhh4qVxOU=
285280
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
286281
github.com/shirou/gopsutil v0.0.0-20180427012116-c95755e4bcd7/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
287282
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc=
288283
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
289284
github.com/shopspring/decimal v0.0.0-20200227202807-02e2044944cc/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
290-
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
291285
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
292286
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
293287
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
@@ -319,7 +313,6 @@ github.com/ugorji/go/codec v1.2.1 h1:/TRfW3XKkvWvmAYyCUaQlhoCDGjcvNR8xVVA/l5p/jQ
319313
github.com/ugorji/go/codec v1.2.1/go.mod h1:s/WxCRi46t8rA+fowL40EnmD7ec0XhR7ZypxeBNdzsM=
320314
github.com/unrolled/secure v1.0.1/go.mod h1:R6rugAuzh4TQpbFAq69oqZggyBQxFRFQIewtz5z7Jsc=
321315
github.com/urfave/cli v1.21.0/go.mod h1:lxDj6qX9Q6lWQxIrbrT0nwecwUtRnhVZAJjJZrVUZZQ=
322-
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
323316
github.com/x-cray/logrus-prefixed-formatter v0.5.2 h1:00txxvfBM9muc0jiLIEAkAcIMJzfthRT6usrui8uGmg=
324317
github.com/x-cray/logrus-prefixed-formatter v0.5.2/go.mod h1:2duySbKsL6M18s5GU7VPsoEPHyzalCE06qoARUCeBBE=
325318
github.com/xlab/treeprint v0.0.0-20180616005107-d6fb6747feb6/go.mod h1:ce1O1j6UtZfjr22oyGxGLbauSBp2YVXpARAosm7dHBg=
@@ -379,7 +372,6 @@ golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLL
379372
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
380373
golang.org/x/net v0.0.0-20200421231249-e086a090c8fd/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
381374
golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
382-
golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
383375
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
384376
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 h1:4nGaVu0QrbjT/AK2PRLuQfQuh6DJve+pELhqTdAj3x0=
385377
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
@@ -415,7 +407,6 @@ golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7w
415407
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
416408
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
417409
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
418-
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
419410
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
420411
golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
421412
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -430,7 +421,6 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
430421
golang.org/x/text v0.3.4 h1:0YWbFKbhXG/wIiuHDSKpS0Iy7FSA+u45VtBMfQcFTTc=
431422
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
432423
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
433-
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
434424
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
435425
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
436426
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -509,7 +499,6 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWD
509499
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
510500
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
511501
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
512-
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
513502
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
514503
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
515504
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=

internal/app/task.go

+10-7
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,24 @@ func InitApp() error{
4444
healthcheck.SpeedTimeout = time.Duration(config.Config.HealthCheckTimeout) * time.Second
4545
log.Printf("CONF: Health check timeout is set to %d seconds\n", config.Config.HealthCheckTimeout)
4646
}
47+
48+
// healthcheck setttings
49+
healthcheck.DelayConn = config.Config.HealthCheckConnection
50+
healthcheck.DelayTimeout = time.Duration(config.Config.HealthCheckTimeout) * time.Second
51+
healthcheck.SpeedConn = config.Config.SpeedConnection
52+
healthcheck.SpeedTimeout = time.Duration(config.Config.SpeedTimeout) * time.Second
53+
4754
proxies = healthcheck.CleanBadProxiesWithGrpool(proxies)
4855
log.Println("Usable proxy count: ", len(proxies))
4956

5057
// Save to cache
5158
cache.SetProxies("proxies", proxies)
5259
cache.UsableProxiesCount = len(proxies)
5360

54-
// Speed test
55-
if config.Config.SpeedTest == true{
56-
if config.Config.SpeedTimeout >= 0 {
57-
healthcheck.SpeedTimeout = time.Duration(config.Config.SpeedTimeout) * time.Second
58-
log.Printf("CONF: Speed test timeout is set to %d seconds\n", config.Config.SpeedTimeout)
59-
}
60-
healthcheck.SpeedTestAll(proxies, config.Config.Connection)
61+
if config.Config.SpeedTest == true {
62+
healthcheck.SpeedTestAll(proxies)
6163
}
64+
6265
cache.SetString("clashproxies", provider.Clash{
6366
provider.Base{
6467
Proxies: &proxies,

main.go

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ func main() {
1717
http.ListenAndServe("0.0.0.0:6061", nil)
1818
}()
1919

20+
//Slog.SetLevel(Slog.DEBUG) // Print original pack log
21+
2022
// fetch configuration
2123
flag.StringVar(&configFilePath, "c", "", "path to config file: config.yaml")
2224
flag.Parse()

0 commit comments

Comments
 (0)