Skip to content

core(routing): use less brittle route reconciliation mechanism #97

Description

@encodeous

Currently, nylon wraps the ip command on linux, /sbin/ifconfig on mac, and netsh on Windows.

This is not problematic in itself, however nylon also keeps a model of the system route table in-memory, without actually retrieving the system routing table. This can lead to drift over time, if there are other applications/users which modify the route table, or if a command fails for some reason.

To resolve: implement a cross-platform route table interface, like:

type SystemRoutes interface {
      InterfaceAddresses(ifName string) ([]netip.Prefix, error)
      AddAddress(ifName string, addr netip.Addr) error
      DeleteAddress(ifName string, addr netip.Addr) error

      InterfaceRoutes(ifName string) ([]netip.Prefix, error)
      AddRoute(ifName string, prefix netip.Prefix) error
      DeleteRoute(ifName string, prefix netip.Prefix) error
}

I looked online, and I don't think there is such an "all-in-one" go library for the major platforms.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requesthelp wantedExtra attention is needed

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions