1
0
mirror of https://github.com/billz/raspap-webgui.git synced 2023-10-10 13:37:24 +02:00

WIP: txpower feature

This commit is contained in:
billz 2021-04-20 15:19:00 +01:00
parent 07ea4d2519
commit 6c674537bb
6 changed files with 29 additions and 5 deletions

View File

@ -120,6 +120,11 @@ $(document).on("click", "#gen_wpa_passphrase", function(e) {
$('#txtwpapassphrase').val(genPassword(63));
});
// Enable Bootstrap tooltips
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
function genPassword(pwdLen) {
var pwdChars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
var rndPass = Array(pwdLen).fill(pwdChars).map(function(x) { return x[Math.floor(Math.random() * x.length)] }).join('');

View File

@ -49,6 +49,9 @@
"AllowedIPs": ["10.8.2.0/24"],
"PersistentKeepalive": [ "15" ]
}
},
"txpower": {
"dbm": [ "auto", "30", "20", "17", "10", "6", "3", "1", "0" ]
}
}

View File

@ -152,15 +152,16 @@ function getDefaultNetValue($svc,$iface,$key)
* Returns default options for the specified service
*
* @param string $svc
* @param string $key
* @return object $json
*/
function getDefaultNetOpts($svc)
function getDefaultNetOpts($svc,$key)
{
$json = json_decode(file_get_contents(RASPI_CONFIG_NETWORK), true);
if ($json === null) {
return false;
} else {
return $json[$svc]['options'];
return $json[$svc][$key];
}
}
@ -774,4 +775,4 @@ function preg_only_match($pat,$haystack) {
function qr_encode($str)
{
return preg_replace('/(?<!\\\)([\":;,])/', '\\\\\1', $str);
}
}

View File

@ -25,6 +25,7 @@ function DisplayHostAPDConfig()
];
$arrSecurity = array(1 => 'WPA', 2 => 'WPA2', 3 => 'WPA+WPA2', 'none' => _("None"));
$arrEncType = array('TKIP' => 'TKIP', 'CCMP' => 'CCMP', 'TKIP CCMP' => 'TKIP+CCMP');
$arrTxPower = getDefaultNetOpts('txpower','dbm');
$managedModeEnabled = false;
exec("ip -o link show | awk -F': ' '{print $2}'", $interfaces);
sort($interfaces);
@ -102,6 +103,7 @@ function DisplayHostAPDConfig()
"selectedHwMode",
"arrSecurity",
"arrEncType",
"arrTxPower",
"arrHostapdConf"
)
);
@ -306,13 +308,13 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
$ip_address.= (!preg_match('/.*\/\d+/', $ip_address)) ? '/'.mask2cidr($netmask) : null;
if ($bridgedEnable == 1) {
$config = array_keys(getDefaultNetOpts('dhcp'));
$config = array_keys(getDefaultNetOpts('dhcp','options'));
$config[] = PHP_EOL.'# RaspAP br0 configuration';
$config[] = 'denyinterfaces eth0 wlan0';
$config[] = 'interface br0';
$config[] = PHP_EOL;
} elseif ($wifiAPEnable == 1) {
$config = array_keys(getDefaultNetOpts('dhcp'));
$config = array_keys(getDefaultNetOpts('dhcp','options'));
$config[] = PHP_EOL.'# RaspAP uap0 configuration';
$config[] = 'interface uap0';
$config[] = 'static ip_address='.$ip_address;

View File

@ -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/ifup *
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:/etc/raspap/hostapd/enablelog.sh
www-data ALL=(ALL) NOPASSWD:/etc/raspap/hostapd/disablelog.sh

View File

@ -1,3 +1,4 @@
<?php echo '<pre>' . var_export($arrTxPower, true) . '</pre>'; ?>
<div class="tab-pane fade" id="advanced">
<h4 class="mt-3"><?php echo _("Advanced settings"); ?></h4>
<div class="row">
@ -52,6 +53,17 @@
</p>
</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" data-toggle="tooltip" data-placement="right" title="<?php echo _("dBm is an abbreviation for decibel relative to one milliwatt. It is a unit of level used to indicate that a power ratio is expressed in decibels (dB) with reference to one milliwatt (mW)."); ?>"></i>
<?php
SelectorOptions('txpower', $arrTxPower, 'auto', 'cbxtxpower');
?>
<small id="txpower_help" class="text-muted"><?php echo _("Sets the txpower option for the AP interface and the configured country."); ?></small>
</div>
</div>
<div class="row">
<div class="form-group col-md-6">
<label for="max_num_sta"><?php echo _("Maximum number of clients") ?></label>