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

Merge pull request #850 from RaspAP/default-route-option

add 'default route' toggle to network interface configuration ui
This commit is contained in:
Bill Zimmerman 2021-04-05 10:56:48 +02:00 committed by GitHub
commit 260aa7694b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 0 deletions

View File

@ -45,12 +45,14 @@ if (isset($interface)) {
preg_match('/static\srouters=(.*)/', $matched[0], $static_routers);
preg_match('/static\sdomain_name_server=(.*)/', $matched[0], $static_dns);
preg_match('/fallback\sstatic_'.$interface.'/', $matched[0], $fallback);
preg_match('/(?:no)?gateway/', $matched[0], $gateway);
$dhcpdata['Metric'] = $metric[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['StaticRouters'] = $static_routers[1];
$dhcpdata['StaticDNS'] = $static_dns[1];
$dhcpdata['FallbackEnabled'] = empty($fallback) ? false: true;
$dhcpdata['DefaultRoute'] = empty($gateway) || $gateway[0] == "gateway";
echo json_encode($dhcpdata);
}

View File

@ -186,6 +186,7 @@ function loadInterfaceDHCPSelect() {
$('#txtsubnetmask').val(jsonData.SubnetMask);
$('#txtgateway').val(jsonData.StaticRouters);
$('#chkfallback')[0].checked = jsonData.FallbackEnabled;
$('#default-route').prop('checked', jsonData.DefaultRoute);
$('#txtrangestart').val(jsonData.RangeStart);
$('#txtrangeend').val(jsonData.RangeEnd);
$('#txtrangeleasetime').val(jsonData.leaseTime);

View File

@ -244,6 +244,7 @@ function updateDHCPConfig($iface,$status)
$cfg[] = 'profile static_'.$iface;
$cfg[] = 'fallback static_'.$iface;
}
$cfg[] = $_POST['DefaultRoute'] == '1' ? 'gateway' : 'nogateway';
$dhcp_cfg = file_get_contents(RASPI_DHCPCD_CONFIG);
if (!preg_match('/^interface\s'.$iface.'$/m', $dhcp_cfg)) {
$cfg[] = PHP_EOL;

View File

@ -362,6 +362,9 @@ msgstr "Log DHCP requests"
msgid "Log DNS queries"
msgstr "Log DNS queries"
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."
#: includes/hostapd.php
msgid "Basic"
msgstr "Basic"

View File

@ -55,6 +55,18 @@
</div>
</div>
<div class="row">
<div class="form-group col-md-6">
<div class="custom-control custom-switch">
<input class="custom-control-input" id="default-route" type="checkbox" name="DefaultRoute" value="1" aria-describedby="default-route-description">
<label class="custom-control-label" for="default-route"><?php echo _("Install a default route for this interface") ?></label>
</div>
<p class="mb-0" id="default-route-description">
<small><?php echo _("This toggles the <code>gateway</code>/<code>nogateway</code> option for this interface in the DHCPCD configuration.") ?></small>
</p>
</div>
</div>
<h5 class="mt-1">DHCP options</h5>
<div class="row">
<div class="form-group col-md-6">