mirror of
https://github.com/bettercap/bettercap
synced 2025-08-20 13:33:21 -07:00
fix: fixed a bug which made the wifi channel hopper react slowly to wifi.recon.channel N commands
This commit is contained in:
parent
598df7324e
commit
a3d6b353fe
2 changed files with 14 additions and 3 deletions
|
@ -28,6 +28,7 @@ type WiFiModule struct {
|
|||
source string
|
||||
channel int
|
||||
hopPeriod time.Duration
|
||||
hopChanges chan bool
|
||||
frequencies []int
|
||||
ap *network.AccessPoint
|
||||
stickChan int
|
||||
|
@ -55,6 +56,7 @@ func NewWiFiModule(s *session.Session) *WiFiModule {
|
|||
channel: 0,
|
||||
stickChan: 0,
|
||||
hopPeriod: 250 * time.Millisecond,
|
||||
hopChanges: make(chan bool),
|
||||
ap: nil,
|
||||
skipBroken: true,
|
||||
apRunning: false,
|
||||
|
@ -101,6 +103,7 @@ func NewWiFiModule(s *session.Session) *WiFiModule {
|
|||
w.ap = nil
|
||||
w.stickChan = 0
|
||||
w.frequencies, err = network.GetSupportedFrequencies(w.Session.Interface.Name())
|
||||
w.hopChanges <- true
|
||||
return err
|
||||
}))
|
||||
|
||||
|
@ -232,6 +235,7 @@ func NewWiFiModule(s *session.Session) *WiFiModule {
|
|||
}
|
||||
|
||||
w.frequencies = freqs
|
||||
w.hopChanges <- true
|
||||
|
||||
return nil
|
||||
}))
|
||||
|
|
|
@ -41,6 +41,8 @@ func (w *WiFiModule) channelHopper() {
|
|||
}
|
||||
|
||||
frequencies := w.frequencies
|
||||
|
||||
loopCurrentChannels:
|
||||
for _, frequency := range frequencies {
|
||||
channel := network.Dot11Freq2Chan(frequency)
|
||||
// stick to the access point channel as long as it's selected
|
||||
|
@ -57,9 +59,14 @@ func (w *WiFiModule) channelHopper() {
|
|||
}
|
||||
w.chanLock.Unlock()
|
||||
|
||||
time.Sleep(delay)
|
||||
if !w.Running() {
|
||||
return
|
||||
select {
|
||||
case _ = <-w.hopChanges:
|
||||
log.Debug("hop changed")
|
||||
break loopCurrentChannels
|
||||
case <-time.After(delay):
|
||||
if !w.Running() {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue