From a3b730ce69c45f1e1cf5b1585757d9f165b0dcda Mon Sep 17 00:00:00 2001 From: evilsocket Date: Tue, 26 Mar 2019 20:30:33 +0100 Subject: [PATCH] fixed a bug caused by multiple wifi devices attached with different supported frequencies --- modules/wifi/wifi.go | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/modules/wifi/wifi.go b/modules/wifi/wifi.go index 998c2121..4ac37e34 100644 --- a/modules/wifi/wifi.go +++ b/modules/wifi/wifi.go @@ -441,23 +441,21 @@ func (mod *WiFiModule) Configure() error { mod.hopPeriod = time.Duration(hopPeriod) * time.Millisecond if mod.source == "" { - // No channels setted, retrieve frequencies supported by the card - if len(mod.frequencies) == 0 { - if freqs, err := network.GetSupportedFrequencies(ifName); err != nil { - return fmt.Errorf("error while getting supported frequencies of %s: %s", ifName, err) - } else { - mod.setFrequencies(freqs) - } - - mod.Debug("wifi supported frequencies: %v", mod.frequencies) - - // we need to start somewhere, this is just to check if - // this OS supports switching channel programmatically. - if err = network.SetInterfaceChannel(ifName, 1); err != nil { - return fmt.Errorf("error while initializing %s to channel 1: %s", ifName, err) - } - mod.Info("started (min rssi: %d dBm)", mod.minRSSI) + if freqs, err := network.GetSupportedFrequencies(ifName); err != nil { + return fmt.Errorf("error while getting supported frequencies of %s: %s", ifName, err) + } else { + mod.setFrequencies(freqs) } + + mod.Debug("wifi supported frequencies: %v", mod.frequencies) + + // we need to start somewhere, this is just to check if + // this OS supports switching channel programmatically. + if err = network.SetInterfaceChannel(ifName, 1); err != nil { + return fmt.Errorf("error while initializing %s to channel 1: %s", ifName, err) + } + + mod.Info("started (min rssi: %d dBm)", mod.minRSSI) } return nil