mirror of
https://github.com/henrygd/beszel.git
synced 2026-09-22 09:27:46 +02:00
add custom user agent to HTTP monitors
This commit is contained in:
@@ -8,9 +8,12 @@ import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/henrygd/beszel"
|
||||
"github.com/henrygd/beszel/internal/entities/monitor"
|
||||
)
|
||||
|
||||
const networkMonitorUserAgent = "Beszel-Agent/" + beszel.Version + " (+https://beszel.dev)"
|
||||
|
||||
// monitorProbe performs one check. Errors are recorded as loss by the task runner.
|
||||
// Implementations must honor cancellation and bound their execution time.
|
||||
type monitorProbe func(context.Context, monitor.Config) (int64, error)
|
||||
@@ -93,6 +96,7 @@ func monitorHTTP(ctx context.Context, client *http.Client, url string) (int64, e
|
||||
if err != nil {
|
||||
return -1, err
|
||||
}
|
||||
req.Header.Set("User-Agent", networkMonitorUserAgent)
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return -1, err
|
||||
|
||||
Reference in New Issue
Block a user