Documentation
¶
Overview ¶
Package routetable provides functions that operate on the system's route table.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RouteDestination ¶
RouteDestination is the destination of a route.
This is similar to net/netip.Prefix, but also contains an optional IPv6 zone.
func (RouteDestination) String ¶
func (r RouteDestination) String() string
type RouteEntry ¶
type RouteEntry struct {
// Family is the IP family of the route; it will be either 4 or 6.
Family int
// Type is the type of this route.
Type RouteType
// Dst is the destination of the route.
Dst RouteDestination
// Gatewayis the gateway address specified for this route.
// This value will be invalid (where !r.Gateway.IsValid()) in cases
// where there is no gateway address for this route.
Gateway netip.Addr
// Interface is the name of the network interface to use when sending
// packets that match this route. This field can be empty.
Interface string
// Sys contains platform-specific information about this route.
Sys any
}
RouteEntry contains common cross-platform fields describing an entry in the system route table.
func Get ¶
func Get(max int) ([]RouteEntry, error)
Get returns route entries from the system route table, limited to at most max results.
type RouteEntryLinux ¶
type RouteEntryLinux struct {
// Type is the raw type of the route.
Type int
// Table is the routing table index of this route.
Table int
// Src is the source of the route (if any).
Src netip.Addr
// Proto describes the source of the route--i.e. what caused this route
// to be added to the route table.
Proto netlink.RouteProtocol
// Priority is the route's priority.
Priority int
// Scope is the route's scope.
Scope int
// InputInterfaceIdx is the input interface index.
InputInterfaceIdx int
// InputInterfaceName is the input interface name (if available).
InputInterfaceName string
}
RouteEntryLinux is the structure that makes up the Sys field of the RouteEntry structure.
func (RouteEntryLinux) Format ¶
func (r RouteEntryLinux) Format(f fmt.State, verb rune)
Format implements the fmt.Formatter interface.
func (RouteEntryLinux) ScopeName ¶
func (r RouteEntryLinux) ScopeName() string
ScopeName returns the string representation of this route's Scope.
func (RouteEntryLinux) TableName ¶
func (r RouteEntryLinux) TableName() string
TableName returns the string representation of this route's Table.
func (RouteEntryLinux) TypeName ¶
func (r RouteEntryLinux) TypeName() string
TypeName returns the string representation of this route's Type.
type RouteType ¶
type RouteType int
RouteType describes the type of a route.
const ( // RouteTypeUnspecified is the unspecified route type. RouteTypeUnspecified RouteType = iota // RouteTypeLocal indicates that the destination of this route is an // address that belongs to this system. RouteTypeLocal // RouteTypeUnicast indicates that the destination of this route is a // "regular" address--one that neither belongs to this host, nor is a // broadcast/multicast/etc. address. RouteTypeUnicast // RouteTypeBroadcast indicates that the destination of this route is a // broadcast address. RouteTypeBroadcast // RouteTypeMulticast indicates that the destination of this route is a // multicast address. RouteTypeMulticast // RouteTypeOther indicates that the route is of some other valid type; // see the Sys field for the OS-provided route information to determine // the exact type. RouteTypeOther )