Skip to content

Commit

Permalink
Use custom User-Agent header (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
ribbybibby committed Apr 28, 2024
1 parent dd2a9a2 commit 1b8a0c3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions prober/http_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func ProbeHTTPFile(ctx context.Context, logger log.Logger, target string, module
if err != nil {
return fmt.Errorf("creating http request: %w", err)
}
req.Header.Set("User-Agent", userAgent)
resp, err := client.Do(req)
if err != nil {
return fmt.Errorf("making http request: %w", err)
Expand Down
4 changes: 4 additions & 0 deletions prober/https.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ import (
"github.com/go-kit/log"
"github.com/go-kit/log/level"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/version"
"github.com/ribbybibby/ssl_exporter/v2/config"
)

var userAgent = fmt.Sprintf("SSLExporter/%s", version.Version)

// ProbeHTTPS performs a https probe
func ProbeHTTPS(ctx context.Context, logger log.Logger, target string, module config.Module, registry *prometheus.Registry) error {
tlsConfig, err := newTLSConfig("", registry, &module.TLSConfig)
Expand Down Expand Up @@ -57,6 +60,7 @@ func ProbeHTTPS(ctx context.Context, logger log.Logger, target string, module co
return err
}
request = request.WithContext(ctx)
request.Header.Set("User-Agent", userAgent)
resp, err := client.Do(request)
if err != nil {
return err
Expand Down

0 comments on commit 1b8a0c3

Please sign in to comment.