mirror of
https://github.com/billz/raspap-webgui.git
synced 2023-10-10 13:37:24 +02:00
Merge branch 'feature/dhcp-eth0' of https://github.com/billz/raspap-webgui into feature/dhcp-eth0
This commit is contained in:
commit
047e0cecc3
@ -222,6 +222,8 @@ function contentLoaded() {
|
|||||||
setupBtns();
|
setupBtns();
|
||||||
case "hostapd_conf":
|
case "hostapd_conf":
|
||||||
loadChannel();
|
loadChannel();
|
||||||
|
case "dhcpd_conf":
|
||||||
|
loadInterfaceDHCPSelect('wlan0');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -238,15 +240,10 @@ function loadWifiStations(refresh) {
|
|||||||
}
|
}
|
||||||
$(".js-reload-wifi-stations").on("click", loadWifiStations(true));
|
$(".js-reload-wifi-stations").on("click", loadWifiStations(true));
|
||||||
|
|
||||||
|
function loadInterfaceDHCPSelect(default_iface) {
|
||||||
function loadInterfaceDHCP(selected) {
|
var iface = (default_iface) ? default_iface : $('#cbxdhcpiface').val();
|
||||||
|
$('#cbxdhcpiface').val(iface);
|
||||||
}
|
$.get('ajax/networking/get_netcfg.php?iface='+iface,function(data){
|
||||||
|
|
||||||
function loadInterfaceDHCPSelect() {
|
|
||||||
var interface = $('#cbxdhcpiface').val();
|
|
||||||
console.log(interface);
|
|
||||||
$.get('ajax/networking/get_netcfg.php?iface='+interface,function(data){
|
|
||||||
jsonData = JSON.parse(data);
|
jsonData = JSON.parse(data);
|
||||||
$('#dhcp-iface')[0].checked = jsonData.DHCPEnabled;
|
$('#dhcp-iface')[0].checked = jsonData.DHCPEnabled;
|
||||||
$('#txtrangestart').val(jsonData.RangeStart);
|
$('#txtrangestart').val(jsonData.RangeStart);
|
||||||
|
@ -9,7 +9,6 @@ define('RASPI_CACHE_PATH', sys_get_temp_dir() . '/raspap');
|
|||||||
|
|
||||||
// Constants for configuration file paths.
|
// Constants for configuration file paths.
|
||||||
// These are typical for default RPi installs. Modify if needed.
|
// These are typical for default RPi installs. Modify if needed.
|
||||||
define('RASPI_DNSMASQ_CONFIG', '/etc/dnsmasq.d/090_raspap.conf');
|
|
||||||
define('RASPI_DNSMASQ_LEASES', '/var/lib/misc/dnsmasq.leases');
|
define('RASPI_DNSMASQ_LEASES', '/var/lib/misc/dnsmasq.leases');
|
||||||
define('RASPI_DNSMASQ_PREFIX', '/etc/dnsmasq.d/090_');
|
define('RASPI_DNSMASQ_PREFIX', '/etc/dnsmasq.d/090_');
|
||||||
define('RASPI_ADBLOCK_LISTPATH', '/etc/raspap/adblock/');
|
define('RASPI_ADBLOCK_LISTPATH', '/etc/raspap/adblock/');
|
||||||
|
@ -14,7 +14,6 @@ $defaults = [
|
|||||||
|
|
||||||
// Constants for configuration file paths.
|
// Constants for configuration file paths.
|
||||||
// These are typical for default RPi installs. Modify if needed.
|
// These are typical for default RPi installs. Modify if needed.
|
||||||
'RASPI_DNSMASQ_CONFIG' => '/etc/dnsmasq.d/090_raspap.conf',
|
|
||||||
'RASPI_DNSMASQ_LEASES' => '/var/lib/misc/dnsmasq.leases',
|
'RASPI_DNSMASQ_LEASES' => '/var/lib/misc/dnsmasq.leases',
|
||||||
'RASPI_DNSMASQ_PREFIX' => '/etc/dnsmasq.d/090_',
|
'RASPI_DNSMASQ_PREFIX' => '/etc/dnsmasq.d/090_',
|
||||||
'RASPI_ADBLOCK_LISTPATH' => '/etc/raspap/adblock/',
|
'RASPI_ADBLOCK_LISTPATH' => '/etc/raspap/adblock/',
|
||||||
|
@ -103,8 +103,11 @@ function SaveDHCPConfig($status)
|
|||||||
}
|
}
|
||||||
$config .= PHP_EOL;
|
$config .= PHP_EOL;
|
||||||
}
|
}
|
||||||
$config .= "log-facility=/tmp/dnsmasq.log".PHP_EOL;
|
// enable these settings on the default interface
|
||||||
$config .= "conf-dir=/etc/dnsmasq.d".PHP_EOL;
|
if ($iface == "wlan0") {
|
||||||
|
$config .= "log-facility=/tmp/dnsmasq.log".PHP_EOL;
|
||||||
|
$config .= "conf-dir=/etc/dnsmasq.d".PHP_EOL;
|
||||||
|
}
|
||||||
file_put_contents("/tmp/dnsmasqdata", $config);
|
file_put_contents("/tmp/dnsmasqdata", $config);
|
||||||
$msg = file_exists(RASPI_DNSMASQ_PREFIX.$iface.'.conf') ? 'updated' : 'added';
|
$msg = file_exists(RASPI_DNSMASQ_PREFIX.$iface.'.conf') ? 'updated' : 'added';
|
||||||
system('sudo cp /tmp/dnsmasqdata '.RASPI_DNSMASQ_PREFIX.$iface.'.conf', $return);
|
system('sudo cp /tmp/dnsmasqdata '.RASPI_DNSMASQ_PREFIX.$iface.'.conf', $return);
|
||||||
@ -152,9 +155,8 @@ function SaveDHCPConfig($status)
|
|||||||
} elseif (($_POST['dhcp-iface'] == "0") && file_exists(RASPI_DNSMASQ_PREFIX.$iface.'.conf')) {
|
} elseif (($_POST['dhcp-iface'] == "0") && file_exists(RASPI_DNSMASQ_PREFIX.$iface.'.conf')) {
|
||||||
// remove dhcp conf for selected interface
|
// remove dhcp conf for selected interface
|
||||||
$dhcp_cfg = file_get_contents(RASPI_DHCPCD_CONFIG);
|
$dhcp_cfg = file_get_contents(RASPI_DHCPCD_CONFIG);
|
||||||
// todo: improve by removing extra blank lines
|
|
||||||
$dhcp_cfg = preg_replace('/^#\sRaspAP\s'.$iface.'.*\n(.*\n){3}/m', '', $dhcp_cfg);
|
$dhcp_cfg = preg_replace('/^#\sRaspAP\s'.$iface.'.*\n(.*\n){3}/m', '', $dhcp_cfg);
|
||||||
file_put_contents("/tmp/dhcpddata", $dhcp_cfg);
|
file_put_contents("/tmp/dhcpddata", rtrim($dhcp_cfg).PHP_EOL);
|
||||||
system('sudo cp /tmp/dhcpddata '.RASPI_DHCPCD_CONFIG, $return);
|
system('sudo cp /tmp/dhcpddata '.RASPI_DHCPCD_CONFIG, $return);
|
||||||
$status->addMessage('DHCP configuration for '.$iface.' removed.', 'success');
|
$status->addMessage('DHCP configuration for '.$iface.' removed.', 'success');
|
||||||
// remove dnsmasq eth0 conf
|
// remove dnsmasq eth0 conf
|
||||||
|
@ -302,7 +302,7 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
|
|||||||
system("sudo cp /tmp/hostapddata " . RASPI_HOSTAPD_CONFIG, $return);
|
system("sudo cp /tmp/hostapddata " . RASPI_HOSTAPD_CONFIG, $return);
|
||||||
|
|
||||||
// Fetch dhcp-range, lease time from system config
|
// Fetch dhcp-range, lease time from system config
|
||||||
$dhcpConfig = parse_ini_file(RASPI_DNSMASQ_CONFIG, false, INI_SCANNER_RAW);
|
$dhcpConfig = parse_ini_file(RASPI_DNSMASQ_PREFIX.$_SESSION['ap_interface'].'conf', false, INI_SCANNER_RAW);
|
||||||
|
|
||||||
if ($wifiAPEnable == 1) {
|
if ($wifiAPEnable == 1) {
|
||||||
// Enable uap0 configuration in dnsmasq for Wifi client AP mode
|
// Enable uap0 configuration in dnsmasq for Wifi client AP mode
|
||||||
@ -330,7 +330,7 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_put_contents("/tmp/dnsmasqdata", $config);
|
file_put_contents("/tmp/dnsmasqdata", $config);
|
||||||
system('sudo cp /tmp/dnsmasqdata '.RASPI_DNSMASQ_CONFIG, $return);
|
system('sudo cp /tmp/dnsmasqdata '.RASPI_DNSMASQ_PREFIX.$_SESSION['ap_interface'].'conf', $return);
|
||||||
|
|
||||||
// Set dnsmasq values from ini, fallback to default if undefined
|
// Set dnsmasq values from ini, fallback to default if undefined
|
||||||
$intConfig = parse_ini_file(RASPI_CONFIG_NETWORKING.'/'.$_POST['interface'].'.ini', false, INI_SCANNER_RAW);
|
$intConfig = parse_ini_file(RASPI_CONFIG_NETWORKING.'/'.$_POST['interface'].'.ini', false, INI_SCANNER_RAW);
|
||||||
@ -371,7 +371,6 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
|
|||||||
$config[] = 'interface '.$_POST['interface'];
|
$config[] = 'interface '.$_POST['interface'];
|
||||||
$config[] = 'static ip_address='.$ip_address;
|
$config[] = 'static ip_address='.$ip_address;
|
||||||
$config[] = 'static domain_name_server='.$domain_name_server;
|
$config[] = 'static domain_name_server='.$domain_name_server;
|
||||||
$config[] = PHP_EOL;
|
|
||||||
|
|
||||||
// write the static IP back to the $_POST['interface'].ini file
|
// write the static IP back to the $_POST['interface'].ini file
|
||||||
$intConfig['interface'] = $_POST['interface'];
|
$intConfig['interface'] = $_POST['interface'];
|
||||||
@ -382,9 +381,10 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
|
|||||||
$intConfig['failover'] = "false";
|
$intConfig['failover'] = "false";
|
||||||
write_php_ini($intConfig, RASPI_CONFIG_NETWORKING.'/'.$_POST['interface'].".ini");
|
write_php_ini($intConfig, RASPI_CONFIG_NETWORKING.'/'.$_POST['interface'].".ini");
|
||||||
}
|
}
|
||||||
|
|
||||||
$config = join(PHP_EOL, $config);
|
$config = join(PHP_EOL, $config);
|
||||||
file_put_contents("/tmp/dhcpddata", $config);
|
$dhcp_cfg = file_get_contents(RASPI_DHCPCD_CONFIG);
|
||||||
|
$merged = preg_replace('/^#\sRaspAP\s.*?(?=\s*^\s*$)/ms', $config, $dhcp_cfg);
|
||||||
|
file_put_contents("/tmp/dhcpddata", rtrim($merged).PHP_EOL);
|
||||||
system('sudo cp /tmp/dhcpddata '.RASPI_DHCPCD_CONFIG, $return);
|
system('sudo cp /tmp/dhcpddata '.RASPI_DHCPCD_CONFIG, $return);
|
||||||
|
|
||||||
if ($return == 0) {
|
if ($return == 0) {
|
||||||
|
@ -254,6 +254,12 @@ msgstr "Client list"
|
|||||||
msgid "Interface"
|
msgid "Interface"
|
||||||
msgstr "Interface"
|
msgstr "Interface"
|
||||||
|
|
||||||
|
msgid "Enable DHCP for this interface"
|
||||||
|
msgstr "Enable DHCP for this interface"
|
||||||
|
|
||||||
|
msgid "Enable this option if you want RaspAP to assign IP addresses on the selected interface."
|
||||||
|
msgstr "Enable this option if you want RaspAP to assign IP addresses on the selected interface."
|
||||||
|
|
||||||
msgid "DNS Server"
|
msgid "DNS Server"
|
||||||
msgstr "DNS Server"
|
msgstr "DNS Server"
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
<input class="custom-control-input" id="dhcp-iface" type="checkbox" name="dhcp-iface" value="1" <?php echo $dhcp_iface_enable ? ' checked="checked"' : "" ?> aria-describedby="dhcp-iface-description">
|
<input class="custom-control-input" id="dhcp-iface" type="checkbox" name="dhcp-iface" value="1" <?php echo $dhcp_iface_enable ? ' checked="checked"' : "" ?> aria-describedby="dhcp-iface-description">
|
||||||
<label class="custom-control-label" for="dhcp-iface"><?php echo _("Enable DHCP for this interface") ?></label>
|
<label class="custom-control-label" for="dhcp-iface"><?php echo _("Enable DHCP for this interface") ?></label>
|
||||||
</div>
|
</div>
|
||||||
<p id="dhcp-iface-description">
|
<p class="mb-0" id="dhcp-iface-description">
|
||||||
<small><?php echo _("Enable this option if you want RaspAP to assign IP addresses on the selected interface.") ?></small>
|
<small><?php echo _("Enable this option if you want RaspAP to assign IP addresses on the selected interface.") ?></small>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user