types.go 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. ECMP bool `json:"ecmp"` // Equal-Cost Multi-Path route (MikroTik 'E' flag)
  16. Multicast bool `json:"multicast"` // Multicast / IGMP route (224.0.0.0/4 or kernel multicast)
  17. IsMultiPath bool `json:"is_multipath"` // Linux kernel multipath nexthop
  18. Disabled bool `json:"disabled"` // MikroTik 'X' flag
  19. Comment string `json:"comment,omitempty"`
  20. // Gateway Health Check & Behind-NAT Internet Prober
  21. CheckGateway string `json:"check_gateway,omitempty"` // "none", "ping", "internet"
  22. CheckTarget string `json:"check_target,omitempty"` // Target to probe (e.g. "1.1.1.1", "8.8.8.8")
  23. CheckInterval int `json:"check_interval,omitempty"` // Seconds between probes (default 5)
  24. CheckThreshold int `json:"check_threshold,omitempty"` // Consecutive failures before failover (default 3)
  25. HealthStatus string `json:"health_status,omitempty"` // "online", "offline", "checking", "none"
  26. HealthRTT float64 `json:"health_rtt_ms,omitempty"` // Round trip latency in ms
  27. HealthLossPct float64 `json:"health_loss_pct,omitempty"` // Packet loss percentage
  28. HealthFailCount int `json:"health_fail_count,omitempty"` // Consecutive failures count
  29. HealthLastCheck string `json:"health_last_check,omitempty"` // Formatted timestamp of last probe
  30. // Old values for modifying existing routes
  31. OldDstAddress string `json:"old_dst_address,omitempty"`
  32. OldGateway string `json:"old_gateway,omitempty"`
  33. OldRoutingTable string `json:"old_routing_table,omitempty"`
  34. OldDistance *int `json:"old_distance,omitempty"`
  35. OldInterface string `json:"old_interface,omitempty"`
  36. }
  37. // PolicyRuleItem represents a MikroTik /ip route rule (Linux `ip rule`)
  38. type PolicyRuleItem struct {
  39. ID string `json:"id"`
  40. Priority int `json:"priority"` // Preference number (e.g. 1000, 32766)
  41. SrcAddress string `json:"src_address,omitempty"`
  42. DstAddress string `json:"dst_address,omitempty"`
  43. RoutingMark string `json:"routing_mark,omitempty"` // Matches fwmark set in Mangle
  44. Table string `json:"table"` // Table to lookup (e.g. "wan2", "main")
  45. TableID int `json:"table_id"`
  46. Action string `json:"action"` // lookup, unreachable, blackhole, prohibit
  47. Comment string `json:"comment,omitempty"`
  48. IsDefault bool `json:"is_default,omitempty"`
  49. IsSystem bool `json:"is_system,omitempty"`
  50. }
  51. // RoutingTableItem represents a named routing table in Linux (/etc/iproute2/rt_tables)
  52. type RoutingTableItem struct {
  53. Name string `json:"name"`
  54. TableID int `json:"table_id"`
  55. Comment string `json:"comment,omitempty"`
  56. }