fixed a bug caused by multiple wifi devices attached with different supported frequencies

This commit is contained in:
evilsocket 2019-03-26 20:30:33 +01:00
commit a3b730ce69
No known key found for this signature in database
GPG key ID: 1564D7F30393A456

View file

@ -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