aboutsummaryrefslogtreecommitdiff
path: root/internal
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
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')
-rw-r--r--internal/config/config.go1
-rw-r--r--internal/monitor/http.go8
2 files changed, 8 insertions, 1 deletions
diff --git a/internal/config/config.go b/internal/config/config.go
index 81f745c..4d428fc 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -87,6 +87,7 @@ type MonitorConfig struct {
RoundResponseTime bool `yaml:"round_response_time,omitempty"` // Round response time to nearest second
RoundUptime bool `yaml:"round_uptime,omitempty"` // Round uptime percentage (e.g., 99.99% → 100%)
Method string `yaml:"method,omitempty"`
+ UserAgent string `yaml:"user_agent,omitempty"` // Custom User-Agent header (default: "Kaze-Monitor/1.0")
Headers map[string]string `yaml:"headers,omitempty"`
Body string `yaml:"body,omitempty"`
}
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)
}