fix: do not report a routing error if the interface is disconnected

This commit is contained in:
Simone Margaritelli 2024-08-18 13:43:19 +02:00
parent 2d03782fe1
commit 23e074b686

View file

@ -6,6 +6,7 @@ import (
"github.com/bettercap/bettercap/v2/network"
"github.com/bettercap/bettercap/v2/routing"
"github.com/evilsocket/islazy/log"
"github.com/evilsocket/islazy/ops"
)
type gateway struct {
@ -51,7 +52,10 @@ func (s *Session) routeMon() {
}
if err != nil {
s.Events.Log(log.ERROR, "error getting ipv4 gateway: %v", err)
s.Events.Log(
ops.Ternary(err == network.ErrNoGateway, log.DEBUG, log.ERROR).(log.Verbosity),
"error getting ipv4 gateway: %v",
err)
} else {
if gw4now.IpAddress != gw4.IpAddress || gw4now.HwAddress != gw4.HwAddress {
s.Events.Add("gateway.change", GatewayChange{