aboutsummaryrefslogtreecommitdiff
path: root/internal/monitor
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-01-19 17:50:35 -0800
committerFuwn <[email protected]>2026-01-19 17:50:35 -0800
commita24b3b5c206a75ace0b0e77c29abb9ac46c487ed (patch)
treec8b180276df1b122627b374d947581df217fd8fd /internal/monitor
parentfeat: Change default favicon to wind chime emoji (🎐) (diff)
downloadkaze-a24b3b5c206a75ace0b0e77c29abb9ac46c487ed.tar.xz
kaze-a24b3b5c206a75ace0b0e77c29abb9ac46c487ed.zip
feat: Add configurable user_agent to bypass bot detection
Diffstat (limited to 'internal/monitor')
-rw-r--r--internal/monitor/http.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/internal/monitor/http.go b/internal/monitor/http.go
index 00e3e0a..ddf8641 100644
--- a/internal/monitor/http.go
+++ b/internal/monitor/http.go
@@ -22,6 +22,7 @@ type HTTPMonitor struct {
timeout time.Duration
retries int
method string
+ userAgent string
headers map[string]string
body string
expectedStatus int
@@ -88,6 +89,7 @@ func NewHTTPMonitor(cfg config.MonitorConfig) (*HTTPMonitor, error) {
timeout: cfg.Timeout.Duration,
retries: cfg.Retries,
method: cfg.Method,
+ userAgent: cfg.UserAgent,
headers: cfg.Headers,
body: cfg.Body,
expectedStatus: cfg.ExpectedStatus,
@@ -161,7 +163,11 @@ func (m *HTTPMonitor) Check(ctx context.Context) *Result {
}
// Set headers
- req.Header.Set("User-Agent", "Kaze-Monitor/1.0")
+ userAgent := m.userAgent
+ if userAgent == "" {
+ userAgent = "Kaze-Monitor/1.0"
+ }
+ req.Header.Set("User-Agent", userAgent)
for key, value := range m.headers {
req.Header.Set(key, value)
}