mirror of
https://github.com/billz/raspap-webgui.git
synced 2023-10-10 13:37:24 +02:00
Merge pull request #582 from billz/zbchristian-wlan-switch
Enable switching of AP interface
This commit is contained in:
commit
d95113eaaf
@ -6,18 +6,20 @@ require_once '../../includes/config.php';
|
||||
require_once '../../includes/functions.php';
|
||||
|
||||
if (isset($_POST['generate'])) {
|
||||
$cnfNetworking = array_diff(scandir(RASPI_CONFIG_NETWORKING, 1), array('..','.','dhcpcd.conf'));
|
||||
$cnfNetworking = array_diff(scandir(RASPI_CONFIG_NETWORKING, 1), array('..','.','dhcpcd.conf','defaults'));
|
||||
$cnfNetworking = array_combine($cnfNetworking, $cnfNetworking);
|
||||
$strConfFile = "";
|
||||
$strConfFile = file_get_contents(RASPI_CONFIG_NETWORKING.'/defaults')."\n";
|
||||
foreach ($cnfNetworking as $index => $file) {
|
||||
if ($index != "defaults") {
|
||||
$cnfFile = parse_ini_file(RASPI_CONFIG_NETWORKING.'/'.$file, false, INI_SCANNER_RAW);
|
||||
if ($cnfFile['static'] === 'true') {
|
||||
$strConfFile .= "#Static IP configured for ".$cnfFile['interface']."\n";
|
||||
$strConfFile .= "interface ".$cnfFile['interface']."\n";
|
||||
$strConfFile .= "static ip_address=".$cnfFile['ip_address']."\n";
|
||||
$strConfFile .= "static routers=".$cnfFile['routers']."\n";
|
||||
$strConfFile .= "static domain_name_servers=".$cnfFile['domain_name_server']."\n";
|
||||
$strConfFile .= "static domain_name_servers=".$cnfFile['domain_name_server']."\n\n";
|
||||
} elseif ($cnfFile['static'] === 'false' && $cnfFile['failover'] === 'true') {
|
||||
$strConfFile .= "#Failover static IP configured for ".$cnfFile['interface']."\n";
|
||||
$strConfFile .= "profile static_".$cnfFile['interface']."\n";
|
||||
$strConfFile .= "static ip_address=".$cnfFile['ip_address']."\n";
|
||||
$strConfFile .= "static routers=".$cnfFile['routers']."\n";
|
||||
@ -27,13 +29,11 @@ if (isset($_POST['generate'])) {
|
||||
} else {
|
||||
$strConfFile .= "#DHCP configured for ".$cnfFile['interface']."\n\n";
|
||||
}
|
||||
} else {
|
||||
$strConfFile .= file_get_contents(RASPI_CONFIG_NETWORKING.'/'.$index)."\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (file_put_contents(RASPI_CONFIG_NETWORKING.'/dhcpcd.conf', $strConfFile)) {
|
||||
exec('sudo /bin/cp /etc/raspap/networking/dhcpcd.conf /etc/dhcpcd.conf');
|
||||
exec('sudo /bin/cp '.RASPI_CONFIG_NETWORKING.'/dhcpcd.conf '.RASPI_DHCPCD_CONFIG);
|
||||
$output = ['return'=>0,'output'=>'Settings successfully applied'];
|
||||
} else {
|
||||
$output = ['return'=>2,'output'=>'Unable to write to apply settings'];
|
||||
|
@ -4,7 +4,7 @@ define('RASPI_VERSION', '2.4.1');
|
||||
define('RASPI_CONFIG', '/etc/raspap');
|
||||
define('RASPI_CONFIG_NETWORKING', RASPI_CONFIG.'/networking');
|
||||
define('RASPI_ADMIN_DETAILS', RASPI_CONFIG.'/raspap.auth');
|
||||
define('RASPI_WIFI_CLIENT_INTERFACE', 'wlan0');
|
||||
define('RASPI_WIFI_AP_INTERFACE', 'wlan0');
|
||||
define('RASPI_CACHE_PATH', sys_get_temp_dir() . '/raspap');
|
||||
|
||||
// Constants for configuration file paths.
|
||||
|
@ -12,11 +12,12 @@ function DisplayWPAConfig()
|
||||
$status = new StatusMessages();
|
||||
$networks = [];
|
||||
|
||||
getWifiInterface();
|
||||
knownWifiStations($networks);
|
||||
|
||||
if (isset($_POST['connect'])) {
|
||||
$result = 0;
|
||||
exec('sudo wpa_cli -i ' . RASPI_WIFI_CLIENT_INTERFACE . ' select_network '.strval($_POST['connect']));
|
||||
exec('sudo wpa_cli -i ' . $_SESSION['wifi_client_interface'] . ' select_network '.strval($_POST['connect']));
|
||||
$status->addMessage('New network selected', 'success');
|
||||
} elseif (isset($_POST['client_settings'])) {
|
||||
$tmp_networks = $networks;
|
||||
@ -76,7 +77,7 @@ function DisplayWPAConfig()
|
||||
if ($ok) {
|
||||
system('sudo cp /tmp/wifidata ' . RASPI_WPA_SUPPLICANT_CONFIG, $returnval);
|
||||
if ($returnval == 0) {
|
||||
exec('sudo wpa_cli -i ' . RASPI_WIFI_CLIENT_INTERFACE . ' reconfigure', $reconfigure_out, $reconfigure_return);
|
||||
exec('sudo wpa_cli -i ' . $_SESSION['wifi_client_interface'] . ' reconfigure', $reconfigure_out, $reconfigure_return);
|
||||
if ($reconfigure_return == 0) {
|
||||
$status->addMessage('Wifi settings updated successfully', 'success');
|
||||
$networks = $tmp_networks;
|
||||
|
@ -1,16 +1,17 @@
|
||||
<?php
|
||||
|
||||
require_once 'config.php';
|
||||
require_once 'includes/config.php';
|
||||
require_once 'includes/wifi_functions.php';
|
||||
|
||||
/**
|
||||
* Show dashboard page.
|
||||
*/
|
||||
function DisplayDashboard(&$extraFooterScripts)
|
||||
{
|
||||
|
||||
getWifiInterface();
|
||||
$status = new StatusMessages();
|
||||
// Need this check interface name for proper shell execution.
|
||||
if (!preg_match('/^([a-zA-Z0-9]+)$/', RASPI_WIFI_CLIENT_INTERFACE)) {
|
||||
if (!preg_match('/^([a-zA-Z0-9]+)$/', $_SESSION['wifi_client_interface'])) {
|
||||
$status->addMessage(_('Interface name invalid.'), 'danger');
|
||||
$status->showMessages();
|
||||
return;
|
||||
@ -21,8 +22,7 @@ function DisplayDashboard(&$extraFooterScripts)
|
||||
$status->showMessages();
|
||||
return;
|
||||
}
|
||||
|
||||
exec('ip a show '.RASPI_WIFI_CLIENT_INTERFACE, $stdoutIp);
|
||||
exec('ip a show '.$_SESSION['ap_interface'], $stdoutIp);
|
||||
$stdoutIpAllLinesGlued = implode(" ", $stdoutIp);
|
||||
$stdoutIpWRepeatedSpaces = preg_replace('/\s\s+/', ' ', $stdoutIpAllLinesGlued);
|
||||
|
||||
@ -61,26 +61,26 @@ function DisplayDashboard(&$extraFooterScripts)
|
||||
|
||||
// Because of table layout used in the ip output we get the interface statistics directly from
|
||||
// the system. One advantage of this is that it could work when interface is disable.
|
||||
exec('cat /sys/class/net/'.RASPI_WIFI_CLIENT_INTERFACE.'/statistics/rx_packets ', $stdoutCatRxPackets);
|
||||
exec('cat /sys/class/net/'.$_SESSION['ap_interface'].'/statistics/rx_packets ', $stdoutCatRxPackets);
|
||||
$strRxPackets = _('No data');
|
||||
if (ctype_digit($stdoutCatRxPackets[0])) {
|
||||
$strRxPackets = $stdoutCatRxPackets[0];
|
||||
}
|
||||
|
||||
exec('cat /sys/class/net/'.RASPI_WIFI_CLIENT_INTERFACE.'/statistics/tx_packets ', $stdoutCatTxPackets);
|
||||
exec('cat /sys/class/net/'.$_SESSION['ap_interface'].'/statistics/tx_packets ', $stdoutCatTxPackets);
|
||||
$strTxPackets = _('No data');
|
||||
if (ctype_digit($stdoutCatTxPackets[0])) {
|
||||
$strTxPackets = $stdoutCatTxPackets[0];
|
||||
}
|
||||
|
||||
exec('cat /sys/class/net/'.RASPI_WIFI_CLIENT_INTERFACE.'/statistics/rx_bytes ', $stdoutCatRxBytes);
|
||||
exec('cat /sys/class/net/'.$_SESSION['ap_interface'].'/statistics/rx_bytes ', $stdoutCatRxBytes);
|
||||
$strRxBytes = _('No data');
|
||||
if (ctype_digit($stdoutCatRxBytes[0])) {
|
||||
$strRxBytes = $stdoutCatRxBytes[0];
|
||||
$strRxBytes .= getHumanReadableDatasize($strRxBytes);
|
||||
}
|
||||
|
||||
exec('cat /sys/class/net/'.RASPI_WIFI_CLIENT_INTERFACE.'/statistics/tx_bytes ', $stdoutCatTxBytes);
|
||||
exec('cat /sys/class/net/'.$_SESSION['ap_interface'].'/statistics/tx_bytes ', $stdoutCatTxBytes);
|
||||
$strTxBytes = _('No data');
|
||||
if (ctype_digit($stdoutCatTxBytes[0])) {
|
||||
$strTxBytes = $stdoutCatTxBytes[0];
|
||||
@ -89,7 +89,7 @@ function DisplayDashboard(&$extraFooterScripts)
|
||||
|
||||
define('SSIDMAXLEN', 32);
|
||||
// Warning iw comes with: "Do NOT screenscrape this tool, we don't consider its output stable."
|
||||
exec('iw dev '.RASPI_WIFI_CLIENT_INTERFACE.' link ', $stdoutIw);
|
||||
exec('iw dev ' .$_SESSION['wifi_client_interface']. ' link ', $stdoutIw);
|
||||
$stdoutIwAllLinesGlued = implode(' ', $stdoutIw);
|
||||
$stdoutIwWRepSpaces = preg_replace('/\s\s+/', ' ', $stdoutIwAllLinesGlued);
|
||||
|
||||
@ -121,7 +121,7 @@ function DisplayDashboard(&$extraFooterScripts)
|
||||
$bitrate = empty($bitrate) ? "-" : $bitrate;
|
||||
|
||||
// txpower is now displayed on iw dev(..) info command, not on link command.
|
||||
exec('iw dev '.RASPI_WIFI_CLIENT_INTERFACE.' info ', $stdoutIwInfo);
|
||||
exec('iw dev '.$_SESSION['wifi_client_interface'].' info ', $stdoutIwInfo);
|
||||
$stdoutIwInfoAllLinesGlued = implode(' ', $stdoutIwInfo);
|
||||
$stdoutIpInfoWRepSpaces = preg_replace('/\s\s+/', ' ', $stdoutIwInfoAllLinesGlued);
|
||||
|
||||
@ -147,13 +147,12 @@ function DisplayDashboard(&$extraFooterScripts)
|
||||
$classMsgDevicestatus = 'success';
|
||||
}
|
||||
|
||||
|
||||
if (!RASPI_MONITOR_ENABLED) {
|
||||
if (isset($_POST['ifdown_wlan0'])) {
|
||||
// Pressed stop button
|
||||
if ($interfaceState === 'UP') {
|
||||
$status->addMessage(sprintf(_('Interface is going %s.'), _('down')), 'warning');
|
||||
exec('sudo ip link set '.RASPI_WIFI_CLIENT_INTERFACE.' down');
|
||||
exec('sudo ip link set '.$_SESSION['wifi_client_interface'].' down');
|
||||
$wlan0up = false;
|
||||
$status->addMessage(sprintf(_('Interface is now %s.'), _('down')), 'success');
|
||||
} elseif ($interfaceState === 'unknown') {
|
||||
@ -165,8 +164,8 @@ function DisplayDashboard(&$extraFooterScripts)
|
||||
// Pressed start button
|
||||
if ($interfaceState === 'DOWN') {
|
||||
$status->addMessage(sprintf(_('Interface is going %s.'), _('up')), 'warning');
|
||||
exec('sudo ip link set ' . RASPI_WIFI_CLIENT_INTERFACE . ' up');
|
||||
exec('sudo ip -s a f label ' . RASPI_WIFI_CLIENT_INTERFACE);
|
||||
exec('sudo ip link set ' .$_SESSION['wifi_client_interface']. ' up');
|
||||
exec('sudo ip -s a f label ' . $_SESSION['wifi_client_interface']);
|
||||
$wlan0up = true;
|
||||
$status->addMessage(sprintf(_('Interface is now %s.'), _('up')), 'success');
|
||||
} elseif ($interfaceState === 'unknown') {
|
||||
|
@ -8,7 +8,7 @@ $defaults = [
|
||||
'RASPI_VERSION' => '2.4.1',
|
||||
'RASPI_CONFIG_NETWORKING' => RASPI_CONFIG.'/networking',
|
||||
'RASPI_ADMIN_DETAILS' => RASPI_CONFIG.'/raspap.auth',
|
||||
'RASPI_WIFI_CLIENT_INTERFACE' => 'wlan0',
|
||||
'RASPI_WIFI_AP_INTERFACE' => 'wlan0',
|
||||
'RASPI_CACHE_PATH' => sys_get_temp_dir() . '/raspap',
|
||||
|
||||
// Constants for configuration file paths.
|
||||
|
@ -1,8 +1,11 @@
|
||||
<?php
|
||||
|
||||
require_once 'includes/status_messages.php';
|
||||
require_once 'status_messages.php';
|
||||
require_once 'app/lib/system.php';
|
||||
require_once 'config.php';
|
||||
require_once 'includes/wifi_functions.php';
|
||||
require_once 'includes/config.php';
|
||||
|
||||
getWifiInterface();
|
||||
|
||||
/**
|
||||
*
|
||||
@ -56,7 +59,7 @@ function DisplayHostAPDConfig()
|
||||
}
|
||||
|
||||
exec('cat '. RASPI_HOSTAPD_CONFIG, $hostapdconfig);
|
||||
exec('iwgetid '. RASPI_WIFI_CLIENT_INTERFACE. ' -r', $wifiNetworkID);
|
||||
exec('iwgetid '. $_POST['interface']. ' -r', $wifiNetworkID);
|
||||
if (!empty($wifiNetworkID[0])) {
|
||||
$managedModeEnabled = true;
|
||||
}
|
||||
@ -146,27 +149,29 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
|
||||
if ($arrHostapdConf['LogEnable'] == 0) {
|
||||
if (isset($_POST['logEnable'])) {
|
||||
$logEnable = 1;
|
||||
exec('sudo /etc/raspap/hostapd/enablelog.sh');
|
||||
exec('sudo '.RASPI_CONFIG.'/hostapd/enablelog.sh');
|
||||
} else {
|
||||
exec('sudo /etc/raspap/hostapd/disablelog.sh');
|
||||
exec('sudo '.RASPI_CONFIG.'/hostapd/disablelog.sh');
|
||||
}
|
||||
} else {
|
||||
if (isset($_POST['logEnable'])) {
|
||||
$logEnable = 1;
|
||||
exec('sudo /etc/raspap/hostapd/enablelog.sh');
|
||||
exec('sudo '.RASPI_CONFIG.'/hostapd/enablelog.sh');
|
||||
} else {
|
||||
exec('sudo /etc/raspap/hostapd/disablelog.sh');
|
||||
exec('sudo '.RASPI_CONFIG.'/hostapd/disablelog.sh');
|
||||
}
|
||||
}
|
||||
|
||||
$cfg = [];
|
||||
$cfg['WifiInterface'] = $_POST['interface'];
|
||||
$cfg['LogEnable'] = $logEnable;
|
||||
// Save previous Client mode status when Bridged
|
||||
$cfg['WifiAPEnable'] = ($bridgedEnable == 1 ?
|
||||
$arrHostapdConf['WifiAPEnable'] : $wifiAPEnable);
|
||||
$cfg['BridgedEnable'] = $bridgedEnable;
|
||||
$cfg['WifiManaged'] = RASPI_WIFI_CLIENT_INTERFACE;
|
||||
write_php_ini($cfg, '/etc/raspap/hostapd.ini');
|
||||
$cfg['WifiManaged'] = $_POST['interface'];
|
||||
write_php_ini($cfg, RASPI_CONFIG.'/hostapd.ini');
|
||||
$_SESSION['ap_interface'] = $_POST['interface'];
|
||||
|
||||
// Verify input
|
||||
if (empty($_POST['ssid']) || strlen($_POST['ssid']) > 32) {
|
||||
@ -255,7 +260,7 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
|
||||
if ($wifiAPEnable == 1) {
|
||||
$config.= 'interface=uap0'.PHP_EOL;
|
||||
} elseif ($bridgedEnable == 1) {
|
||||
$config.='interface='.RASPI_WIFI_CLIENT_INTERFACE.PHP_EOL;
|
||||
$config.='interface='.$_POST['interface'].PHP_EOL;
|
||||
$config.= 'bridge=br0'.PHP_EOL;
|
||||
} else {
|
||||
$config.= 'interface='.$_POST['interface'].PHP_EOL;
|
||||
@ -303,11 +308,12 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
|
||||
system('sudo cp /tmp/dnsmasqdata '.RASPI_DNSMASQ_CONFIG, $return);
|
||||
|
||||
// Set dnsmasq values from ini, fallback to default if undefined
|
||||
$intConfig = parse_ini_file(RASPI_CONFIG_NETWORKING.'/'.RASPI_WIFI_CLIENT_INTERFACE.'.ini', false, INI_SCANNER_RAW);
|
||||
$intConfig = parse_ini_file(RASPI_CONFIG_NETWORKING.'/'.$_POST['interface'].'.ini', false, INI_SCANNER_RAW);
|
||||
$domain_name_server = ($intConfig['domain_name_server'] =='') ? '1.1.1.1 8.8.8.8' : $intConfig['domain_name_server'];
|
||||
$routers = ($intConfig['routers'] == '') ? '10.3.141.1' : $intConfig['routers'];
|
||||
|
||||
$config = [ '# RaspAP wlan0 configuration' ];
|
||||
// write options to dhcpcd.conf
|
||||
$config = [ '# RaspAP '.$_POST['interface'].' configuration' ];
|
||||
$config[] = 'hostname';
|
||||
$config[] = 'clientid';
|
||||
$config[] = 'persistent';
|
||||
@ -330,12 +336,26 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status)
|
||||
$config[] = 'static ip_address='.$ip_address;
|
||||
$config[] = 'nohook wpa_supplicant';
|
||||
} else {
|
||||
// Default config
|
||||
$ip_address = ($intConfig['ip_address'] == '') ? '10.3.141.1/24' : $intConfig['ip_address'];
|
||||
$config[] = 'interface '.RASPI_WIFI_CLIENT_INTERFACE;
|
||||
// Default config
|
||||
$ip_address = "10.3.141.1/24"; // fallback IP
|
||||
// default IP of the AP xxx.xxx.xxx.1/24 of the selected dhcp range
|
||||
$def_ip = array();
|
||||
if (preg_match("/^([0-9]{1,3}\.){3}/",$dhcp_range,$def_ip) ) $ip_address = $def_ip[0]."1/24";
|
||||
// use static IP assigned to interface only, if consistent with the selected dhcp range
|
||||
if (preg_match("/^([0-9]{1,3}\.){3}/",$intConfig['ip_address'],$int_ip) && $def_ip[0] === $int_ip[0]) $ip_address = $intConfig['ip_address'];
|
||||
$config[] = 'interface '.$_POST['interface'];
|
||||
$config[] = 'static ip_address='.$ip_address;
|
||||
$config[] = 'static routers='.$routers;
|
||||
$config[] = 'static domain_name_server='.$domain_name_server;
|
||||
$config[] = PHP_EOL;
|
||||
|
||||
// write the static IP back to the $_POST['interface'].ini file
|
||||
$intConfig['interface'] = $_POST['interface'];
|
||||
$intConfig['ip_address'] = $ip_address;
|
||||
$intConfig['domain_name_server'] = $domain_name_server;
|
||||
$intConfig['routers'] = $routers;
|
||||
$intConfig['static'] = "true";
|
||||
$intConfig['failover'] = "false";
|
||||
write_php_ini($intConfig, RASPI_CONFIG_NETWORKING.'/'.$_POST['interface'].".ini");
|
||||
}
|
||||
|
||||
$config = join(PHP_EOL, $config);
|
||||
|
@ -1,7 +1,10 @@
|
||||
<?php
|
||||
|
||||
require_once 'includes/status_messages.php';
|
||||
require_once 'config.php';
|
||||
require_once 'includes/config.php';
|
||||
require_once 'includes/wifi_functions.php';
|
||||
|
||||
getWifiInterface();
|
||||
|
||||
/**
|
||||
* Manage OpenVPN configuration
|
||||
@ -146,7 +149,7 @@ function SaveOpenVPNConfig($status, $file, $authUser, $authPassword)
|
||||
}
|
||||
|
||||
// Set iptables rules and, optionally, auth-user-pass
|
||||
exec("sudo /etc/raspap/openvpn/configauth.sh $tmp_ovpnclient $auth_flag " .RASPI_WIFI_CLIENT_INTERFACE, $return);
|
||||
exec("sudo /etc/raspap/openvpn/configauth.sh $tmp_ovpnclient $auth_flag " .$_SESSION['ap_interface'], $return);
|
||||
foreach ($return as $line) {
|
||||
$status->addMessage($line, 'info');
|
||||
}
|
||||
|
@ -52,12 +52,11 @@ function nearbyWifiStations(&$networks, $cached = true)
|
||||
}
|
||||
|
||||
$scan_results = cache(
|
||||
$cacheKey,
|
||||
function () {
|
||||
exec('sudo wpa_cli -i ' . RASPI_WIFI_CLIENT_INTERFACE . ' scan');
|
||||
$cacheKey, function () {
|
||||
exec('sudo wpa_cli -i ' .$_SESSION['wifi_client_interface']. ' scan');
|
||||
sleep(3);
|
||||
|
||||
exec('sudo wpa_cli -i ' . RASPI_WIFI_CLIENT_INTERFACE . ' scan_results', $stdout);
|
||||
exec('sudo wpa_cli -i ' .$_SESSION['wifi_client_interface']. ' scan_results', $stdout);
|
||||
array_shift($stdout);
|
||||
|
||||
return implode("\n", $stdout);
|
||||
@ -77,7 +76,7 @@ function nearbyWifiStations(&$networks, $cached = true)
|
||||
|
||||
$ssid = trim($arrNetwork[4]);
|
||||
// filter SSID string: anything invisible in 7bit ASCII or quotes -> ignore network
|
||||
if (preg_match('[\x00-\x1f\x7f-\xff\'\`\´\"]', $ssid)) {
|
||||
if (preg_match('[\x00-\x1f\x7f-\xff\'\`\´\"]', $ssid)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -108,7 +107,7 @@ function nearbyWifiStations(&$networks, $cached = true)
|
||||
|
||||
function connectedWifiStations(&$networks)
|
||||
{
|
||||
exec('iwconfig ' . RASPI_WIFI_CLIENT_INTERFACE, $iwconfig_return);
|
||||
exec('iwconfig ' .$_SESSION['wifi_client_interface'], $iwconfig_return);
|
||||
foreach ($iwconfig_return as $line) {
|
||||
if (preg_match('/ESSID:\"([^"]+)\"/i', $line, $iwconfig_ssid)) {
|
||||
$networks[$iwconfig_ssid[1]]['connected'] = true;
|
||||
@ -133,3 +132,20 @@ function sortNetworksByRSSI(&$networks)
|
||||
$networks[$SSID]['RSSI'] = $RSSI;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Determines the configured wireless AP interface
|
||||
*
|
||||
* If not saved in /etc/raspap/hostapd.ini, check for a second
|
||||
* wireless interface with iw dev. Fallback to the constant
|
||||
* value defined in config.php
|
||||
*/
|
||||
function getWifiInterface()
|
||||
{
|
||||
$arrHostapdConf = parse_ini_file(RASPI_CONFIG.'/hostapd.ini');
|
||||
$iface = $_SESSION['ap_interface'] = isset($arrHostapdConf['WifiInterface']) ? $arrHostapdConf['WifiInterface'] : RASPI_WIFI_AP_INTERFACE;
|
||||
// check for 2nd wifi interface -> wifi client on different interface
|
||||
exec("iw dev | awk '$1==\"Interface\" && $2!=\"$iface\" {print $2}'",$iface2);
|
||||
$_SESSION['wifi_client_interface'] = empty($iface2) ? $iface : trim($iface2[0]);
|
||||
}
|
||||
|
||||
|
@ -1,17 +1,18 @@
|
||||
<?php
|
||||
$arrHostapdConf = parse_ini_file('/etc/raspap/hostapd.ini');
|
||||
$arrHostapdConf = parse_ini_file(RASPI_CONFIG.'/hostapd.ini');
|
||||
if ($arrHostapdConf['WifiAPEnable'] == 1) {
|
||||
$client_iface = 'uap0';
|
||||
$client_interface = 'uap0';
|
||||
} else {
|
||||
$client_iface = RASPI_WIFI_CLIENT_INTERFACE;
|
||||
$client_interface = $_SESSION['wifi_client_interface'];
|
||||
}
|
||||
$ap_iface = $_SESSION['ap_interface'];
|
||||
$MACPattern = '"([[:xdigit:]]{2}:){5}[[:xdigit:]]{2}"';
|
||||
if ($arrHostapdConf['BridgedEnable'] == 1) {
|
||||
$moreLink = "index.php?page=hostapd_conf";
|
||||
exec('iw dev '.$client_iface.' station dump | grep -oE '.$MACPattern, $clients);
|
||||
$moreLink = "index.php?page=hostapd_conf";
|
||||
exec('iw dev '.$ap_iface.' station dump | grep -oE '.$MACPattern, $clients);
|
||||
} else {
|
||||
$moreLink = "index.php?page=dhcpd_conf";
|
||||
exec('cat '.RASPI_DNSMASQ_LEASES.'| grep -E $(iw dev '.$client_iface.' station dump | grep -oE '.$MACPattern.' | paste -sd "|")', $clients);
|
||||
$moreLink = "index.php?page=dhcpd_conf";
|
||||
exec('cat '.RASPI_DNSMASQ_LEASES.'| grep -E $(iw dev '.$ap_iface.' station dump | grep -oE '.$MACPattern.' | paste -sd "|")', $clients);
|
||||
}
|
||||
$ifaceStatus = $wlan0up ? "up" : "down";
|
||||
?>
|
||||
@ -26,7 +27,7 @@ $ifaceStatus = $wlan0up ? "up" : "down";
|
||||
<div class="col">
|
||||
<button class="btn btn-light btn-icon-split btn-sm service-status float-right">
|
||||
<span class="icon"><i class="fas fa-circle service-status-<?php echo $ifaceStatus ?>"></i></span>
|
||||
<span class="text service-status"><?php echo strtolower($client_iface) .' '. _($ifaceStatus) ?></span>
|
||||
<span class="text service-status"><?php echo strtolower($ap_iface) .' '. _($ifaceStatus) ?></span>
|
||||
</button>
|
||||
</div>
|
||||
</div><!-- /.row -->
|
||||
@ -39,7 +40,7 @@ $ifaceStatus = $wlan0up ? "up" : "down";
|
||||
<div class="card mb-3">
|
||||
<div class="card-body">
|
||||
<h4><?php echo _("Hourly traffic amount"); ?></h4>
|
||||
<div id="divInterface" class="d-none"><?php echo RASPI_WIFI_CLIENT_INTERFACE; ?></div>
|
||||
<div id="divInterface" class="d-none"><?php echo $_SESSION['ap_interface']; ?></div>
|
||||
<div class="col-md-12">
|
||||
<canvas id="divDBChartBandwidthhourly"></canvas>
|
||||
</div>
|
||||
@ -126,9 +127,9 @@ $ifaceStatus = $wlan0up ? "up" : "down";
|
||||
<?php echo CSRFTokenFieldTag() ?>
|
||||
<?php if (!RASPI_MONITOR_ENABLED) : ?>
|
||||
<?php if (!$wlan0up) : ?>
|
||||
<input type="submit" class="btn btn-success" value="<?php echo _("Start").' '.RASPI_WIFI_CLIENT_INTERFACE ?>" name="ifup_wlan0" />
|
||||
<input type="submit" class="btn btn-success" value="<?php echo _("Start").' '.$client_interface ?>" name="ifup_wlan0" />
|
||||
<?php else : ?>
|
||||
<input type="submit" class="btn btn-warning" value="<?php echo _("Stop").' '.RASPI_WIFI_CLIENT_INTERFACE ?>" name="ifdown_wlan0" />
|
||||
<input type="submit" class="btn btn-warning" value="<?php echo _("Stop").' '.$client_interface ?>" name="ifdown_wlan0" />
|
||||
<?php endif ?>
|
||||
<?php endif ?>
|
||||
<a href="?page=<?php echo $_GET['page'] ?>" class="btn btn-outline btn-primary"><i class="fas fa-sync-alt"></i> <?php echo _("Refresh") ?></a>
|
||||
|
Loading…
Reference in New Issue
Block a user