mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 13:09:49 -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"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"slices"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
@ -485,8 +487,13 @@ func (mod *WiFiModule) setFrequencies(freqs []int) {
|
||||||
mod.frequencies = freqs
|
mod.frequencies = freqs
|
||||||
channels := []int{}
|
channels := []int{}
|
||||||
for _, freq := range freqs {
|
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.State.Store("channels", channels)
|
||||||
|
|
||||||
mod.Info("channels: %v", channels)
|
mod.Info("channels: %v", channels)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue