mirror of
https://github.com/billz/raspap-webgui.git
synced 2023-10-10 13:37:24 +02:00
Merge pull request #26 from RaspAP/feature/tx-power
Feature: Set TxPower for AP
This commit is contained in:
commit
fcb601e369
@ -120,6 +120,11 @@ $(document).on("click", "#gen_wpa_passphrase", function(e) {
|
|||||||
$('#txtwpapassphrase').val(genPassword(63));
|
$('#txtwpapassphrase').val(genPassword(63));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Enable Bootstrap tooltips
|
||||||
|
$(function () {
|
||||||
|
$('[data-toggle="tooltip"]').tooltip()
|
||||||
|
})
|
||||||
|
|
||||||
function genPassword(pwdLen) {
|
function genPassword(pwdLen) {
|
||||||
var pwdChars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
var pwdChars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||||
var rndPass = Array(pwdLen).fill(pwdChars).map(function(x) { return x[Math.floor(Math.random() * x.length)] }).join('');
|
var rndPass = Array(pwdLen).fill(pwdChars).map(function(x) { return x[Math.floor(Math.random() * x.length)] }).join('');
|
||||||
|
@ -49,6 +49,9 @@
|
|||||||
"AllowedIPs": ["10.8.2.0/24"],
|
"AllowedIPs": ["10.8.2.0/24"],
|
||||||
"PersistentKeepalive": [ "15" ]
|
"PersistentKeepalive": [ "15" ]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"txpower": {
|
||||||
|
"dbm": [ "auto", "30", "20", "17", "10", "6", "3", "1", "0" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,15 +152,16 @@ function getDefaultNetValue($svc,$iface,$key)
|
|||||||
* Returns default options for the specified service
|
* Returns default options for the specified service
|
||||||
*
|
*
|
||||||
* @param string $svc
|
* @param string $svc
|
||||||
|
* @param string $key
|
||||||
* @return object $json
|
* @return object $json
|
||||||
*/
|
*/
|
||||||
function getDefaultNetOpts($svc)
|
function getDefaultNetOpts($svc,$key)
|
||||||
{
|
{
|
||||||
$json = json_decode(file_get_contents(RASPI_CONFIG_NETWORK), true);
|
$json = json_decode(file_get_contents(RASPI_CONFIG_NETWORK), true);
|
||||||
if ($json === null) {
|
if ($json === null) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return $json[$svc]['options'];
|
return $json[$svc][$key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,12 +25,17 @@ function DisplayHostAPDConfig()
|
|||||||
];
|
];
|
||||||
$arrSecurity = array(1 => 'WPA', 2 => 'WPA2', 3 => 'WPA+WPA2', 'none' => _("None"));
|
$arrSecurity = array(1 => 'WPA', 2 => 'WPA2', 3 => 'WPA+WPA2', 'none' => _("None"));
|
||||||
$arrEncType = array('TKIP' => 'TKIP', 'CCMP' => 'CCMP', 'TKIP CCMP' => 'TKIP+CCMP');
|
$arrEncType = array('TKIP' => 'TKIP', 'CCMP' => 'CCMP', 'TKIP CCMP' => 'TKIP+CCMP');
|
||||||
|
$arrTxPower = getDefaultNetOpts('txpower','dbm');
|
||||||
$managedModeEnabled = false;
|
$managedModeEnabled = false;
|
||||||
exec("ip -o link show | awk -F': ' '{print $2}'", $interfaces);
|
exec("ip -o link show | awk -F': ' '{print $2}'", $interfaces);
|
||||||
sort($interfaces);
|
sort($interfaces);
|
||||||
|
|
||||||
exec("iw reg get | awk '/country / { sub(/:/,\"\",$2); print $2 }'", $country_code);
|
exec("iw reg get | awk '/country / { sub(/:/,\"\",$2); print $2 }'", $country_code);
|
||||||
|
|
||||||
|
$cmd = "iw dev ".$_SESSION['ap_interface']." info | awk '$1==\"txpower\" {print $2}'";
|
||||||
|
exec($cmd, $txpower);
|
||||||
|
$txpower = intval($txpower[0]);
|
||||||
|
|
||||||
if (!RASPI_MONITOR_ENABLED) {
|
if (!RASPI_MONITOR_ENABLED) {
|
||||||
if (isset($_POST['SaveHostAPDSettings'])) {
|
if (isset($_POST['SaveHostAPDSettings'])) {
|
||||||
SaveHostAPDConfig($arrSecurity, $arrEncType, $arr80211Standard, $interfaces, $status);
|
SaveHostAPDConfig($arrSecurity, $arrEncType, $arr80211Standard, $interfaces, $status);
|
||||||
@ -61,7 +66,7 @@ function DisplayHostAPDConfig()
|
|||||||
}
|
}
|
||||||
|
|
||||||
exec('cat '. RASPI_HOSTAPD_CONFIG, $hostapdconfig);
|
exec('cat '. RASPI_HOSTAPD_CONFIG, $hostapdconfig);
|
||||||
exec('iwgetid '. $_POST['interface']. ' -r', $wifiNetworkID);
|
exec('iwgetid '. $_POST['interface'].' -r', $wifiNetworkID);
|
||||||
if (!empty($wifiNetworkID[0])) {
|
if (!empty($wifiNetworkID[0])) {
|
||||||
$managedModeEnabled = true;
|
$managedModeEnabled = true;
|
||||||
}
|
}
|
||||||
@ -89,6 +94,17 @@ function DisplayHostAPDConfig()
|
|||||||
if (!isset($arrConfig['country_code']) && isset($country_code[0])) {
|
if (!isset($arrConfig['country_code']) && isset($country_code[0])) {
|
||||||
$arrConfig['country_code'] = $country_code[0];
|
$arrConfig['country_code'] = $country_code[0];
|
||||||
}
|
}
|
||||||
|
// set txpower with iw if value is non-default ('auto')
|
||||||
|
if (isset($_POST['txpower']) && ($_POST['txpower'] != 'auto')) {
|
||||||
|
$sdBm = $_POST['txpower'] * 100;
|
||||||
|
exec('sudo /sbin/iw dev '.$_POST['interface'].' set txpower fixed '.$sdBm, $return);
|
||||||
|
$status->addMessage('Setting transmit power to '.$_POST['txpower'].' dBm.', 'success');
|
||||||
|
$txpower = $_POST['txpower'];
|
||||||
|
} elseif ($_POST['txpower'] == 'auto') {
|
||||||
|
exec('sudo /sbin/iw dev '.$_POST['interface'].' set txpower auto', $return);
|
||||||
|
$status->addMessage('Setting transmit power to '.$_POST['txpower'].'.', 'success');
|
||||||
|
$txpower = $_POST['txpower'];
|
||||||
|
}
|
||||||
|
|
||||||
echo renderTemplate(
|
echo renderTemplate(
|
||||||
"hostapd", compact(
|
"hostapd", compact(
|
||||||
@ -102,6 +118,8 @@ function DisplayHostAPDConfig()
|
|||||||
"selectedHwMode",
|
"selectedHwMode",
|
||||||
"arrSecurity",
|
"arrSecurity",
|
||||||
"arrEncType",
|
"arrEncType",
|
||||||
|
"arrTxPower",
|
||||||
|
"txpower",
|
||||||
"arrHostapdConf"
|
"arrHostapdConf"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -306,13 +324,13 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
|
|||||||
$ip_address.= (!preg_match('/.*\/\d+/', $ip_address)) ? '/'.mask2cidr($netmask) : null;
|
$ip_address.= (!preg_match('/.*\/\d+/', $ip_address)) ? '/'.mask2cidr($netmask) : null;
|
||||||
|
|
||||||
if ($bridgedEnable == 1) {
|
if ($bridgedEnable == 1) {
|
||||||
$config = array_keys(getDefaultNetOpts('dhcp'));
|
$config = array_keys(getDefaultNetOpts('dhcp','options'));
|
||||||
$config[] = PHP_EOL.'# RaspAP br0 configuration';
|
$config[] = PHP_EOL.'# RaspAP br0 configuration';
|
||||||
$config[] = 'denyinterfaces eth0 wlan0';
|
$config[] = 'denyinterfaces eth0 wlan0';
|
||||||
$config[] = 'interface br0';
|
$config[] = 'interface br0';
|
||||||
$config[] = PHP_EOL;
|
$config[] = PHP_EOL;
|
||||||
} elseif ($wifiAPEnable == 1) {
|
} elseif ($wifiAPEnable == 1) {
|
||||||
$config = array_keys(getDefaultNetOpts('dhcp'));
|
$config = array_keys(getDefaultNetOpts('dhcp','options'));
|
||||||
$config[] = PHP_EOL.'# RaspAP uap0 configuration';
|
$config[] = PHP_EOL.'# RaspAP uap0 configuration';
|
||||||
$config[] = 'interface uap0';
|
$config[] = 'interface uap0';
|
||||||
$config[] = 'static ip_address='.$ip_address;
|
$config[] = 'static ip_address='.$ip_address;
|
||||||
|
@ -32,6 +32,7 @@ www-data ALL=(ALL) NOPASSWD:/sbin/ip link set wlan[0-9] up
|
|||||||
www-data ALL=(ALL) NOPASSWD:/sbin/ip -s a f label wlan[0-9]
|
www-data ALL=(ALL) NOPASSWD:/sbin/ip -s a f label wlan[0-9]
|
||||||
www-data ALL=(ALL) NOPASSWD:/sbin/ifup *
|
www-data ALL=(ALL) NOPASSWD:/sbin/ifup *
|
||||||
www-data ALL=(ALL) NOPASSWD:/sbin/ifdown *
|
www-data ALL=(ALL) NOPASSWD:/sbin/ifdown *
|
||||||
|
www-data ALL=(ALL) NOPASSWD:/sbin/iw
|
||||||
www-data ALL=(ALL) NOPASSWD:/bin/cp /etc/raspap/networking/dhcpcd.conf /etc/dhcpcd.conf
|
www-data ALL=(ALL) NOPASSWD:/bin/cp /etc/raspap/networking/dhcpcd.conf /etc/dhcpcd.conf
|
||||||
www-data ALL=(ALL) NOPASSWD:/etc/raspap/hostapd/enablelog.sh
|
www-data ALL=(ALL) NOPASSWD:/etc/raspap/hostapd/enablelog.sh
|
||||||
www-data ALL=(ALL) NOPASSWD:/etc/raspap/hostapd/disablelog.sh
|
www-data ALL=(ALL) NOPASSWD:/etc/raspap/hostapd/disablelog.sh
|
||||||
|
Binary file not shown.
@ -528,8 +528,8 @@ msgstr "Hide SSID in broadcast"
|
|||||||
msgid "Maximum number of clients"
|
msgid "Maximum number of clients"
|
||||||
msgstr "Maximum number of clients"
|
msgstr "Maximum number of clients"
|
||||||
|
|
||||||
msgid "Configures the max_num_sta option of hostapd. The default and maximum is 2007. If empty or 0, the default applies."
|
msgid "Configures the <code>max_num_sta</code> option of hostapd. The default and maximum is 2007. If empty or 0, the default applies."
|
||||||
msgstr "Configures the max_num_sta option of hostapd. The default and maximum is 2007. If empty or 0, the default applies."
|
msgstr "Configures the <code>max_num_sta</code> option of hostapd. The default and maximum is 2007. If empty or 0, the default applies."
|
||||||
|
|
||||||
msgid "Beacon interval"
|
msgid "Beacon interval"
|
||||||
msgstr "Beacon interval"
|
msgstr "Beacon interval"
|
||||||
@ -549,6 +549,15 @@ msgstr "Close"
|
|||||||
msgid "Enable this option to log <code>hostapd</code> activity."
|
msgid "Enable this option to log <code>hostapd</code> activity."
|
||||||
msgstr "Enable this option to log <code>hostapd</code> activity."
|
msgstr "Enable this option to log <code>hostapd</code> activity."
|
||||||
|
|
||||||
|
msgid "Transmit power (dBm)"
|
||||||
|
msgstr "Transmit power (dBm)"
|
||||||
|
|
||||||
|
msgid "Sets the <code>txpower</code> option for the AP interface and the configured country."
|
||||||
|
msgstr "Sets the <code>txpower</code> option for the AP interface and the configured country."
|
||||||
|
|
||||||
|
msgid "dBm is a unit of level used to indicate that a power ratio is expressed in decibels (dB) with reference to one milliwatt (mW). 30 dBm is equal to 1000 mW, while 0 dBm equals 1.25 mW."
|
||||||
|
msgstr "dBm is a unit of level used to indicate that a power ratio is expressed in decibels (dB) with reference to one milliwatt (mW). 30 dBm is equal to 1000 mW, while 0 dBm equals 1.25 mW."
|
||||||
|
|
||||||
#: includes/networking.php
|
#: includes/networking.php
|
||||||
msgid "Summary"
|
msgid "Summary"
|
||||||
msgstr "Summary"
|
msgstr "Summary"
|
||||||
|
@ -52,11 +52,22 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="form-group col-md-6">
|
||||||
|
<label for="cbxtxpower"><?php echo _("Transmit power (dBm)") ?></label>
|
||||||
|
<i class="fas fa-question-circle text-muted" data-toggle="tooltip" data-placement="auto" title="<?php echo _("dBm is a unit of level used to indicate that a power ratio is expressed in decibels (dB) with reference to one milliwatt (mW). 30 dBm is equal to 1000 mW, while 0 dBm equals 1.25 mW."); ?>"></i>
|
||||||
|
<?php
|
||||||
|
SelectorOptions('txpower', $arrTxPower, $txpower, 'cbxtxpower');
|
||||||
|
?>
|
||||||
|
<small id="txpower_help" class="text-muted"><?php echo _("Sets the <code>txpower</code> option for the AP interface and the configured country."); ?></small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="form-group col-md-6">
|
<div class="form-group col-md-6">
|
||||||
<label for="max_num_sta"><?php echo _("Maximum number of clients") ?></label>
|
<label for="max_num_sta"><?php echo _("Maximum number of clients") ?></label>
|
||||||
<input type="text" id="max_num_sta" class="form-control" name="max_num_sta" placeholder="2007" value="<?php echo $arrConfig["max_num_sta"] ?>" aria-describedby="max_num_sta_help">
|
<input type="text" id="max_num_sta" class="form-control" name="max_num_sta" placeholder="2007" value="<?php echo $arrConfig["max_num_sta"] ?>" aria-describedby="max_num_sta_help">
|
||||||
<small id="max_num_sta_help" class="text-muted"><?php echo _("Configures the max_num_sta option of hostapd. The default and maximum is 2007. If empty or 0, the default applies.") ?></small>
|
<small id="max_num_sta_help" class="text-muted"><?php echo _("Configures the <code>max_num_sta</code> option of hostapd. The default and maximum is 2007. If empty or 0, the default applies.") ?></small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
Loading…
Reference in New Issue
Block a user