mirror of
https://github.com/bettercap/bettercap
synced 2025-08-14 10:46:57 -07:00
fix: make sure that wifi channels are unique and sorted
This commit is contained in:
parent
8d8af63577
commit
2d03782fe1
1 changed files with 8 additions and 1 deletions
|
@ -5,6 +5,8 @@ import (
|
|||
"fmt"
|
||||
"net"
|
||||
"regexp"
|
||||
"slices"
|
||||
"sort"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
|
@ -485,8 +487,13 @@ func (mod *WiFiModule) setFrequencies(freqs []int) {
|
|||
mod.frequencies = freqs
|
||||
channels := []int{}
|
||||
for _, freq := range freqs {
|
||||
channels = append(channels, network.Dot11Freq2Chan(freq))
|
||||
channel := network.Dot11Freq2Chan(freq)
|
||||
if !slices.Contains(channels, channel) {
|
||||
channels = append(channels, channel)
|
||||
}
|
||||
}
|
||||
sort.Ints(channels)
|
||||
|
||||
mod.State.Store("channels", channels)
|
||||
|
||||
mod.Info("channels: %v", channels)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue