dashboard

package
v1.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 14, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package dashboard provides HTTP handlers and API endpoints for AegisGate's real-time monitoring interface.

Package dashboard provides HTTP handlers and API endpoints for AegisGate's real-time monitoring interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIResponse

type APIResponse struct {
	Success   bool        `json:"success"`
	Data      interface{} `json:"data,omitempty"`
	Error     string      `json:"error,omitempty"`
	Timestamp time.Time   `json:"timestamp"`
}

type AdminHandler

type AdminHandler struct {
	// contains filtered or unexported fields
}

func NewAdminHandler

func NewAdminHandler(authManager *auth.Manager, dashboard *Dashboard) *AdminHandler

func (*AdminHandler) RegisterRoutes

func (ah *AdminHandler) RegisterRoutes()

type ComponentStatus

type ComponentStatus struct {
	Name    string `json:"name"`
	Status  string `json:"status"`
	Message string `json:"message,omitempty"`
}

ComponentStatus represents the health status of a component

type Config

type Config struct {
	Port              int      `json:"port"`
	StaticDir         string   `json:"static_dir"`
	AuthToken         string   `json:"auth_token,omitempty"`
	CORSEnabled       bool     `json:"cors_enabled"`
	CORSOrigins       []string `json:"cors_origins,omitempty"`
	RateLimitRequests int      `json:"rate_limit_requests"`
	RateLimitBurst    int      `json:"rate_limit_burst"`
	LogLevel          string   `json:"log_level"`
	// Security configuration
	EnableCSRF            bool          `json:"enable_csrf,omitempty"`
	CSRFTokenLifetime     time.Duration `json:"csrf_token_lifetime,omitempty"`
	EnableAudit           bool          `json:"enable_audit,omitempty"`
	AuditLevel            string        `json:"audit_level,omitempty"`
	EnableSecurityHeaders bool          `json:"enable_security_headers,omitempty"`
	CSPPolicy             string        `json:"csp_policy,omitempty"`
	EnablePanicRecovery   bool          `json:"enable_panic_recovery,omitempty"`
	SecretsProvider       string        `json:"secrets_provider,omitempty"`
}

Config holds the dashboard configuration.

func DefaultConfig

func DefaultConfig() Config

type Dashboard

type Dashboard struct {
	// contains filtered or unexported fields
}

func New

func New(cfg Config) *Dashboard

New creates a new Dashboard without i18n support (backward compatible)

func NewWithI18n

func NewWithI18n(cfg Config, i18nManager *i18n.Manager) *Dashboard

NewWithI18n creates a new Dashboard with i18n support

func (*Dashboard) GetComponentStatus

func (d *Dashboard) GetComponentStatus() []ComponentStatus

GetComponentStatus returns the current status of all components Useful for external monitoring systems

func (*Dashboard) GetI18nManager

func (d *Dashboard) GetI18nManager() *i18n.Manager

GetI18nManager returns the i18n manager for external access

func (*Dashboard) GetSystemMetrics

func (d *Dashboard) GetSystemMetrics() map[string]interface{}

GetSystemMetrics returns current system metrics

func (*Dashboard) HandleLocale

func (d *Dashboard) HandleLocale(w http.ResponseWriter, r *http.Request) error

HandleLocale handles GET /api/locale Returns current locale and supported locales

func (*Dashboard) HandleSetLocale

func (d *Dashboard) HandleSetLocale(w http.ResponseWriter, r *http.Request) error

HandleSetLocale handles POST /api/locale Sets the current locale

func (*Dashboard) IsHealthy

func (d *Dashboard) IsHealthy() bool

IsHealthy returns true if all components are healthy

func (*Dashboard) RecordPrometheusBlocked

func (d *Dashboard) RecordPrometheusBlocked(reason, category string)

RecordPrometheusBlocked records a blocked request to Prometheus metrics

func (*Dashboard) RecordPrometheusError

func (d *Dashboard) RecordPrometheusError(errorType string)

RecordPrometheusError records an error to Prometheus metrics

func (*Dashboard) RecordPrometheusProxyLatency

func (d *Dashboard) RecordPrometheusProxyLatency(latency time.Duration)

RecordPrometheusProxyLatency records proxy latency to Prometheus metrics

func (*Dashboard) RecordPrometheusRequest

func (d *Dashboard) RecordPrometheusRequest(method, path string, status int, duration time.Duration)

RecordPrometheusRequest records a request to Prometheus metrics Called by the proxy when processing requests

func (*Dashboard) RecordPrometheusScanDuration

func (d *Dashboard) RecordPrometheusScanDuration(duration time.Duration)

RecordPrometheusScanDuration records WAF scan duration to Prometheus metrics

func (*Dashboard) RecordPrometheusViolation

func (d *Dashboard) RecordPrometheusViolation(severity, category, pattern string)

RecordPrometheusViolation records a violation to Prometheus metrics

func (*Dashboard) RegisterEventChannel

func (d *Dashboard) RegisterEventChannel(events <-chan metrics.MetricEvent)

func (*Dashboard) SetLocale

func (d *Dashboard) SetLocale(locale i18n.Locale) error

SetLocale sets the current locale

func (*Dashboard) Start

func (d *Dashboard) Start() error

func (*Dashboard) StartMetricsSync

func (d *Dashboard) StartMetricsSync(interval time.Duration)

StartMetricsSync starts a background goroutine that syncs internal metrics to Prometheus The sync interval determines how often the metrics are updated

func (*Dashboard) Stop

func (d *Dashboard) Stop(ctx context.Context) error

type DashboardData

type DashboardData struct {
	Version      string                 `json:"version"`
	ServerTime   time.Time              `json:"server_time"`
	Uptime       time.Duration          `json:"uptime"`
	Config       Config                 `json:"config"`
	Stats        map[string]interface{} `json:"stats"`
	WebSocketURL string                 `json:"websocket_url"`
}

type HandlerFunc

type HandlerFunc func(w http.ResponseWriter, r *http.Request) error

type RateLimiter

type RateLimiter struct {
	// contains filtered or unexported fields
}

func NewRateLimiter

func NewRateLimiter(requests, burst int) *RateLimiter

func (*RateLimiter) Allow

func (rl *RateLimiter) Allow(clientIP string) bool

type Route

type Route struct {
	Path        string
	Method      string
	Handler     HandlerFunc
	RequireAuth bool
	RateLimited bool
}

type SecurityConfig

type SecurityConfig struct {
	EnableCSRF            bool
	EnableAudit           bool
	CSRFTokenLifetime     int // in seconds
	EnableSecurityHeaders bool
	EnablePanicRecovery   bool
}

type SecurityMiddleware

type SecurityMiddleware struct {
	// contains filtered or unexported fields
}

func NewSecurityMiddleware

func NewSecurityMiddleware(config SecurityConfig) *SecurityMiddleware

func (*SecurityMiddleware) Wrap

func (sm *SecurityMiddleware) Wrap(handler http.Handler) http.Handler

type StatsFilter

type StatsFilter struct {
	Severity    string    `json:"severity,omitempty"`
	Limit       int       `json:"limit,omitempty"`
	Since       time.Time `json:"since,omitempty"`
	Until       time.Time `json:"until,omitempty"`
	PatternType string    `json:"pattern_type,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL