mirror of
https://github.com/RaspAP/raspap-webgui.git
synced 2024-11-21 23:20:22 +00:00
Merge pull request #1452 from RaspAP/config/default-wlan1
Define/set default subnet for wlan1
This commit is contained in:
commit
fc12951e88
3 changed files with 47 additions and 13 deletions
|
@ -6,6 +6,12 @@
|
|||
"static domain_name_server": [ "1.1.1.1 8.8.8.8" ],
|
||||
"subnetmask": [ "255.255.255.0" ]
|
||||
},
|
||||
"wlan1": {
|
||||
"static ip_address": [ "10.9.141.1/24" ],
|
||||
"static routers": [ "10.9.141.1" ],
|
||||
"static domain_name_server": [ "1.1.1.1 8.8.8.8" ],
|
||||
"subnetmask": [ "255.255.255.0" ]
|
||||
},
|
||||
"uap0": {
|
||||
"static ip_address": [ "192.168.50.1/24" ],
|
||||
"static routers": [ "192.168.50.1" ],
|
||||
|
@ -30,6 +36,9 @@
|
|||
"wlan0": {
|
||||
"dhcp-range": [ "10.3.141.50,10.3.141.254,255.255.255.0,12h" ]
|
||||
},
|
||||
"wlan1": {
|
||||
"dhcp-range": [ "10.9.141.50,10.9.141.254,255.255.255.0,12h" ]
|
||||
},
|
||||
"uap0": {
|
||||
"dhcp-range": [ "192.168.50.50,192.168.50.150,12h" ]
|
||||
}
|
||||
|
|
|
@ -344,7 +344,7 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $reg_dom
|
|||
file_put_contents("/tmp/dnsmasqdata", $config);
|
||||
system('sudo cp /tmp/dnsmasqdata '.RASPI_DNSMASQ_PREFIX.$ap_iface.'.conf', $return);
|
||||
} elseif ($bridgedEnable !==1) {
|
||||
$dhcp_range = ($syscfg['dhcp-range'] =='') ? getDefaultNetValue('dnsmasq','wlan0','dhcp-range') : $syscfg['dhcp-range'];
|
||||
$dhcp_range = ($syscfg['dhcp-range'] =='') ? getDefaultNetValue('dnsmasq',$ap_iface,'dhcp-range') : $syscfg['dhcp-range'];
|
||||
$config = [ '# RaspAP '.$_POST['interface'].' configuration' ];
|
||||
$config[] = 'interface='.$_POST['interface'];
|
||||
$config[] = 'domain-needed';
|
||||
|
@ -361,10 +361,12 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $reg_dom
|
|||
// Set dhcp values from system config, fallback to default if undefined
|
||||
$jsonData = json_decode(getNetConfig($ap_iface), true);
|
||||
$ip_address = ($jsonData['StaticIP'] == '') ? getDefaultNetValue('dhcp',$ap_iface,'static ip_address') : $jsonData['StaticIP'];
|
||||
$domain_name_server = ($jsonData['StaticDNS'] =='') ? getDefaultNetValue('dhcp','wlan0','static domain_name_server') : $jsonData['StaticDNS'];
|
||||
$domain_name_server = ($jsonData['StaticDNS'] =='') ? getDefaultNetValue('dhcp',$ap_iface,'static domain_name_server') : $jsonData['StaticDNS'];
|
||||
$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'];
|
||||
$ip_address.= (!preg_match('/.*\/\d+/', $ip_address)) ? '/'.mask2cidr($netmask) : null;
|
||||
if (isset($ip_address) && !preg_match('/.*\/\d+/', $ip_address)) {
|
||||
$ip_address.='/'.mask2cidr($netmask);
|
||||
}
|
||||
|
||||
if ($bridgedEnable == 1) {
|
||||
$config = array_keys(getDefaultNetOpts('dhcp','options'));
|
||||
|
@ -389,30 +391,38 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $reg_dom
|
|||
if (! is_null($jsonData['Metric'])) { $config[] = 'metric '.$jsonData['Metric']; }
|
||||
}
|
||||
$dhcp_cfg = file_get_contents(RASPI_DHCPCD_CONFIG);
|
||||
if ($bridgedEnable == 1 || $wifiAPEnable == 1) {
|
||||
|
||||
if (preg_match('/wlan[2-9]\d*|wlan[1-9]\d+/', $ap_iface)) {
|
||||
$skip_dhcp = true;;
|
||||
} elseif ($bridgedEnable == 1 || $wifiAPEnable == 1) {
|
||||
$dhcp_cfg = join(PHP_EOL, $config);
|
||||
$status->addMessage('DHCP configuration for '.$ap_iface.' enabled.', 'success');
|
||||
$status->addMessage(sprintf(_('DHCP configuration for %s enabled.'), $ap_iface), 'success');
|
||||
} elseif (!preg_match('/^interface\s'.$ap_iface.'$/m', $dhcp_cfg)) {
|
||||
$config[] = PHP_EOL;
|
||||
$config= join(PHP_EOL, $config);
|
||||
$dhcp_cfg = removeDHCPIface($dhcp_cfg,'br0');
|
||||
$dhcp_cfg = removeDHCPIface($dhcp_cfg,'uap0');
|
||||
$dhcp_cfg .= $config;
|
||||
$status->addMessage('DHCP configuration for '.$ap_iface.' added.', 'success');
|
||||
$status->addMessage(sprintf(_('DHCP configuration for %s added.'), $ap_iface), 'success');
|
||||
} else {
|
||||
$config = join(PHP_EOL, $config);
|
||||
$dhcp_cfg = removeDHCPIface($dhcp_cfg,'br0');
|
||||
$dhcp_cfg = removeDHCPIface($dhcp_cfg,'uap0');
|
||||
$dhcp_cfg = preg_replace('/^#\sRaspAP\s'.$ap_iface.'\s.*?(?=\s*^\s*$)/ms', $config, $dhcp_cfg, 1);
|
||||
$status->addMessage('DHCP configuration for '.$ap_iface.' updated.', 'success');
|
||||
$status->addMessage(sprintf(_('DHCP configuration for %s updated.'), $ap_iface), 'success');
|
||||
}
|
||||
file_put_contents("/tmp/dhcpddata", $dhcp_cfg);
|
||||
system('sudo cp /tmp/dhcpddata '.RASPI_DHCPCD_CONFIG, $return);
|
||||
|
||||
if ($return == 0) {
|
||||
$status->addMessage('Wifi Hotspot settings saved', 'success');
|
||||
if (!$skip_dhcp) {
|
||||
file_put_contents("/tmp/dhcpddata", $dhcp_cfg);
|
||||
system('sudo cp /tmp/dhcpddata '.RASPI_DHCPCD_CONFIG, $return);
|
||||
if ($return == 0) {
|
||||
$status->addMessage('Wifi Hotspot settings saved', 'success');
|
||||
} else {
|
||||
$status->addMessage('Unable to save wifi hotspot settings', 'danger');
|
||||
}
|
||||
} else {
|
||||
$status->addMessage('Unable to save wifi hotspot settings', 'danger');
|
||||
$status->addMessage(sprintf(_('Interface %s has no default settings.'), $ap_iface), 'warning');
|
||||
$status->addMessage(('Configure settings in <strong>DHCP Server</strong> before starting AP.'), 'warning');
|
||||
$status->addMessage('Wifi Hotspot settings saved', 'success');
|
||||
}
|
||||
} else {
|
||||
$status->addMessage('Unable to save wifi hotspot settings', 'danger');
|
||||
|
|
|
@ -531,6 +531,21 @@ msgstr "Unknown interface"
|
|||
msgid "Country code must be blank or two characters"
|
||||
msgstr "Country code must be blank or two characters"
|
||||
|
||||
msgid "DHCP configuration for %s enabled."
|
||||
msgstr "DHCP configuration for %s enabled."
|
||||
|
||||
msgid "DHCP configuration for %s added."
|
||||
msgstr "DHCP configuration for %s added."
|
||||
|
||||
msgid "DHCP configuration for %s updated."
|
||||
msgstr "DHCP configuration for %s updated."
|
||||
|
||||
msgid "Interface %s has no default settings."
|
||||
msgstr "Interface %s has no default settings."
|
||||
|
||||
msgid "Configure settings in <strong>DHCP Server</strong> before starting AP."
|
||||
msgstr "Configure settings in <strong>DHCP Server</strong> before starting AP."
|
||||
|
||||
msgid "Wifi Hotspot settings saved"
|
||||
msgstr "Wifi Hotspot settings saved"
|
||||
|
||||
|
|
Loading…
Reference in a new issue