types.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. }
  18. // PolicyRuleItem represents a MikroTik /ip route rule (Linux `ip rule`)
  19. type PolicyRuleItem struct {
  20. ID string `json:"id"`
  21. Priority int `json:"priority"` // Preference number (e.g. 1000, 32766)
  22. SrcAddress string `json:"src_address,omitempty"`
  23. DstAddress string `json:"dst_address,omitempty"`
  24. RoutingMark string `json:"routing_mark,omitempty"` // Matches fwmark set in Mangle
  25. Table string `json:"table"` // Table to lookup (e.g. "wan2", "main")
  26. TableID int `json:"table_id"`
  27. Action string `json:"action"` // lookup, unreachable, blackhole, prohibit
  28. Comment string `json:"comment,omitempty"`
  29. }
  30. // RoutingTableItem represents a named routing table in Linux (/etc/iproute2/rt_tables)
  31. type RoutingTableItem struct {
  32. Name string `json:"name"`
  33. TableID int `json:"table_id"`
  34. Comment string `json:"comment,omitempty"`
  35. }