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
|
source string
|
||||||
channel int
|
channel int
|
||||||
hopPeriod time.Duration
|
hopPeriod time.Duration
|
||||||
|
hopChanges chan bool
|
||||||
frequencies []int
|
frequencies []int
|
||||||
ap *network.AccessPoint
|
ap *network.AccessPoint
|
||||||
stickChan int
|
stickChan int
|
||||||
|
@ -55,6 +56,7 @@ func NewWiFiModule(s *session.Session) *WiFiModule {
|
||||||
channel: 0,
|
channel: 0,
|
||||||
stickChan: 0,
|
stickChan: 0,
|
||||||
hopPeriod: 250 * time.Millisecond,
|
hopPeriod: 250 * time.Millisecond,
|
||||||
|
hopChanges: make(chan bool),
|
||||||
ap: nil,
|
ap: nil,
|
||||||
skipBroken: true,
|
skipBroken: true,
|
||||||
apRunning: false,
|
apRunning: false,
|
||||||
|
@ -101,6 +103,7 @@ func NewWiFiModule(s *session.Session) *WiFiModule {
|
||||||
w.ap = nil
|
w.ap = nil
|
||||||
w.stickChan = 0
|
w.stickChan = 0
|
||||||
w.frequencies, err = network.GetSupportedFrequencies(w.Session.Interface.Name())
|
w.frequencies, err = network.GetSupportedFrequencies(w.Session.Interface.Name())
|
||||||
|
w.hopChanges <- true
|
||||||
return err
|
return err
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
@ -232,6 +235,7 @@ func NewWiFiModule(s *session.Session) *WiFiModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
w.frequencies = freqs
|
w.frequencies = freqs
|
||||||
|
w.hopChanges <- true
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -41,6 +41,8 @@ func (w *WiFiModule) channelHopper() {
|
||||||
}
|
}
|
||||||
|
|
||||||
frequencies := w.frequencies
|
frequencies := w.frequencies
|
||||||
|
|
||||||
|
loopCurrentChannels:
|
||||||
for _, frequency := range frequencies {
|
for _, frequency := range frequencies {
|
||||||
channel := network.Dot11Freq2Chan(frequency)
|
channel := network.Dot11Freq2Chan(frequency)
|
||||||
// stick to the access point channel as long as it's selected
|
// stick to the access point channel as long as it's selected
|
||||||
|
@ -57,10 +59,15 @@ func (w *WiFiModule) channelHopper() {
|
||||||
}
|
}
|
||||||
w.chanLock.Unlock()
|
w.chanLock.Unlock()
|
||||||
|
|
||||||
time.Sleep(delay)
|
select {
|
||||||
|
case _ = <-w.hopChanges:
|
||||||
|
log.Debug("hop changed")
|
||||||
|
break loopCurrentChannels
|
||||||
|
case <-time.After(delay):
|
||||||
if !w.Running() {
|
if !w.Running() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue