types.go 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. // Old values for modifying existing routes
  18. OldDstAddress string `json:"old_dst_address,omitempty"`
  19. OldGateway string `json:"old_gateway,omitempty"`
  20. OldRoutingTable string `json:"old_routing_table,omitempty"`
  21. OldDistance *int `json:"old_distance,omitempty"`
  22. OldInterface string `json:"old_interface,omitempty"`
  23. }
  24. // PolicyRuleItem represents a MikroTik /ip route rule (Linux `ip rule`)
  25. type PolicyRuleItem struct {
  26. ID string `json:"id"`
  27. Priority int `json:"priority"` // Preference number (e.g. 1000, 32766)
  28. SrcAddress string `json:"src_address,omitempty"`
  29. DstAddress string `json:"dst_address,omitempty"`
  30. RoutingMark string `json:"routing_mark,omitempty"` // Matches fwmark set in Mangle
  31. Table string `json:"table"` // Table to lookup (e.g. "wan2", "main")
  32. TableID int `json:"table_id"`
  33. Action string `json:"action"` // lookup, unreachable, blackhole, prohibit
  34. Comment string `json:"comment,omitempty"`
  35. IsDefault bool `json:"is_default,omitempty"`
  36. IsSystem bool `json:"is_system,omitempty"`
  37. }
  38. // RoutingTableItem represents a named routing table in Linux (/etc/iproute2/rt_tables)
  39. type RoutingTableItem struct {
  40. Name string `json:"name"`
  41. TableID int `json:"table_id"`
  42. Comment string `json:"comment,omitempty"`
  43. }