types.go 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package routing
  2. // RouteItem represents a MikroTik-style /ip route entry
  3. type RouteItem struct {
  4. ID string `json:"id"`
  5. DstAddress string `json:"dst_address"` // CIDR e.g. "0.0.0.0/0", "192.168.10.0/24"
  6. Gateway string `json:"gateway"` // Gateway IP e.g. "192.168.1.1" or interface "wg0"
  7. Interface string `json:"interface"` // Output device
  8. Distance int `json:"distance"` // Metric / Administrative Distance
  9. RoutingTable string `json:"routing_table"` // Table name e.g. "main", "wan2", "vpn_out"
  10. TableID int `json:"table_id"`
  11. Active bool `json:"active"` // MikroTik 'A' flag
  12. Dynamic bool `json:"dynamic"` // MikroTik 'D' flag (kernel learned)
  13. Connect bool `json:"connect"` // MikroTik 'C' flag (directly connected interface subnet)
  14. Static bool `json:"static"` // MikroTik 'S' flag (user defined)
  15. Disabled bool `json:"disabled"` // MikroTik 'X' flag
  16. Comment string `json:"comment,omitempty"`
  17. // Gateway Health Check & Behind-NAT Internet Prober
  18. CheckGateway string `json:"check_gateway,omitempty"` // "none", "ping", "internet"
  19. CheckTarget string `json:"check_target,omitempty"` // Target to probe (e.g. "1.1.1.1", "8.8.8.8")
  20. CheckInterval int `json:"check_interval,omitempty"` // Seconds between probes (default 5)
  21. CheckThreshold int `json:"check_threshold,omitempty"` // Consecutive failures before failover (default 3)
  22. HealthStatus string `json:"health_status,omitempty"` // "online", "offline", "checking", "none"
  23. HealthRTT float64 `json:"health_rtt_ms,omitempty"` // Round trip latency in ms
  24. HealthLossPct float64 `json:"health_loss_pct,omitempty"` // Packet loss percentage
  25. HealthFailCount int `json:"health_fail_count,omitempty"` // Consecutive failures count
  26. HealthLastCheck string `json:"health_last_check,omitempty"` // Formatted timestamp of last probe
  27. // Old values for modifying existing routes
  28. OldDstAddress string `json:"old_dst_address,omitempty"`
  29. OldGateway string `json:"old_gateway,omitempty"`
  30. OldRoutingTable string `json:"old_routing_table,omitempty"`
  31. OldDistance *int `json:"old_distance,omitempty"`
  32. OldInterface string `json:"old_interface,omitempty"`
  33. }
  34. // PolicyRuleItem represents a MikroTik /ip route rule (Linux `ip rule`)
  35. type PolicyRuleItem struct {
  36. ID string `json:"id"`
  37. Priority int `json:"priority"` // Preference number (e.g. 1000, 32766)
  38. SrcAddress string `json:"src_address,omitempty"`
  39. DstAddress string `json:"dst_address,omitempty"`
  40. RoutingMark string `json:"routing_mark,omitempty"` // Matches fwmark set in Mangle
  41. Table string `json:"table"` // Table to lookup (e.g. "wan2", "main")
  42. TableID int `json:"table_id"`
  43. Action string `json:"action"` // lookup, unreachable, blackhole, prohibit
  44. Comment string `json:"comment,omitempty"`
  45. IsDefault bool `json:"is_default,omitempty"`
  46. IsSystem bool `json:"is_system,omitempty"`
  47. }
  48. // RoutingTableItem represents a named routing table in Linux (/etc/iproute2/rt_tables)
  49. type RoutingTableItem struct {
  50. Name string `json:"name"`
  51. TableID int `json:"table_id"`
  52. Comment string `json:"comment,omitempty"`
  53. }