Implements nohook wpa_supplicant flag

This commit is contained in:
billz 2023-05-19 12:18:25 +01:00
parent c971c5c9bc
commit 98d392d473
6 changed files with 37 additions and 4 deletions

View file

@ -46,6 +46,7 @@ if (isset($interface)) {
preg_match('/static\sdomain_name_server=(.*)/', $matched[0], $static_dns); preg_match('/static\sdomain_name_server=(.*)/', $matched[0], $static_dns);
preg_match('/fallback\sstatic_'.$interface.'/', $matched[0], $fallback); preg_match('/fallback\sstatic_'.$interface.'/', $matched[0], $fallback);
preg_match('/(?:no)?gateway/', $matched[0], $gateway); preg_match('/(?:no)?gateway/', $matched[0], $gateway);
preg_match('/nohook\swpa_supplicant/', $matched[0], $nohook_wpa_supplicant);
$dhcpdata['Metric'] = $metric[1]; $dhcpdata['Metric'] = $metric[1];
$dhcpdata['StaticIP'] = strpos($static_ip[1],'/') ? substr($static_ip[1], 0, strpos($static_ip[1],'/')) : $static_ip[1]; $dhcpdata['StaticIP'] = strpos($static_ip[1],'/') ? substr($static_ip[1], 0, strpos($static_ip[1],'/')) : $static_ip[1];
$dhcpdata['SubnetMask'] = cidr2mask($static_ip[1]); $dhcpdata['SubnetMask'] = cidr2mask($static_ip[1]);
@ -53,6 +54,7 @@ if (isset($interface)) {
$dhcpdata['StaticDNS'] = $static_dns[1]; $dhcpdata['StaticDNS'] = $static_dns[1];
$dhcpdata['FallbackEnabled'] = empty($fallback) ? false: true; $dhcpdata['FallbackEnabled'] = empty($fallback) ? false: true;
$dhcpdata['DefaultRoute'] = $gateway[0] == "gateway"; $dhcpdata['DefaultRoute'] = $gateway[0] == "gateway";
$dhcpdata['NoHookWPASupplicant'] = $nohook_wpa_supplicant[0] == "nohook wpa_supplicant";
echo json_encode($dhcpdata); echo json_encode($dhcpdata);
} }

View file

@ -216,6 +216,12 @@ function loadInterfaceDHCPSelect() {
$('#txtgateway').val(jsonData.StaticRouters); $('#txtgateway').val(jsonData.StaticRouters);
$('#chkfallback')[0].checked = jsonData.FallbackEnabled; $('#chkfallback')[0].checked = jsonData.FallbackEnabled;
$('#default-route').prop('checked', jsonData.DefaultRoute); $('#default-route').prop('checked', jsonData.DefaultRoute);
if (strInterface.startsWith("wl")) {
$('#nohook-wpa-supplicant').parent().parent().parent().show()
$('#nohook-wpa-supplicant').prop('checked', jsonData.NoHookWPASupplicant);
} else {
$('#nohook-wpa-supplicant').parent().parent().parent().hide()
}
$('#txtrangestart').val(jsonData.RangeStart); $('#txtrangestart').val(jsonData.RangeStart);
$('#txtrangeend').val(jsonData.RangeEnd); $('#txtrangeend').val(jsonData.RangeEnd);
$('#txtrangeleasetime').val(jsonData.leaseTime); $('#txtrangeleasetime').val(jsonData.leaseTime);

View file

@ -253,24 +253,27 @@ function updateDHCPConfig($iface,$status)
{ {
$cfg[] = '# RaspAP '.$iface.' configuration'; $cfg[] = '# RaspAP '.$iface.' configuration';
$cfg[] = 'interface '.$iface; $cfg[] = 'interface '.$iface;
if (isset($_POST['StaticIP'])) { if (isset($_POST['StaticIP']) && $_POST['StaticIP'] !== '') {
$mask = ($_POST['SubnetMask'] !== '' && $_POST['SubnetMask'] !== '0.0.0.0') ? '/'.mask2cidr($_POST['SubnetMask']) : null; $mask = ($_POST['SubnetMask'] !== '' && $_POST['SubnetMask'] !== '0.0.0.0') ? '/'.mask2cidr($_POST['SubnetMask']) : null;
$cfg[] = 'static ip_address='.$_POST['StaticIP'].$mask; $cfg[] = 'static ip_address='.$_POST['StaticIP'].$mask;
} }
if (isset($_POST['DefaultGateway'])) { if (isset($_POST['DefaultGateway']) && $_POST['DefaultGateway'] !== '') {
$cfg[] = 'static routers='.$_POST['DefaultGateway']; $cfg[] = 'static routers='.$_POST['DefaultGateway'];
} }
if ($_POST['DNS1'] !== '' || $_POST['DNS2'] !== '') { if ($_POST['DNS1'] !== '' || $_POST['DNS2'] !== '') {
$cfg[] = 'static domain_name_server='.$_POST['DNS1'].' '.$_POST['DNS2']; $cfg[] = 'static domain_name_server='.$_POST['DNS1'].' '.$_POST['DNS2'];
} }
if ($_POST['Metric'] !== '') { if ($_POST['Metric'] !== '') {
$cfg[] = 'metric '.$_POST['Metric']; $cfg[] = 'metric '.$_POST['Metric'];
} }
if ($_POST['Fallback'] == 1) { if ($_POST['Fallback'] == 1) {
$cfg[] = 'profile static_'.$iface; $cfg[] = 'profile static_'.$iface;
$cfg[] = 'fallback static_'.$iface; $cfg[] = 'fallback static_'.$iface;
} }
$cfg[] = $_POST['DefaultRoute'] == '1' ? 'gateway' : 'nogateway'; $cfg[] = $_POST['DefaultRoute'] == '1' ? 'gateway' : 'nogateway';
if (( substr($iface, 0, 2) === "wl") && $_POST['NoHookWPASupplicant'] == '1') {
$cfg[] = 'nohook wpa_supplicant';
}
$dhcp_cfg = file_get_contents(RASPI_DHCPCD_CONFIG); $dhcp_cfg = file_get_contents(RASPI_DHCPCD_CONFIG);
if (!preg_match('/^interface\s'.$iface.'$/m', $dhcp_cfg)) { if (!preg_match('/^interface\s'.$iface.'$/m', $dhcp_cfg)) {
$cfg[] = PHP_EOL; $cfg[] = PHP_EOL;

Binary file not shown.

View file

@ -464,6 +464,15 @@ msgstr "This option adds <code>dhcp-host</code> entries to the dnsmasq configura
msgid "This toggles the <code>gateway</code>/<code>nogateway</code> option for this interface in the DHCPCD configuration." msgid "This toggles the <code>gateway</code>/<code>nogateway</code> option for this interface in the DHCPCD configuration."
msgstr "This toggles the <code>gateway</code>/<code>nogateway</code> option for this interface in the DHCPCD configuration." msgstr "This toggles the <code>gateway</code>/<code>nogateway</code> option for this interface in the DHCPCD configuration."
msgid "This toggles the <code>nohook wpa_supplicant</code> option for this interface in the DHCPCD configuration."
msgstr "This toggles the <code>nohook wpa_supplicant</code> option for this interface in the DHCPCD configuration."
msgid "Disable wpa_supplicant dhcp hook for this interface"
msgstr "Disable wpa_supplicant dhcp hook for this interface"
msgid "If you manage wireless connections with wpa_supplicant itself, the hook may create unwanted connection events. This option disables the hook."
msgstr "If you manage wireless connections with wpa_supplicant itself, the hook may create unwanted connection events. This option disables the hook."
#: includes/hostapd.php #: includes/hostapd.php
msgid "Basic" msgid "Basic"
msgstr "Basic" msgstr "Basic"

View file

@ -67,6 +67,19 @@
</div> </div>
</div> </div>
<div class="row">
<div class="form-group col-md-6">
<div class="custom-control custom-switch">
<input class="custom-control-input" id="nohook-wpa-supplicant" type="checkbox" name="NoHookWPASupplicant" value="1" aria-describedby="hook-wpa-supplicant-description">
<label class="custom-control-label" for="nohook-wpa-supplicant"><?php echo _("Disable wpa_supplicant dhcp hook for this interface") ?></label>
<?php getTooltip('If you manage wireless connections with wpa_supplicant itself, the hook may create unwanted connection events. This option disables the hook.', 'tipnohook'); ?>
</div>
<p class="mb-0" id="hook-wpa-supplicant-description">
<small><?php echo _("This toggles the <code>nohook wpa_supplicant</code> option for this interface in the DHCPCD configuration.") ?></small>
</p>
</div>
</div>
<h5 class="mt-1">DHCP options</h5> <h5 class="mt-1">DHCP options</h5>
<div class="row"> <div class="row">
<div class="form-group col-md-6"> <div class="form-group col-md-6">