mirror of
https://github.com/bettercap/bettercap
synced 2025-07-12 08:07:00 -07:00
fix: gracefully handling hid receiver disconnection
This commit is contained in:
parent
afe300cd8a
commit
0113286b4f
2 changed files with 23 additions and 1 deletions
|
@ -4,6 +4,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/bettercap/nrf24"
|
||||
"github.com/google/gousb"
|
||||
)
|
||||
|
||||
func (mod *HIDRecon) doHopping() {
|
||||
|
@ -26,7 +27,13 @@ func (mod *HIDRecon) doHopping() {
|
|||
mod.channel = 1
|
||||
}
|
||||
if err := mod.dongle.SetChannel(mod.channel); err != nil {
|
||||
mod.Warning("error hopping on channel %d: %v", mod.channel, err)
|
||||
if err == gousb.ErrorNoDevice {
|
||||
mod.Error("device disconnected, stopping module")
|
||||
mod.forceStop()
|
||||
return
|
||||
} else {
|
||||
mod.Warning("error hopping on channel %d: %v", mod.channel, err)
|
||||
}
|
||||
} else {
|
||||
mod.lastHop = time.Now()
|
||||
}
|
||||
|
@ -107,6 +114,11 @@ func (mod *HIDRecon) Start() error {
|
|||
|
||||
buf, err := mod.dongle.ReceivePayload()
|
||||
if err != nil {
|
||||
if err == gousb.ErrorNoDevice {
|
||||
mod.Error("device disconnected, stopping module")
|
||||
mod.forceStop()
|
||||
return
|
||||
}
|
||||
mod.Warning("error receiving payload from channel %d: %v", mod.channel, err)
|
||||
continue
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue