new: new wifi.region and wifi.txpower parameters

This commit is contained in:
evilsocket 2019-02-19 12:09:00 +01:00
commit 345c1f5d45
No known key found for this signature in database
GPG key ID: 1564D7F30393A456
2 changed files with 52 additions and 6 deletions

View file

@ -264,6 +264,15 @@ func FindInterface(name string) (*Endpoint, error) {
return nil, ErrNoIfaces
}
func SetWiFiRegion(region string) error {
if out, err := core.Exec("iw", []string{"reg", "set", region}); err != nil {
return err
} else if out != "" {
return fmt.Errorf("unexpected output while setting WiFi region %s: %s", region, out)
}
return nil
}
func ActivateInterface(name string) error {
if out, err := core.Exec("ifconfig", []string{name, "up"}); err != nil {
return err
@ -273,6 +282,15 @@ func ActivateInterface(name string) error {
return nil
}
func SetInterfaceTxPower(name string, txpower int) error {
if out, err := core.ExecSilent("iwconfig", []string{name, "txpower", fmt.Sprintf("%d", txpower)}); err != nil {
return err
} else if out != "" {
return fmt.Errorf("unexpected output while setting txpower to %d for interface %s: %s", txpower, name, out)
}
return nil
}
func GatewayProvidedByUser(iface *Endpoint, gateway string) (*Endpoint, error) {
Debug("GatewayProvidedByUser(%s) [cmd=%v opts=%v parser=%v]", gateway, IPv4RouteCmd, IPv4RouteCmdOpts, IPv4RouteParser)
if IPv4Validator.MatchString(gateway) {