mirror of
https://github.com/billz/raspap-webgui.git
synced 2025-03-01 10:31:47 +00:00
Add iwRegSet() -> set reg domain for selected country
This commit is contained in:
parent
df7fd21cc5
commit
fee5a69342
@ -32,7 +32,7 @@ function DisplayHostAPDConfig()
|
||||
exec("ip -o link show | awk -F': ' '{print $2}'", $interfaces);
|
||||
sort($interfaces);
|
||||
|
||||
exec("iw reg get | awk '/country / { sub(/:/,\"\",$2); print $2 }'", $country_code);
|
||||
$reg_domain = shell_exec("iw reg get | grep -o 'country [A-Z]\{2\}' | awk 'NR==1{print $2}'");
|
||||
|
||||
$cmd = "iw dev ".$_SESSION['ap_interface']." info | awk '$1==\"txpower\" {print $2}'";
|
||||
exec($cmd, $txpower);
|
||||
@ -43,7 +43,7 @@ function DisplayHostAPDConfig()
|
||||
}
|
||||
if (!RASPI_MONITOR_ENABLED) {
|
||||
if (isset($_POST['SaveHostAPDSettings'])) {
|
||||
SaveHostAPDConfig($arrSecurity, $arrEncType, $arr80211Standard, $interfaces, $status);
|
||||
SaveHostAPDConfig($arrSecurity, $arrEncType, $arr80211Standard, $interfaces, $reg_domain, $status);
|
||||
}
|
||||
}
|
||||
$arrHostapdConf = parse_ini_file(RASPI_CONFIG.'/hostapd.ini');
|
||||
@ -98,10 +98,12 @@ function DisplayHostAPDConfig()
|
||||
} else {
|
||||
$arrConfig['disassoc_low_ack_bool'] = 0;
|
||||
}
|
||||
|
||||
// assign country_code from iw reg if not set in config
|
||||
if (empty($arrConfig['country_code']) && isset($country_code[0])) {
|
||||
$arrConfig['country_code'] = $country_code[0];
|
||||
}
|
||||
|
||||
// set txpower with iw if value is non-default ('auto')
|
||||
if (isset($_POST['txpower'])) {
|
||||
if ($_POST['txpower'] != 'auto') {
|
||||
@ -163,10 +165,11 @@ function DisplayHostAPDConfig()
|
||||
* @param array $enc_types
|
||||
* @param array $modes
|
||||
* @param string $interface
|
||||
* @param string $reg_domain
|
||||
* @param object $status
|
||||
* @return boolean
|
||||
*/
|
||||
function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
|
||||
function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $reg_domain, $status)
|
||||
{
|
||||
// It should not be possible to send bad data for these fields.
|
||||
// If wpa fields are absent, return false and log securely.
|
||||
@ -295,6 +298,8 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
|
||||
if (strlen($_POST['country_code']) !== 0 && strlen($_POST['country_code']) != 2) {
|
||||
$status->addMessage('Country code must be blank or two characters', 'danger');
|
||||
$good_input = false;
|
||||
} else {
|
||||
$country_code = $_POST['country_code'];
|
||||
}
|
||||
if (isset($_POST['beaconintervalEnable'])) {
|
||||
if (!is_numeric($_POST['beacon_interval'])) {
|
||||
@ -312,6 +317,10 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
|
||||
if ($good_input) {
|
||||
$return = updateHostapdConfig($ignore_broadcast_ssid,$wifiAPEnable,$bridgedEnable);
|
||||
|
||||
if (trim($country_code) != trim($reg_domain)) {
|
||||
$return = iwRegSet($country_code, $status);
|
||||
}
|
||||
|
||||
// Fetch dhcp-range, lease time from system config
|
||||
$syscfg = parse_ini_file(RASPI_DNSMASQ_PREFIX.$ap_iface.'.conf', false, INI_SCANNER_RAW);
|
||||
|
||||
@ -483,3 +492,18 @@ function updateHostapdConfig($ignore_broadcast_ssid,$wifiAPEnable,$bridgedEnable
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes iw to set the specified ISO 2-letter country code
|
||||
*
|
||||
* @param string $country_code
|
||||
* @param object $status
|
||||
* @return boolean $result
|
||||
*/
|
||||
function iwRegSet(string $country_code, $status)
|
||||
{
|
||||
$status->addMessage('Setting wireless regulatory domain to '. $country_code, 'success');
|
||||
$country_code = escapeshellarg($country_code);
|
||||
$result = shell_exec("sudo iw reg set $country_code");
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user