diff options
| author | Fuwn <[email protected]> | 2026-01-19 16:53:39 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-01-19 16:53:39 -0800 |
| commit | b83baaae6735eccca31a94e630fdeb67919733a0 (patch) | |
| tree | 625deb2572ed2e8cefa607e88c764c7c21344802 /internal/monitor/gemini.go | |
| parent | feat: Add reset_on_next_check flag to wipe monitor history (diff) | |
| download | kaze-b83baaae6735eccca31a94e630fdeb67919733a0.tar.xz kaze-b83baaae6735eccca31a94e630fdeb67919733a0.zip | |
feat: Add group defaults, content checking, SSL tracking for Gemini, hide/round options
Diffstat (limited to 'internal/monitor/gemini.go')
| -rw-r--r-- | internal/monitor/gemini.go | 52 |
1 files changed, 32 insertions, 20 deletions
diff --git a/internal/monitor/gemini.go b/internal/monitor/gemini.go index d92499b..fb75b7d 100644 --- a/internal/monitor/gemini.go +++ b/internal/monitor/gemini.go @@ -14,12 +14,14 @@ import ( // GeminiMonitor monitors Gemini protocol endpoints type GeminiMonitor struct { - name string - target string - interval time.Duration - timeout time.Duration - retries int - verifySSL bool + name string + target string + interval time.Duration + timeout time.Duration + retries int + verifySSL bool + hideSSLDays bool + roundResponseTime bool } // NewGeminiMonitor creates a new Gemini monitor @@ -50,12 +52,14 @@ func NewGeminiMonitor(cfg config.MonitorConfig) (*GeminiMonitor, error) { } return &GeminiMonitor{ - name: cfg.Name, - target: target, - interval: cfg.Interval.Duration, - timeout: cfg.Timeout.Duration, - retries: cfg.Retries, - verifySSL: verifySSL, + name: cfg.Name, + target: target, + interval: cfg.Interval.Duration, + timeout: cfg.Timeout.Duration, + retries: cfg.Retries, + verifySSL: verifySSL, + hideSSLDays: cfg.HideSSLDays, + roundResponseTime: cfg.RoundResponseTime, }, nil } @@ -84,6 +88,16 @@ func (m *GeminiMonitor) Retries() int { return m.retries } +// HideSSLDays returns whether to hide SSL days from display +func (m *GeminiMonitor) HideSSLDays() bool { + return m.hideSSLDays +} + +// RoundResponseTime returns whether to round response time +func (m *GeminiMonitor) RoundResponseTime() bool { + return m.roundResponseTime +} + // Check performs the Gemini protocol check func (m *GeminiMonitor) Check(ctx context.Context) *Result { result := &Result{ @@ -119,14 +133,12 @@ func (m *GeminiMonitor) Check(ctx context.Context) *Result { } defer conn.Close() - // Check SSL certificate - if m.verifySSL { - connState := conn.ConnectionState() - if len(connState.PeerCertificates) > 0 { - cert := connState.PeerCertificates[0] - result.SSLExpiry = &cert.NotAfter - result.SSLDaysLeft = int(time.Until(cert.NotAfter).Hours() / 24) - } + // Check SSL certificate (always track, even if not verifying) + connState := conn.ConnectionState() + if len(connState.PeerCertificates) > 0 { + cert := connState.PeerCertificates[0] + result.SSLExpiry = &cert.NotAfter + result.SSLDaysLeft = int(time.Until(cert.NotAfter).Hours() / 24) } // Set deadline for the entire operation |