mirror of
https://github.com/billz/raspap-webgui.git
synced 2023-10-10 13:37:24 +02:00
Create getDefaultNetOpts()
This commit is contained in:
parent
22b173b4c5
commit
31e3afa4a4
@ -11,6 +11,19 @@
|
|||||||
"static routers": [ "192.168.50.1" ],
|
"static routers": [ "192.168.50.1" ],
|
||||||
"static domain_name_server": [ "1.1.1.1 8.8.8.8" ],
|
"static domain_name_server": [ "1.1.1.1 8.8.8.8" ],
|
||||||
"subnetmask": [ "255.255.255.0" ]
|
"subnetmask": [ "255.255.255.0" ]
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"# RaspAP default configuration": null,
|
||||||
|
"hostname": null,
|
||||||
|
"clientid": null,
|
||||||
|
"persistent": null,
|
||||||
|
"option rapid_commit": null,
|
||||||
|
"option domain_name_servers, domain_name, domain_search, host_name": null,
|
||||||
|
"option classless_static_routes": null,
|
||||||
|
"option ntp_servers": null,
|
||||||
|
"require dhcp_server_identifier": null,
|
||||||
|
"slaac private": null,
|
||||||
|
"nohook lookup-hostname": null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dnsmasq": {
|
"dnsmasq": {
|
||||||
@ -22,3 +35,4 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,27 +29,6 @@ function cidr2mask($cidr)
|
|||||||
return join ('.', $netmask);
|
return join ('.', $netmask);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a dhcp default config header
|
|
||||||
*
|
|
||||||
* @return array $config
|
|
||||||
*/
|
|
||||||
function defaultHeader()
|
|
||||||
{
|
|
||||||
$config = [ '# RaspAP default configuration' ];
|
|
||||||
$config[] = 'hostname';
|
|
||||||
$config[] = 'clientid';
|
|
||||||
$config[] = 'persistent';
|
|
||||||
$config[] = 'option rapid_commit';
|
|
||||||
$config[] = 'option domain_name_servers, domain_name, domain_search, host_name';
|
|
||||||
$config[] = 'option classless_static_routes';
|
|
||||||
$config[] = 'option ntp_servers';
|
|
||||||
$config[] = 'require dhcp_server_identifier';
|
|
||||||
$config[] = 'slaac private';
|
|
||||||
$config[] = 'nohook lookup-hostname';
|
|
||||||
return $config;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a dhcp configuration block for the specified interface
|
* Removes a dhcp configuration block for the specified interface
|
||||||
*
|
*
|
||||||
@ -139,6 +118,22 @@ function getDefaultNetValue($svc,$iface,$key)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns default options for the specified service
|
||||||
|
*
|
||||||
|
* @param string $svc
|
||||||
|
* @return object $json
|
||||||
|
*/
|
||||||
|
function getDefaultNetOpts($svc)
|
||||||
|
{
|
||||||
|
$json = json_decode(file_get_contents(RASPI_CONFIG_NETWORK), true);
|
||||||
|
if ($json === null) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return $json[$svc]['options'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Functions to write ini files */
|
/* Functions to write ini files */
|
||||||
|
|
||||||
function write_php_ini($array, $file)
|
function write_php_ini($array, $file)
|
||||||
|
@ -296,14 +296,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 = defaultHeader();
|
$config = array_keys(getDefaultNetOpts('dhcp'));
|
||||||
$config[] = PHP_EOL.'# RaspAP br0 configuration';
|
$config[] = PHP_EOL.'# RaspAP br0 configuration';
|
||||||
$config[] = 'interface br0';
|
$config[] = 'interface br0';
|
||||||
$config[] = 'denyinterfaces eth0 wlan0';
|
$config[] = 'denyinterfaces eth0 wlan0';
|
||||||
$config[] = PHP_EOL;
|
$config[] = PHP_EOL;
|
||||||
} elseif ($wifiAPEnable == 1) {
|
} elseif ($wifiAPEnable == 1) {
|
||||||
// Enable uap0 configuration for ap-sta
|
$config = array_keys(getDefaultNetOpts('dhcp'));
|
||||||
$config = defaultHeader();
|
|
||||||
$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;
|
||||||
@ -319,7 +318,6 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
|
|||||||
$config[] = 'static domain_name_server='.$domain_name_server;
|
$config[] = 'static domain_name_server='.$domain_name_server;
|
||||||
if (! is_null($jsonData['Metric'])) { $config[] = 'metric '.$jsonData['Metric']; }
|
if (! is_null($jsonData['Metric'])) { $config[] = 'metric '.$jsonData['Metric']; }
|
||||||
}
|
}
|
||||||
|
|
||||||
$dhcp_cfg = file_get_contents(RASPI_DHCPCD_CONFIG);
|
$dhcp_cfg = file_get_contents(RASPI_DHCPCD_CONFIG);
|
||||||
if ($bridgedEnable == 1 || $wifiAPEnable == 1) {
|
if ($bridgedEnable == 1 || $wifiAPEnable == 1) {
|
||||||
$dhcp_cfg = join(PHP_EOL, $config);
|
$dhcp_cfg = join(PHP_EOL, $config);
|
||||||
|
Loading…
Reference in New Issue
Block a user