diff options
Diffstat (limited to 'internal/pkg/network/iface.go')
-rw-r--r-- | internal/pkg/network/iface.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/internal/pkg/network/iface.go b/internal/pkg/network/iface.go index b2a57bd..d49566d 100644 --- a/internal/pkg/network/iface.go +++ b/internal/pkg/network/iface.go @@ -27,6 +27,24 @@ func GetDefaultGateway() (string, error) { return "", errors.New("Unable to find default route") } +//CheckRoute return bool isPresent +func CheckRoute(dst, gw string) (bool, error) { + var isPresent bool + routes, err := netlink.RouteList(nil, syscall.AF_INET) + if err != nil { + return isPresent, err + } + + for _, route := range routes { + if route.Dst.String() == dst && route.Gw.To4().String() == gw { + isPresent = true + } + } + + return isPresent, nil + +} + // GetDefaultGatewayInterface return default gateway interface link func GetDefaultGatewayInterface() (*net.Interface, error) { routes, err := netlink.RouteList(nil, syscall.AF_INET) |