diff --git a/pkg/meshnet/system/routes/routes_darwin.go b/pkg/meshnet/system/routes/routes_darwin.go index 06a9cef15..202d6e8a4 100644 --- a/pkg/meshnet/system/routes/routes_darwin.go +++ b/pkg/meshnet/system/routes/routes_darwin.go @@ -54,9 +54,9 @@ func SetDefaultIPv4Gateway(ctx context.Context, gateway Gateway) error { // Add adds a route to the interface with the given name. func Add(ctx context.Context, ifaceName string, addr netip.Prefix) error { - out, err := common.ExecOutput(ctx, "route", "-n", "add", "-"+getFamily(addr.Addr()), addr.Masked().String(), "-interface", ifaceName) + _, err := common.ExecOutput(ctx, "route", "-n", "add", "-"+getFamily(addr.Addr()), addr.Masked().String(), "-interface", ifaceName) if err != nil { - if strings.Contains(string(out), "already in table") || strings.Contains(string(out), "exists") { + if strings.Contains(err.Error(), "already in table") || strings.Contains(err.Error(), "exists") { return ErrRouteExists } return err diff --git a/pkg/meshnet/system/routes/routes_freebsd.go b/pkg/meshnet/system/routes/routes_freebsd.go index 016f5a0ac..e9da8f7b3 100644 --- a/pkg/meshnet/system/routes/routes_freebsd.go +++ b/pkg/meshnet/system/routes/routes_freebsd.go @@ -55,9 +55,9 @@ func SetDefaultIPv4Gateway(ctx context.Context, gateway Gateway) error { // Add adds a route to the interface with the given name. func Add(ctx context.Context, ifaceName string, addr netip.Prefix) error { - out, err := common.ExecOutput(ctx, "route", "-n", "add", "-"+getFamily(addr.Addr()), addr.Masked().String(), "-interface", ifaceName) + _, err := common.ExecOutput(ctx, "route", "-n", "add", "-"+getFamily(addr.Addr()), addr.Masked().String(), "-interface", ifaceName) if err != nil { - if strings.Contains(string(out), "already in table") || strings.Contains(string(out), "exists") { + if strings.Contains(err.Error(), "already in table") || strings.Contains(err.Error(), "exists") { return ErrRouteExists } return err