typedef.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package uptime
  2. import "imuslab.com/zoraxy/mod/info/logger"
  3. const (
  4. logModuleName = "uptime-monitor"
  5. )
  6. type Record struct {
  7. Timestamp int64
  8. ID string
  9. Name string
  10. URL string
  11. Protocol string
  12. Online bool
  13. StatusCode int
  14. Latency int64
  15. }
  16. type ProxyType string
  17. const (
  18. ProxyType_Host ProxyType = "Origin Server"
  19. ProxyType_Vdir ProxyType = "Virtual Directory"
  20. )
  21. type Target struct {
  22. ID string
  23. Name string
  24. URL string
  25. Protocol string
  26. ProxyType ProxyType
  27. }
  28. type Config struct {
  29. Targets []*Target
  30. Interval int
  31. MaxRecordsStore int
  32. OnlineStateNotify func(upstreamIP string, isOnline bool)
  33. Logger *logger.Logger
  34. }
  35. type Monitor struct {
  36. Config *Config
  37. OnlineStatusLog map[string][]*Record
  38. }
  39. // Default configs
  40. var exampleTarget = Target{
  41. ID: "example",
  42. Name: "Example",
  43. URL: "example.com",
  44. Protocol: "https",
  45. }
  46. func defaultNotify(upstreamIP string, isOnline bool) {
  47. // Do nothing
  48. }