mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 13:09:49 -07:00
new: new hid.ttl parameter (fixes #560)
This commit is contained in:
parent
8ec91c9206
commit
f14470c8f6
2 changed files with 12 additions and 3 deletions
|
@ -17,6 +17,7 @@ type HIDRecon struct {
|
||||||
dongle *nrf24.Dongle
|
dongle *nrf24.Dongle
|
||||||
waitGroup *sync.WaitGroup
|
waitGroup *sync.WaitGroup
|
||||||
channel int
|
channel int
|
||||||
|
devTTL int
|
||||||
hopPeriod time.Duration
|
hopPeriod time.Duration
|
||||||
pingPeriod time.Duration
|
pingPeriod time.Duration
|
||||||
sniffPeriod time.Duration
|
sniffPeriod time.Duration
|
||||||
|
@ -45,6 +46,7 @@ func NewHIDRecon(s *session.Session) *HIDRecon {
|
||||||
waitGroup: &sync.WaitGroup{},
|
waitGroup: &sync.WaitGroup{},
|
||||||
sniffLock: &sync.Mutex{},
|
sniffLock: &sync.Mutex{},
|
||||||
writeLock: &sync.Mutex{},
|
writeLock: &sync.Mutex{},
|
||||||
|
devTTL: 1200,
|
||||||
hopPeriod: 100 * time.Millisecond,
|
hopPeriod: 100 * time.Millisecond,
|
||||||
pingPeriod: 100 * time.Millisecond,
|
pingPeriod: 100 * time.Millisecond,
|
||||||
sniffPeriod: 500 * time.Millisecond,
|
sniffPeriod: 500 * time.Millisecond,
|
||||||
|
@ -117,6 +119,10 @@ func NewHIDRecon(s *session.Session) *HIDRecon {
|
||||||
|
|
||||||
mod.AddHandler(inject)
|
mod.AddHandler(inject)
|
||||||
|
|
||||||
|
mod.AddParam(session.NewIntParameter("hid.ttl",
|
||||||
|
fmt.Sprintf("%d", mod.devTTL),
|
||||||
|
"Seconds of inactivity to consider a device as not in range."))
|
||||||
|
|
||||||
mod.AddParam(session.NewBoolParameter("hid.lna",
|
mod.AddParam(session.NewBoolParameter("hid.lna",
|
||||||
"true",
|
"true",
|
||||||
"If true, enable the LNA power amplifier for CrazyRadio devices."))
|
"If true, enable the LNA power amplifier for CrazyRadio devices."))
|
||||||
|
@ -170,6 +176,10 @@ func (mod *HIDRecon) Configure() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err, mod.devTTL = mod.IntParam("hid.ttl"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
if err, n = mod.IntParam("hid.hop.period"); err != nil {
|
if err, n = mod.IntParam("hid.hop.period"); err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -68,13 +68,12 @@ func (mod *HIDRecon) onDeviceDetected(buf []byte) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var maxDeviceTTL = 20 * time.Minute
|
|
||||||
|
|
||||||
func (mod *HIDRecon) devPruner() {
|
func (mod *HIDRecon) devPruner() {
|
||||||
mod.waitGroup.Add(1)
|
mod.waitGroup.Add(1)
|
||||||
defer mod.waitGroup.Done()
|
defer mod.waitGroup.Done()
|
||||||
|
|
||||||
mod.Debug("devices pruner started.")
|
maxDeviceTTL := time.Duration(mod.devTTL) * time.Second
|
||||||
|
mod.Debug("devices pruner started with ttl %v", maxDeviceTTL)
|
||||||
for mod.Running() {
|
for mod.Running() {
|
||||||
for _, dev := range mod.Session.HID.Devices() {
|
for _, dev := range mod.Session.HID.Devices() {
|
||||||
sinceLastSeen := time.Since(dev.LastSeen)
|
sinceLastSeen := time.Since(dev.LastSeen)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue