mirror of
https://github.com/bettercap/bettercap
synced 2025-08-19 21:13:18 -07:00
fix: using iw instead of iwconfig whenever possible (fixes #657)
This commit is contained in:
parent
83c6cde152
commit
2f3390cf36
2 changed files with 24 additions and 6 deletions
|
@ -285,7 +285,14 @@ func ActivateInterface(name string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetInterfaceTxPower(name string, txpower int) error {
|
func SetInterfaceTxPower(name string, txpower int) error {
|
||||||
if core.HasBinary("iwconfig") {
|
if core.HasBinary("iw") {
|
||||||
|
Debug("SetInterfaceTxPower(%s, %d) iw based", name, txpower)
|
||||||
|
if _, err := core.Exec("iw", []string{"dev", name, "set", "txpower", fmt.Sprintf("%dmBm",
|
||||||
|
txpower)}); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else if core.HasBinary("iwconfig") {
|
||||||
|
Debug("SetInterfaceTxPower(%s, %d) iwconfig based", name, txpower)
|
||||||
if out, err := core.Exec("iwconfig", []string{name, "txpower", fmt.Sprintf("%d", txpower)}); err != nil {
|
if out, err := core.Exec("iwconfig", []string{name, "txpower", fmt.Sprintf("%d", txpower)}); err != nil {
|
||||||
return err
|
return err
|
||||||
} else if out != "" {
|
} else if out != "" {
|
||||||
|
|
|
@ -41,12 +41,23 @@ func SetInterfaceChannel(iface string, channel int) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if core.HasBinary("iw") {
|
||||||
|
Debug("SetInterfaceChannel(%s, %d) iw based", iface, channel)
|
||||||
|
out, err := core.Exec("iw", []string{"dev", iface, "set", "channel", fmt.Sprintf("%d", channel)})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
} else if out != "" {
|
||||||
|
return fmt.Errorf("Unexpected output while setting interface %s to channel %d: %s", iface, channel, out)
|
||||||
|
}
|
||||||
|
} else if core.HasBinary("iwconfig") {
|
||||||
|
Debug("SetInterfaceChannel(%s, %d) iwconfig based")
|
||||||
out, err := core.Exec("iwconfig", []string{iface, "channel", fmt.Sprintf("%d", channel)})
|
out, err := core.Exec("iwconfig", []string{iface, "channel", fmt.Sprintf("%d", channel)})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
} else if out != "" {
|
} else if out != "" {
|
||||||
return fmt.Errorf("Unexpected output while setting interface %s to channel %d: %s", iface, channel, out)
|
return fmt.Errorf("Unexpected output while setting interface %s to channel %d: %s", iface, channel, out)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SetInterfaceCurrentChannel(iface, channel)
|
SetInterfaceCurrentChannel(iface, channel)
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue