route_info.go 627 B

12345678910111213141516171819
  1. package sockaddr
  2. // RouteInterface specifies an interface for obtaining memoized route table and
  3. // network information from a given OS.
  4. type RouteInterface interface {
  5. // GetDefaultInterfaceName returns the name of the interface that has a
  6. // default route or an error and an empty string if a problem was
  7. // encountered.
  8. GetDefaultInterfaceName() (string, error)
  9. }
  10. // VisitCommands visits each command used by the platform-specific RouteInfo
  11. // implementation.
  12. func (ri routeInfo) VisitCommands(fn func(name string, cmd []string)) {
  13. for k, v := range ri.cmds {
  14. cmds := append([]string(nil), v...)
  15. fn(k, cmds)
  16. }
  17. }