From c486fb1c7498f89d7019919ee997e7107f794059 Mon Sep 17 00:00:00 2001 From: Aaron Chen Date: Wed, 31 Jul 2024 21:22:11 +0800 Subject: [PATCH] fix proxy setting when ratelimit not set --- README.md | 2 +- cmd/notify/notify.go | 2 +- internal/runner/runner.go | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c0f412f..cdffb79 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ This will display help for the tool. Here are all the switches it supports. | `-no-color` | disable colors in output | `notify -nc` | | `-provider-config` | provider config path | `notify -pc provider.yaml` | | `-provider` | provider to send the notification to (optional) | `notify -p slack,telegram` | -| `-proxy` | http proxy to use with notify | `notify -proxy http://127.0.0.1:8080` | +| `-proxy` | http/socks5 proxy to use with notify | `notify -proxy http://127.0.0.1:8080` | | `-rate-limit` | maximum number of HTTP requests to send per second | `notify -rl 1` | | `-silent` | enable silent mode | `notify -silent` | | `-verbose` | enable verbose mode | `notify -verbose` | diff --git a/cmd/notify/notify.go b/cmd/notify/notify.go index 52783a5..9c01163 100644 --- a/cmd/notify/notify.go +++ b/cmd/notify/notify.go @@ -63,7 +63,7 @@ func readConfig() { set.BoolVarP(&options.Verbose, "verbose", "v", false, "enable verbose mode") set.BoolVar(&options.Version, "version", false, "display version") set.BoolVarP(&options.NoColor, "no-color", "nc", false, "disable colors in output") - set.StringVar(&options.Proxy, "proxy", "", "HTTP Proxy to use with notify") + set.StringVar(&options.Proxy, "proxy", "", "http/socks5 proxy to use with notify") set.CallbackVarP(runner.GetUpdateCallback(), "update", "up", "update notify to latest version") set.BoolVarP(&options.DisableUpdateCheck, "disable-update-check", "duc", false, "disable automatic notify update check") diff --git a/internal/runner/runner.go b/internal/runner/runner.go index c4ff399..951a6c8 100644 --- a/internal/runner/runner.go +++ b/internal/runner/runner.go @@ -80,6 +80,8 @@ func (r *Runner) Run() error { if r.options.RateLimit > 0 { http.DefaultClient.Transport = utils.NewThrottledTransport(time.Second, r.options.RateLimit, defaultTransport) + } else { + http.DefaultClient.Transport = defaultTransport } var inFile *os.File