You've already forked ssl_exporter
mirror of
https://github.com/ribbybibby/ssl_exporter.git
synced 2025-07-15 23:54:18 +02:00
Use custom User-Agent header (#178)
This commit is contained in:
@ -35,6 +35,7 @@ func ProbeHTTPFile(ctx context.Context, logger log.Logger, target string, module
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("creating http request: %w", err)
|
return fmt.Errorf("creating http request: %w", err)
|
||||||
}
|
}
|
||||||
|
req.Header.Set("User-Agent", userAgent)
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("making http request: %w", err)
|
return fmt.Errorf("making http request: %w", err)
|
||||||
|
@ -12,9 +12,12 @@ import (
|
|||||||
"github.com/go-kit/log"
|
"github.com/go-kit/log"
|
||||||
"github.com/go-kit/log/level"
|
"github.com/go-kit/log/level"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
|
"github.com/prometheus/common/version"
|
||||||
"github.com/ribbybibby/ssl_exporter/v2/config"
|
"github.com/ribbybibby/ssl_exporter/v2/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var userAgent = fmt.Sprintf("SSLExporter/%s", version.Version)
|
||||||
|
|
||||||
// ProbeHTTPS performs a https probe
|
// ProbeHTTPS performs a https probe
|
||||||
func ProbeHTTPS(ctx context.Context, logger log.Logger, target string, module config.Module, registry *prometheus.Registry) error {
|
func ProbeHTTPS(ctx context.Context, logger log.Logger, target string, module config.Module, registry *prometheus.Registry) error {
|
||||||
tlsConfig, err := newTLSConfig("", registry, &module.TLSConfig)
|
tlsConfig, err := newTLSConfig("", registry, &module.TLSConfig)
|
||||||
@ -57,6 +60,7 @@ func ProbeHTTPS(ctx context.Context, logger log.Logger, target string, module co
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
request = request.WithContext(ctx)
|
request = request.WithContext(ctx)
|
||||||
|
request.Header.Set("User-Agent", userAgent)
|
||||||
resp, err := client.Do(request)
|
resp, err := client.Do(request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Reference in New Issue
Block a user