mirror of
https://github.com/RaspAP/raspap-webgui.git
synced 2024-11-22 07:30:23 +00:00
add 'default route' toggle to network interface configuration ui
This commit is contained in:
parent
8f0ae3b36a
commit
6196bcd311
4 changed files with 16 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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">
|
||||
|
|
Loading…
Reference in a new issue