mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 21:13:18 -07:00
Add initial test for net_linux.go
More tests needed based on iwlist output, but the side-effect-free part of GetSupportedFrequencies() has been been broken out into a function that can now be tested without calling core.Exec().
This commit is contained in:
parent
3c3ed30001
commit
56d1655727
2 changed files with 48 additions and 4 deletions
|
@ -59,13 +59,12 @@ func SetInterfaceChannel(iface string, channel int) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func GetSupportedFrequencies(iface string) ([]int, error) {
|
||||
func processSupportedFrequencies(output string, err error) ([]int, error) {
|
||||
freqs := make([]int, 0)
|
||||
out, err := core.Exec("iwlist", []string{iface, "freq"})
|
||||
if err != nil {
|
||||
return freqs, err
|
||||
} else if out != "" {
|
||||
scanner := bufio.NewScanner(strings.NewReader(out))
|
||||
} else if output != "" {
|
||||
scanner := bufio.NewScanner(strings.NewReader(output))
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
matches := WiFiFreqParser.FindStringSubmatch(line)
|
||||
|
@ -78,3 +77,8 @@ func GetSupportedFrequencies(iface string) ([]int, error) {
|
|||
}
|
||||
return freqs, nil
|
||||
}
|
||||
|
||||
func GetSupportedFrequencies(iface string) ([]int, error) {
|
||||
out, err := core.Exec("iwlist", []string{iface, "freq"})
|
||||
return processSupportedFrequencies(out, err)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue