types.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package sitecheck
  2. import (
  3. "time"
  4. "github.com/0xJacky/Nginx-UI/model"
  5. )
  6. // Site health check status constants
  7. const (
  8. StatusOnline = "online"
  9. StatusOffline = "offline"
  10. StatusError = "error"
  11. StatusChecking = "checking"
  12. )
  13. // SiteInfo represents the information about a site
  14. type SiteInfo struct {
  15. model.SiteConfig
  16. Name string `json:"name"`
  17. Status string `json:"status"` // StatusOnline, StatusOffline, StatusError, StatusChecking
  18. StatusCode int `json:"status_code"`
  19. ResponseTime int64 `json:"response_time"` // in milliseconds
  20. FaviconURL string `json:"favicon_url"`
  21. FaviconData string `json:"favicon_data"` // base64 encoded favicon
  22. Title string `json:"title"`
  23. LastChecked int64 `json:"last_checked"` // Unix timestamp in seconds
  24. Error string `json:"error,omitempty"`
  25. }
  26. // CheckOptions represents options for site checking
  27. type CheckOptions struct {
  28. Timeout time.Duration
  29. UserAgent string
  30. FollowRedirects bool
  31. MaxRedirects int
  32. CheckFavicon bool
  33. }
  34. // DefaultCheckOptions returns default checking options
  35. func DefaultCheckOptions() CheckOptions {
  36. return CheckOptions{
  37. Timeout: 10 * time.Second,
  38. UserAgent: "Nginx-UI Site Checker/1.0",
  39. FollowRedirects: true,
  40. MaxRedirects: 3,
  41. CheckFavicon: true,
  42. }
  43. }