Bugfix: rewrite selected wlan dhcpcd cfg

This commit is contained in:
Bill Zimmerman 2022-01-04 19:02:12 +01:00 committed by GitHub
parent b1da175ea7
commit 793bbfac53
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -320,7 +320,7 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
// Set dhcp values from system config, fallback to default if undefined // Set dhcp values from system config, fallback to default if undefined
$jsonData = json_decode(getNetConfig($ap_iface), true); $jsonData = json_decode(getNetConfig($ap_iface), true);
$ip_address = ($jsonData['StaticIP'] == '') ? getDefaultNetValue('dhcp',$ap_iface,'static ip_address') : $jsonData['StaticIP']; $ip_address = ($jsonData['StaticIP'] == '') ? getDefaultNetValue('dhcp',$ap_iface,'static ip_address') : $jsonData['StaticIP'];
$domain_name_server = ($jsonData['StaticDNS'] =='') ? getDefaultNetValue('dhcp',$ap_iface,'static domain_name_server') : $jsonData['StaticDNS']; $domain_name_server = ($jsonData['StaticDNS'] =='') ? getDefaultNetValue('dhcp','wlan0','static domain_name_server') : $jsonData['StaticDNS'];
$routers = ($jsonData['StaticRouters'] == '') ? getDefaultNetValue('dhcp',$ap_iface,'static routers') : $jsonData['StaticRouters']; $routers = ($jsonData['StaticRouters'] == '') ? getDefaultNetValue('dhcp',$ap_iface,'static routers') : $jsonData['StaticRouters'];
$netmask = ($jsonData['SubnetMask'] == '' || $jsonData['SubnetMask'] == '0.0.0.0') ? getDefaultNetValue('dhcp',$ap_iface,'subnetmask') : $jsonData['SubnetMask']; $netmask = ($jsonData['SubnetMask'] == '' || $jsonData['SubnetMask'] == '0.0.0.0') ? getDefaultNetValue('dhcp',$ap_iface,'subnetmask') : $jsonData['SubnetMask'];
$ip_address.= (!preg_match('/.*\/\d+/', $ip_address)) ? '/'.mask2cidr($netmask) : null; $ip_address.= (!preg_match('/.*\/\d+/', $ip_address)) ? '/'.mask2cidr($netmask) : null;
@ -339,10 +339,9 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
$config[] = 'nohook wpa_supplicant'; $config[] = 'nohook wpa_supplicant';
$config[] = PHP_EOL; $config[] = PHP_EOL;
} else { } else {
// Default wlan0 config
$def_ip = array(); $def_ip = array();
$config = [ '# RaspAP wlan0 configuration' ]; $config = [ '# RaspAP '.$ap_iface.' configuration' ];
$config[] = 'interface wlan0'; $config[] = 'interface '.$ap_iface;
$config[] = 'static ip_address='.$ip_address; $config[] = 'static ip_address='.$ip_address;
$config[] = 'static routers='.$routers; $config[] = 'static routers='.$routers;
$config[] = 'static domain_name_server='.$domain_name_server; $config[] = 'static domain_name_server='.$domain_name_server;