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

Commit

Permalink
add timeout setting & bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Sansui233 committed Jun 2, 2021
1 parent b05ea18 commit 06953af
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 43 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,15 @@ request: http # http / https
domain: # default: 127.0.0.1
port: # default: 80

cron_interval: 15 # default: 15 minutes
cron_interval: 15 # default: 15 minutes
show_remote_speed: true # default false

healthcheck_timeout: # default 5
healthcheck_connection: # default 100

speedtest: # default false
speed_timout: # default 10
connection: # default 5
speedtest: # default false
speed_timout: # default 10
speed_connection: # default 5
```
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.
Expand Down
10 changes: 6 additions & 4 deletions README_zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,11 @@ cron_interval: 15 # default: 15 minutes
show_remote_speed: true # default false

healthcheck_timout: # default 5
healthcheck_connection: # default 100

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


如果您的Web服务器端口与proxypoolCheck服务端口不同,应该将web服务器端口放在配置中,并且设置环境变量`PORT`以供proxypoolCheck服务。当您使用frp时,这将非常有帮助。
Expand Down
36 changes: 23 additions & 13 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@ var configFilePath = "config.yaml"

// ConfigOptions is a struct that represents config files
type ConfigOptions struct {
ServerUrl []string `json:"server_url" yaml:"server_url"`
Request string `json:"request" yaml:"request"`
Domain string `json:"domain" yaml:"domain"`
Port string `json:"port" yaml:"port"`
HealthCheckTimeout int `json:"healthcheck_timeout" yaml:"healthcheck_timeout"`
SpeedTest bool `json:"speedtest" yaml:"speedtest"`
Connection int `json:"connection" yaml:"connection"`
SpeedTimeout int `json:"speed_timeout" yaml:"speed_timeout"`
ShowRemoteSpeed bool `json:"show_remote_speed" yaml:"show_remote_speed"`
CronInterval uint64 `json:"cron_interval" yaml:"cron_interval"`
ServerUrl []string `json:"server_url" yaml:"server_url"`
Request string `json:"request" yaml:"request"`
Domain string `json:"domain" yaml:"domain"`
Port string `json:"port" yaml:"port"`
HealthCheckTimeout int `json:"healthcheck_timeout" yaml:"healthcheck_timeout"`
HealthCheckConnection int `json:"healthcheck_connection" yaml:"healthcheck_connection"`
SpeedTest bool `json:"speedtest" yaml:"speedtest"`
SpeedConnection int `json:"speed_connection" yaml:"speed_connection"`
SpeedTimeout int `json:"speed_timeout" yaml:"speed_timeout"`
ShowRemoteSpeed bool `json:"show_remote_speed" yaml:"show_remote_speed"`
CronInterval uint64 `json:"cron_interval" yaml:"cron_interval"`
}

var Config ConfigOptions
Expand Down Expand Up @@ -56,11 +57,20 @@ func Parse(path string) error {
if Config.Request == ""{
Config.Request = "http"
}
if Config.Connection == 0{
Config.Connection = 5
if Config.HealthCheckTimeout == 0{
Config.HealthCheckTimeout = 5
}
if Config.HealthCheckConnection == 0{
Config.HealthCheckConnection = 100
}
if Config.SpeedConnection == 0{
Config.SpeedConnection = 15
}
if Config.SpeedTimeout == 0 {
Config.SpeedTimeout = 10
}
if Config.CronInterval == 0{
Config.Connection = 15
Config.CronInterval = 15
}
return nil
}
Expand Down
3 changes: 2 additions & 1 deletion config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ cron_interval: 15 # default: 15 minutes
show_remote_speed: true # default false

healthcheck_timeout: # default 5
healthcheck_connection: # default 100

speedtest: # default false
connection: # default 5
speed_connection: # default 5
speed_timeout: # default 10
4 changes: 4 additions & 0 deletions doc/WhatsNew.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2021-06-03
- 添加健康检测并发数设置(v0.3.0)
- 更新依赖,修复 send on closed channel

2021-04-20
- 添加自定义timeout
- 更严格的有效性检查标准
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.16

require (
github.com/PuerkitoBio/goquery v1.6.0 // indirect
github.com/Sansui233/proxypool v0.7.1
github.com/Sansui233/proxypool v0.7.3
github.com/antchfx/xmlquery v1.3.3 // indirect
github.com/antchfx/xpath v1.1.11 // indirect
github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b // indirect
Expand Down
15 changes: 2 additions & 13 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ github.com/Dreamacro/go-shadowsocks2 v0.1.7/go.mod h1:8p5G4cAj5ZlXwUR+Ww63gfSikr
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
github.com/PuerkitoBio/goquery v1.6.0 h1:j7taAbelrdcsOlGeMenZxc2AWXD5fieT1/znArdnx94=
github.com/PuerkitoBio/goquery v1.6.0/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
github.com/Sansui233/proxypool v0.7.1 h1:4fwyQd3B4BxxtJdo1V9ix6y5RY6IxEMte5no2fNza/Y=
github.com/Sansui233/proxypool v0.7.1/go.mod h1:Bob6EbDesHKNp6By0+EXCwclOkzF73AXtEk1ygcKRyw=
github.com/Sansui233/proxypool v0.7.3 h1:VhOPDN9ATjOYtrRQXDfjTgdAs1kn9FwICzgdRlVF9ts=
github.com/Sansui233/proxypool v0.7.3/go.mod h1:IU0kt7Ig3oDiGj4MqX0yBL9Bqc0whjvs+ZHlm6no35Y=
github.com/StackExchange/wmi v0.0.0-20170410192909-ea383cf3ba6e/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g=
github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
Expand All @@ -35,12 +35,10 @@ github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b h1:L/QXpzIa3pO
github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b/go.mod h1:H0wQNHz2YrLsuXOZozoeDmnHXkNCRmMW0gwFWDfEZDA=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cloudflare/cloudflare-go v0.13.5/go.mod h1:OgJ1r3tslnIyWr7kX2OCBKUbSnUIyFKEIlZex9qgmIo=
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
github.com/codegangsta/negroni v1.0.0/go.mod h1:v0y3T5G7Y1UlFfyxFn/QLRU4a2EuNau2iZY63YTKWo0=
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand Down Expand Up @@ -234,7 +232,6 @@ github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd
github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ=
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/memcachier/mc v2.0.1+incompatible h1:s8EDz0xrJLP8goitwZOoq1vA/sm0fPS4X3KAF0nyhWQ=
github.com/memcachier/mc v2.0.1+incompatible/go.mod h1:7bkvFE61leUBvXz+yxsOnGBQSZpBSPIMUQSmmSHvuXc=
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQE9x6ikvDFZS2mDVS3drnohI=
Expand All @@ -247,7 +244,6 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
github.com/olekukonko/tablewriter v0.0.4/go.mod h1:zq6QwlOf5SlnkVbMSr5EoBv3636FWnp+qbPhuoO21uA=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.10.1 h1:q/mM8GF/n0shIN8SaAZ0V+jnLPzen6WIVZdiwrRlMlo=
github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
Expand Down Expand Up @@ -279,15 +275,13 @@ github.com/rollbar/rollbar-go v1.2.0/go.mod h1:czC86b8U4xdUH7W2C6gomi2jutLm8qK0O
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU=
github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca h1:NugYot0LIVPxTvN8n+Kvkn6TrbMyxQiuvKdEwFdR9vI=
github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca/go.mod h1:uugorj2VCxiV1x+LzaIdVa9b4S4qGAcH6cbhh4qVxOU=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/shirou/gopsutil v0.0.0-20180427012116-c95755e4bcd7/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc=
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
github.com/shopspring/decimal v0.0.0-20200227202807-02e2044944cc/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
Expand Down Expand Up @@ -319,7 +313,6 @@ github.com/ugorji/go/codec v1.2.1 h1:/TRfW3XKkvWvmAYyCUaQlhoCDGjcvNR8xVVA/l5p/jQ
github.com/ugorji/go/codec v1.2.1/go.mod h1:s/WxCRi46t8rA+fowL40EnmD7ec0XhR7ZypxeBNdzsM=
github.com/unrolled/secure v1.0.1/go.mod h1:R6rugAuzh4TQpbFAq69oqZggyBQxFRFQIewtz5z7Jsc=
github.com/urfave/cli v1.21.0/go.mod h1:lxDj6qX9Q6lWQxIrbrT0nwecwUtRnhVZAJjJZrVUZZQ=
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
github.com/x-cray/logrus-prefixed-formatter v0.5.2 h1:00txxvfBM9muc0jiLIEAkAcIMJzfthRT6usrui8uGmg=
github.com/x-cray/logrus-prefixed-formatter v0.5.2/go.mod h1:2duySbKsL6M18s5GU7VPsoEPHyzalCE06qoARUCeBBE=
github.com/xlab/treeprint v0.0.0-20180616005107-d6fb6747feb6/go.mod h1:ce1O1j6UtZfjr22oyGxGLbauSBp2YVXpARAosm7dHBg=
Expand Down Expand Up @@ -379,7 +372,6 @@ golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200421231249-e086a090c8fd/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 h1:4nGaVu0QrbjT/AK2PRLuQfQuh6DJve+pELhqTdAj3x0=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
Expand Down Expand Up @@ -415,7 +407,6 @@ golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand All @@ -430,7 +421,6 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.4 h1:0YWbFKbhXG/wIiuHDSKpS0Iy7FSA+u45VtBMfQcFTTc=
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
Expand Down Expand Up @@ -509,7 +499,6 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWD
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
Expand Down
17 changes: 10 additions & 7 deletions internal/app/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,24 @@ func InitApp() error{
healthcheck.SpeedTimeout = time.Duration(config.Config.HealthCheckTimeout) * time.Second
log.Printf("CONF: Health check timeout is set to %d seconds\n", config.Config.HealthCheckTimeout)
}

// healthcheck setttings
healthcheck.DelayConn = config.Config.HealthCheckConnection
healthcheck.DelayTimeout = time.Duration(config.Config.HealthCheckTimeout) * time.Second
healthcheck.SpeedConn = config.Config.SpeedConnection
healthcheck.SpeedTimeout = time.Duration(config.Config.SpeedTimeout) * time.Second

proxies = healthcheck.CleanBadProxiesWithGrpool(proxies)
log.Println("Usable proxy count: ", len(proxies))

// Save to cache
cache.SetProxies("proxies", proxies)
cache.UsableProxiesCount = len(proxies)

// Speed test
if config.Config.SpeedTest == true{
if config.Config.SpeedTimeout >= 0 {
healthcheck.SpeedTimeout = time.Duration(config.Config.SpeedTimeout) * time.Second
log.Printf("CONF: Speed test timeout is set to %d seconds\n", config.Config.SpeedTimeout)
}
healthcheck.SpeedTestAll(proxies, config.Config.Connection)
if config.Config.SpeedTest == true {
healthcheck.SpeedTestAll(proxies)
}

cache.SetString("clashproxies", provider.Clash{
provider.Base{
Proxies: &proxies,
Expand Down
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ func main() {
http.ListenAndServe("0.0.0.0:6061", nil)
}()

//Slog.SetLevel(Slog.DEBUG) // Print original pack log

// fetch configuration
flag.StringVar(&configFilePath, "c", "", "path to config file: config.yaml")
flag.Parse()
Expand Down

0 comments on commit 06953af

Please sign in to comment.