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.
Currently, nylon wraps the
ipcommand on linux,/sbin/ifconfigon mac, andnetshon 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:
I looked online, and I don't think there is such an "all-in-one" go library for the major platforms.