diff --git a/BACKERS.md b/BACKERS.md index 9104fb2b..ab6e9417 100644 --- a/BACKERS.md +++ b/BACKERS.md @@ -31,5 +31,5 @@ Erin C - "Just got Raspap up and running, looks very cool, thanks!" -$20 CAD Ralf J - "Thanks for RaspAP including OpenVPN. It was a big help for me." -€15 Felipe C - "Thanks for the good work on RaspAP!" -$6 Webagentur S - "Like what you and RaspAP are doing." -€20 -Matthew B - "Great project, easy to set up." -£15 +Matthew B - "Great project, easy to set up." -£15 Mikko M - "Thanks for the great RaspAP." -€10 diff --git a/README.md b/README.md index 2ab02526..de95ee2d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ ![](https://i.imgur.com/xeKD93p.png) -[![Release 2.5.2](https://img.shields.io/badge/Release-2.5.2-green.svg)](https://github.com/billz/raspap-webgui/releases) [![Awesome](https://awesome.re/badge.svg)](https://github.com/thibmaek/awesome-raspberry-pi) [![Financial Contributors on Open Collective](https://opencollective.com/raspap/all/badge.svg?label=financial+contributors)](https://opencollective.com/raspap) ![https://travis-ci.com/billz/raspap-webgui/](https://img.shields.io/travis/com/billz/raspap-webgui/master) [![Crowdin](https://badges.crowdin.net/raspap/localized.svg)](https://crowdin.com/project/raspap) [![Twitter URL](https://img.shields.io/twitter/url?label=%40RaspAP&logoColor=%23d8224c&url=https%3A%2F%2Ftwitter.com%2Frasp_ap)](https://twitter.com/rasp_ap) [![Subreddit subscribers](https://img.shields.io/reddit/subreddit-subscribers/RaspAP?style=social)](https://www.reddit.com/r/RaspAP/) +[![Release 2.6-beta](https://img.shields.io/badge/release-v2.6--beta-orange)](https://github.com/billz/raspap-webgui/releases) [![Awesome](https://awesome.re/badge.svg)](https://github.com/thibmaek/awesome-raspberry-pi) [![Financial Contributors on Open Collective](https://opencollective.com/raspap/all/badge.svg?label=financial+contributors)](https://opencollective.com/raspap) ![https://travis-ci.com/billz/raspap-webgui/](https://img.shields.io/travis/com/billz/raspap-webgui/master) [![Crowdin](https://badges.crowdin.net/raspap/localized.svg)](https://crowdin.com/project/raspap) [![Twitter URL](https://img.shields.io/twitter/url?label=%40RaspAP&logoColor=%23d8224c&url=https%3A%2F%2Ftwitter.com%2Frasp_ap)](https://twitter.com/rasp_ap) [![Subreddit subscribers](https://img.shields.io/reddit/subreddit-subscribers/RaspAP?style=social)](https://www.reddit.com/r/RaspAP/) RaspAP lets you quickly get a WiFi access point up and running to share the connectivity of many popular [Debian-based devices](#supported-operating-systems), including the Raspberry Pi. Our popular [Quick installer](#quick-installer) creates a known-good default configuration that "just works" on all current Raspberry Pis with onboard wireless. A responsive interface gives you control over the relevant services and networking options. Advanced DHCP settings, OpenVPN client support, SSL, security audits, themes and multilingual options are included. diff --git a/ajax/networking/gen_int_config.php b/ajax/networking/gen_int_config.php deleted file mode 100644 index 4b3be680..00000000 --- a/ajax/networking/gen_int_config.php +++ /dev/null @@ -1,48 +0,0 @@ - $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"; - if (isset($cnfFile['metric'])) { - $strConfFile .= "metric ".$cnfFile['metric']."\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\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"; - $strConfFile .= "static domain_name_servers=".$cnfFile['domain_name_server']."\n\n"; - $strConfFile .= "interface ".$cnfFile['interface']."\n"; - if (isset($cnfFile['metric'])) { - $strConfFile .= "metric ".$cnfFile['metric']."\n"; - } - $strConfFile .= "fallback static_".$cnfFile['interface']."\n\n"; - } else { - $strConfFile .= "#DHCP configured for ".pathinfo($file, PATHINFO_FILENAME)."\n\n"; - } - } - } - - if (file_put_contents(RASPI_CONFIG_NETWORKING.'/dhcpcd.conf', $strConfFile)) { - 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']; - } - echo json_encode($output); -} diff --git a/ajax/networking/get_int_config.php b/ajax/networking/get_int_config.php deleted file mode 100644 index 70be083a..00000000 --- a/ajax/networking/get_int_config.php +++ /dev/null @@ -1,23 +0,0 @@ -1,'output'=>['intConfig'=>$intConfig]]; - echo json_encode($jsonData); - - // Todo - get dhcp lease information from `dhcpcd -U eth0` ? maybe ? -} else { - $jsonData = ['return'=>2,'output'=>['Error getting data']]; - echo json_encode($jsonData); -} diff --git a/ajax/networking/get_netcfg.php b/ajax/networking/get_netcfg.php new file mode 100644 index 00000000..2dd330bb --- /dev/null +++ b/ajax/networking/get_netcfg.php @@ -0,0 +1,56 @@ + 1) { + $dhcpdata['DNS1'] = $arrDns[1]; + } + if (count($arrDns) > 2) { + $dhcpdata['DNS2'] = $arrDns[2]; + } + } + } + + // fetch dhcpcd.conf settings for interface + $conf = file_get_contents(RASPI_DHCPCD_CONFIG); + preg_match('/^#\sRaspAP\s'.$interface.'\s.*?(?=\s*+$)/ms', $conf, $matched); + preg_match('/metric\s(\d*)/', $matched[0], $metric); + preg_match('/static\sip_address=(.*)/', $matched[0], $static_ip); + preg_match('/static\srouters=(.*)/', $matched[0], $static_routers); + preg_match('/static\sdomain_name_server=(.*)/', $matched[0], $static_dns); + preg_match('/fallback\sstatic_'.$interface.'/', $matched[0], $fallback); + $dhcpdata['Metric'] = $metric[1]; + $dhcpdata['StaticIP'] = strpos($static_ip[1],'/') ? substr($static_ip[1], 0, strpos($static_ip[1],'/')) : $static_ip[1]; + $dhcpdata['SubnetMask'] = cidr2mask($static_ip[1]); + $dhcpdata['StaticRouters'] = $static_routers[1]; + $dhcpdata['StaticDNS'] = $static_dns[1]; + $dhcpdata['FallbackEnabled'] = empty($fallback) ? false: true; + + echo json_encode($dhcpdata); +} diff --git a/ajax/networking/save_int_config.php b/ajax/networking/save_int_config.php deleted file mode 100644 index f2a3f7b4..00000000 --- a/ajax/networking/save_int_config.php +++ /dev/null @@ -1,35 +0,0 @@ -0,'output'=>['Successfully Updated Network Configuration']]; - } else { - $jsonData = ['return'=>1,'output'=>['Error saving network configuration to file']]; - } -} else { - $jsonData = ['return'=>2,'output'=>'Unable to detect interface']; -} - -echo json_encode($jsonData); diff --git a/app/css/custom.php b/app/css/custom.php index f6b18318..a4f98d72 100644 --- a/app/css/custom.php +++ b/app/css/custom.php @@ -52,19 +52,23 @@ body { font-weight: 500; } -.card .card-header { +.card .card-header, .modal-header { border-color: ; color: #fff; background-color: ; } +.modal-header { + border-radius: 0px; +} + .btn-primary { color: ; border-color: ; background-color: #fff; } -.card-footer { +.card-footer, .modal-footer { background-color: #f2f1f0; } diff --git a/app/css/hackernews.css b/app/css/hackernews.css index 71dbbd27..1dbb2e97 100644 --- a/app/css/hackernews.css +++ b/app/css/hackernews.css @@ -34,12 +34,12 @@ h5.card-title { color: #212529; } -.card { +.card, .modal-dialog { border-radius: 1px; border-color: #ff6600; } -.card>.card-header { +.card>.card-header, .modal-header { border-color: #ff6600; background-color: #ff6600; color: #000; @@ -53,11 +53,20 @@ h5.card-title { font-size: 1.0rem; } -.card-header [class^="fa"] { +.card-header [class^="fa"], .modal-header [class^="fa"] { color: #fff; font-size: 1.0rem; } +.modal-title { + color: #000; + font-size: 1.0rem; +} + +.modal-content { + border-radius: 0px; +} + .sidebar-brand-text { text-transform: none; color: #212529; diff --git a/app/css/lightsout.css b/app/css/lightsout.css index 55eb4b54..c6fb580b 100644 --- a/app/css/lightsout.css +++ b/app/css/lightsout.css @@ -119,7 +119,7 @@ a:focus, a:hover { color: #d2d2d2; } -.card>.card-header { +.card>.card-header, .modal-content, .modal-header { border-color: #404040; background-color: #202020; color: #afafaf; @@ -129,6 +129,10 @@ a:focus, a:hover { font-weight: 400; } +.modal-body { + background-color: #141414; +} + .card>.card-header .fa { color: #202020; } @@ -197,11 +201,15 @@ hr { width: 6.5rem; } -.card-footer { +.card-footer, .modal-footer { background-color: #202020; border-top: 0px; } +.modal-footer { + border-radius: 0.3rem; +} + .card>.card-header::before, .navbar-default::before { content: " "; display: block; diff --git a/app/js/custom.js b/app/js/custom.js index 0a35d917..bd067368 100644 --- a/app/js/custom.js +++ b/app/js/custom.js @@ -49,74 +49,6 @@ function setupTabs() { }); } -function loadCurrentSettings(strInterface) { - $.post('ajax/networking/get_int_config.php',{interface:strInterface},function(data){ - jsonData = JSON.parse(data); - $.each(jsonData['output'],function(i,v) { - var int = v['interface']; - $.each(v,function(i2,v2) { - switch(i2) { - case "static": - if(v2 == 'true') { - $('#'+int+'-static').click(); - $('#'+int+'-nofailover').click(); - } else { - $('#'+int+'-dhcp').click(); - } - break; - case "failover": - if(v2 === 'true') { - $('#'+int+'-failover').click(); - } else { - $('#'+int+'-nofailover').click(); - } - break; - case "ip_address": - var arrIPNetmask = v2.split('/'); - $('#'+int+'-ipaddress').val(arrIPNetmask[0]); - $('#'+int+'-netmask').val(createNetmaskAddr(arrIPNetmask[1])); - break; - case "routers": - $('#'+int+'-gateway').val(v2); - break; - case "domain_name_server": - svrsDNS = v2.split(" "); - $('#'+int+'-dnssvr').val(svrsDNS[0]); - $('#'+int+'-dnssvralt').val(svrsDNS[1]); - break; - } - }); - }); - }); -} - -function saveNetworkSettings(int) { - var frmInt = $('#frm-'+int).find(':input'); - var arrFormData = {}; - $.each(frmInt,function(i3,v3){ - if($(v3).attr('type') == 'radio') { - arrFormData[$(v3).attr('id')] = $(v3).prop('checked'); - } else { - arrFormData[$(v3).attr('id')] = $(v3).val(); - } - }); - arrFormData['interface'] = int; - $.post('ajax/networking/save_int_config.php',arrFormData,function(data){ - var jsonData = JSON.parse(data); - $('#msgNetworking').html(msgShow(jsonData['return'],jsonData['output'])); - }); -} - -function applyNetworkSettings() { - var int = $(this).data('int'); - arrFormData = {}; - arrFormData['generate'] = ''; - $.post('ajax/networking/gen_int_config.php',arrFormData,function(data){ - var jsonData = JSON.parse(data); - $('#msgNetworking').html(msgShow(jsonData['return'],jsonData['output'])); - }); -} - $(document).on("click", ".js-add-dhcp-static-lease", function(e) { e.preventDefault(); var container = $(".js-new-dhcp-static-lease"); @@ -222,6 +154,8 @@ function contentLoaded() { setupBtns(); case "hostapd_conf": loadChannel(); + case "dhcpd_conf": + loadInterfaceDHCPSelect(); break; } } @@ -236,9 +170,61 @@ function loadWifiStations(refresh) { .load('ajax/networking/wifi_stations.php'+qs, complete); }; } - $(".js-reload-wifi-stations").on("click", loadWifiStations(true)); +/* +Populates the DHCP server form fields +Option toggles are set dynamically depending on the loaded configuration +*/ +function loadInterfaceDHCPSelect() { + var iface = $('#cbxdhcpiface').val(); + $.get('ajax/networking/get_netcfg.php?iface='+iface,function(data){ + jsonData = JSON.parse(data); + $('#dhcp-iface')[0].checked = jsonData.DHCPEnabled; + $('#txtipaddress').val(jsonData.StaticIP); + $('#txtsubnetmask').val(jsonData.SubnetMask); + $('#txtgateway').val(jsonData.StaticRouters); + $('#chkfallback')[0].checked = jsonData.FallbackEnabled; + $('#txtrangestart').val(jsonData.RangeStart); + $('#txtrangeend').val(jsonData.RangeEnd); + $('#txtrangeleasetime').val(jsonData.leaseTime); + $('#txtdns1').val(jsonData.DNS1); + $('#txtdns2').val(jsonData.DNS2); + $('#cbxrangeleasetimeunits').val(jsonData.leaseTimeInterval); + $('#no-resolv')[0].checked = jsonData.upstreamServersEnabled; + $('#cbxdhcpupstreamserver').val(jsonData.upstreamServers[0]); + $('#txtmetric').val(jsonData.Metric); + + if (jsonData.StaticIP !== null && jsonData.StaticIP !== '' && !jsonData.FallbackEnabled) { + $('#chkstatic').closest('.btn').button('toggle'); + $('#chkstatic').closest('.btn').button('toggle').blur(); + $('#chkstatic').blur(); + $('#chkfallback').prop('disabled', true); + } else { + $('#chkdhcp').closest('.btn').button('toggle'); + $('#chkdhcp').closest('.btn').button('toggle').blur(); + $('#chkdhcp').blur(); + $('#chkfallback').prop('disabled', false); + } + if (jsonData.FallbackEnabled || $('#chkdhcp').is(':checked')) { + $('#dhcp-iface').prop('disabled', true); + } + }); +} + +function setDHCPToggles(state) { + if ($('#chkfallback').is(':checked') && state) { + $('#chkfallback').prop('checked', state); + } + if ($('#dhcp-iface').is(':checked') && !state) { + $('#dhcp-iface').prop('checked', state); + } + + $('#chkfallback').prop('disabled', state); + $('#dhcp-iface').prop('disabled', !state); + //$('#dhcp-iface').prop('checked', state); +} + function loadChannel() { $.get('ajax/networking/get_channel.php',function(data){ jsonData = JSON.parse(data); @@ -246,6 +232,18 @@ function loadChannel() { }); } +$('#hostapdModal').on('shown.bs.modal', function (e) { + var seconds = 9; + var countDown = setInterval(function(){ + if(seconds <= 0){ + clearInterval(countDown); + } + var pct = Math.floor(100-(seconds*100/9)); + document.getElementsByClassName('progress-bar').item(0).setAttribute('style','width:'+Number(pct)+'%'); + seconds --; + }, 1000); +}); + /* Sets the wirelss channel select options based on hw_mode and country_code. diff --git a/config/090_raspap.conf b/config/090_raspap.conf new file mode 100644 index 00000000..da01c751 --- /dev/null +++ b/config/090_raspap.conf @@ -0,0 +1,4 @@ +# RaspAP default config +log-facility=/tmp/dnsmasq.log +conf-dir=/etc/dnsmasq.d + diff --git a/config/090_wlan0.conf b/config/090_wlan0.conf new file mode 100644 index 00000000..8cabda48 --- /dev/null +++ b/config/090_wlan0.conf @@ -0,0 +1,6 @@ +# RaspAP wlan0 configuration for wired (ethernet) AP mode +interface=wlan0 +domain-needed +dhcp-range=10.3.141.50,10.3.141.255,255.255.255.0,12h +dhcp-option=6,9.9.9.9,1.1.1.1 + diff --git a/config/config.php b/config/config.php index 030df874..2c476b57 100755 --- a/config/config.php +++ b/config/config.php @@ -2,17 +2,17 @@ define('RASPI_BRAND_TEXT', 'RaspAP'); define('RASPI_CONFIG', '/etc/raspap'); -define('RASPI_CONFIG_NETWORKING', RASPI_CONFIG.'/networking'); +define('RASPI_CONFIG_NETWORK', RASPI_CONFIG.'/networking/defaults.json'); define('RASPI_ADMIN_DETAILS', RASPI_CONFIG.'/raspap.auth'); define('RASPI_WIFI_AP_INTERFACE', 'wlan0'); define('RASPI_CACHE_PATH', sys_get_temp_dir() . '/raspap'); // Constants for configuration file paths. // 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_PREFIX', '/etc/dnsmasq.d/090_'); define('RASPI_ADBLOCK_LISTPATH', '/etc/raspap/adblock/'); -define('RASPI_ADBLOCK_CONFIG', '/etc/dnsmasq.d/090_adblock.conf'); +define('RASPI_ADBLOCK_CONFIG', RASPI_DNSMASQ_PREFIX.'adblock.conf'); define('RASPI_HOSTAPD_CONFIG', '/etc/hostapd/hostapd.conf'); define('RASPI_DHCPCD_CONFIG', '/etc/dhcpcd.conf'); define('RASPI_WPA_SUPPLICANT_CONFIG', '/etc/wpa_supplicant/wpa_supplicant.conf'); diff --git a/config/default_hostapd b/config/default_hostapd deleted file mode 100644 index f3549a63..00000000 --- a/config/default_hostapd +++ /dev/null @@ -1,12 +0,0 @@ -# Location of hostapd configuration file -DAEMON_CONF="/etc/hostapd/hostapd.conf" - -# Additional daemon options to be appended to hostapd command:- -# -d show more debug messages (-dd for even more) -# -K include key data in debug messages -# -t include timestamps in some debug messages -# -# Note that -B (daemon mode) and -P (pidfile) options are automatically -# configured by the init.d script and must not be added to DAEMON_OPTS. -# -#DAEMON_OPTS="" diff --git a/config/defaults.json b/config/defaults.json new file mode 100644 index 00000000..94f80da0 --- /dev/null +++ b/config/defaults.json @@ -0,0 +1,38 @@ +{ + "dhcp": { + "wlan0": { + "static ip_address": [ "10.3.141.1/24" ], + "static routers": [ "10.3.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" ], + "static domain_name_server": [ "1.1.1.1 8.8.8.8" ], + "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": { + "wlan0": { + "dhcp-range": [ "10.3.141.50,10.3.141.255,255.255.255.0,12h" ] + }, + "uap0": { + "dhcp-range": [ "192.168.50.50,192.168.50.150,12h" ] + } + } +} + diff --git a/config/dhcpcd.conf b/config/dhcpcd.conf index 22a4ae18..994861b4 100644 --- a/config/dhcpcd.conf +++ b/config/dhcpcd.conf @@ -1,4 +1,4 @@ -# Defaults from Raspberry Pi configuration +# RaspAP default configuration hostname clientid persistent @@ -10,18 +10,9 @@ require dhcp_server_identifier slaac private nohook lookup-hostname -#denyinterfaces eth0 wlan0 #BRIDGED - -# RaspAP br0 configuration -interface br0 - # RaspAP wlan0 configuration interface wlan0 static ip_address=10.3.141.1/24 static routers=10.3.141.1 static domain_name_server=9.9.9.9 1.1.1.1 -# RaspAP uap0 configuration -interface uap0 -static ip_address=192.168.50.1/24 -nohook wpa_supplicant diff --git a/config/dnsmasq.conf b/config/dnsmasq.conf deleted file mode 100644 index acbf4765..00000000 --- a/config/dnsmasq.conf +++ /dev/null @@ -1,13 +0,0 @@ -# RaspAP wlan0 configuration for wired (ethernet) AP mode -interface=wlan0 -dhcp-range=10.3.141.50,10.3.141.255,255.255.255.0,12h -dhcp-option=6,1.1.1.1,8.8.8.8 - -# RaspAP uap0 configuration for wireless client AP mode -#interface=lo,uap0 # Use interfaces lo and uap0 -#bind-interfaces # Bind to the interfaces -#server=8.8.8.8 # Forward DNS requests to Google DNS -#domain-needed # Don't forward short names -#bogus-priv # Never forward addresses in the non-routed address spaces -#dhcp-range=192.168.50.50,192.168.50.150,12h - diff --git a/includes/defaults.php b/includes/defaults.php index eff12bc7..091c230a 100755 --- a/includes/defaults.php +++ b/includes/defaults.php @@ -6,18 +6,18 @@ if (!defined('RASPI_CONFIG')) { $defaults = [ 'RASPI_BRAND_TEXT' => 'RaspAP', - 'RASPI_VERSION' => '2.5.2', - 'RASPI_CONFIG_NETWORKING' => RASPI_CONFIG.'/networking', + 'RASPI_VERSION' => '2.6-beta', + 'RASPI_CONFIG_NETWORK' => RASPI_CONFIG.'/networking/defaults.json', 'RASPI_ADMIN_DETAILS' => RASPI_CONFIG.'/raspap.auth', 'RASPI_WIFI_AP_INTERFACE' => 'wlan0', 'RASPI_CACHE_PATH' => sys_get_temp_dir() . '/raspap', // Constants for configuration file paths. // 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_PREFIX' => '/etc/dnsmasq.d/090_', 'RASPI_ADBLOCK_LISTPATH' => '/etc/raspap/adblock/', - 'RASPI_ADBLOCK_CONFIG' => '/etc/dnsmasq.d/090_adblock.conf', + 'RASPI_ADBLOCK_CONFIG' => RASPI_DNSMASQ_PREFIX.'adblock.conf', 'RASPI_HOSTAPD_CONFIG' => '/etc/hostapd/hostapd.conf', 'RASPI_DHCPCD_CONFIG' => '/etc/dhcpcd.conf', 'RASPI_WPA_SUPPLICANT_CONFIG' => '/etc/wpa_supplicant/wpa_supplicant.conf', diff --git a/includes/dhcp.php b/includes/dhcp.php index b1838214..0ebf641b 100755 --- a/includes/dhcp.php +++ b/includes/dhcp.php @@ -8,94 +8,12 @@ require_once 'config.php'; */ function DisplayDHCPConfig() { - $status = new StatusMessages(); if (!RASPI_MONITOR_ENABLED) { if (isset($_POST['savedhcpdsettings'])) { - $errors = ''; - define('IFNAMSIZ', 16); - if (!preg_match('/^[a-zA-Z0-9]+$/', $_POST['interface']) - || strlen($_POST['interface']) >= IFNAMSIZ - ) { - $errors .= _('Invalid interface name.').'
'.PHP_EOL; - } - - if (!preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\z/', $_POST['RangeStart']) - && !empty($_POST['RangeStart']) - ) { // allow ''/null ? - $errors .= _('Invalid DHCP range start.').'
'.PHP_EOL; - } - - if (!preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\z/', $_POST['RangeEnd']) - && !empty($_POST['RangeEnd']) - ) { // allow ''/null ? - $errors .= _('Invalid DHCP range end.').'
'.PHP_EOL; - } - - if (!ctype_digit($_POST['RangeLeaseTime']) && $_POST['RangeLeaseTimeUnits'] !== 'infinite') { - $errors .= _('Invalid DHCP lease time, not a number.').'
'.PHP_EOL; - } - - if (!in_array($_POST['RangeLeaseTimeUnits'], array('m', 'h', 'd', 'infinite'))) { - $errors .= _('Unknown DHCP lease time unit.').'
'.PHP_EOL; - } - - $return = 1; - if (empty($errors)) { - $config = 'interface='.$_POST['interface'].PHP_EOL. - 'dhcp-range='.$_POST['RangeStart'].','.$_POST['RangeEnd']. - ',255.255.255.0,'; - if ($_POST['RangeLeaseTimeUnits'] !== 'infinite') { - $config .= $_POST['RangeLeaseTime']; - } - - $config .= $_POST['RangeLeaseTimeUnits'].PHP_EOL; - - for ($i=0; $i < count($_POST["static_leases"]["mac"]); $i++) { - $mac = trim($_POST["static_leases"]["mac"][$i]); - $ip = trim($_POST["static_leases"]["ip"][$i]); - if ($mac != "" && $ip != "") { - $config .= "dhcp-host=$mac,$ip".PHP_EOL; - } - } - - if ($_POST['no-resolv'] == "1") { - $config .= "no-resolv".PHP_EOL; - } - foreach ($_POST['server'] as $server) { - $config .= "server=$server".PHP_EOL; - } - if ($_POST['log-dhcp'] == "1") { - $config .= "log-dhcp".PHP_EOL; - } - if ($_POST['log-queries'] == "1") { - $config .= "log-queries".PHP_EOL; - } - if ($_POST['DNS1']) { - $config .= "dhcp-option=6," . $_POST['DNS1']; - if ($_POST['DNS2']) { - $config .= ','.$_POST['DNS2']; - } - $config .= PHP_EOL; - } - - $config .= "log-facility=/tmp/dnsmasq.log".PHP_EOL; - $config .= "conf-dir=/etc/dnsmasq.d".PHP_EOL; - - file_put_contents("/tmp/dnsmasqdata", $config); - system('sudo cp /tmp/dnsmasqdata '.RASPI_DNSMASQ_CONFIG, $return); - } else { - $status->addMessage($errors, 'danger'); - } - - if ($return == 0) { - $status->addMessage('Dnsmasq configuration updated successfully', 'success'); - } else { - $status->addMessage('Dnsmasq configuration failed to be updated.', 'danger'); - } + saveDHCPConfig($status); } } - exec('pidof dnsmasq | wc -l', $dnsmasq); $dnsmasq_state = ($dnsmasq[0] > 0); @@ -126,75 +44,20 @@ function DisplayDHCPConfig() } } } - + getWifiInterface(); $serviceStatus = $dnsmasq_state ? "up" : "down"; - - exec('cat '. RASPI_DNSMASQ_CONFIG, $return); + exec('cat '. RASPI_DNSMASQ_PREFIX.'raspap.conf', $return); $conf = ParseConfig($return); - $arrRange = explode(",", $conf['dhcp-range']); - $RangeStart = $arrRange[0]; - $RangeEnd = $arrRange[1]; - $RangeMask = $arrRange[2]; - $leaseTime = $arrRange[3]; - $dhcpHost = $conf["dhcp-host"]; - $dhcpHost = empty($dhcpHost) ? [] : $dhcpHost; - $dhcpHost = is_array($dhcpHost) ? $dhcpHost : [ $dhcpHost ]; - $upstreamServers = is_array($conf['server']) ? $conf['server'] : [ $conf['server'] ]; - $upstreamServers = array_filter($upstreamServers); - - $DNS1 = ''; - $DNS2 = ''; - if (isset($conf['dhcp-option'])) { - $arrDns = explode(",", $conf['dhcp-option']); - if ($arrDns[0] == '6') { - if (count($arrDns) > 1) { - $DNS1 = $arrDns[1]; - } - if (count($arrDns) > 2) { - $DNS2 = $arrDns[2]; - } - } - } - - $hselected = ''; - $mselected = ''; - $dselected = ''; - $infiniteselected = ''; - preg_match('/([0-9]*)([a-z])/i', $leaseTime, $arrRangeLeaseTime); - if ($leaseTime === 'infinite') { - $infiniteselected = ' selected="selected"'; - } else { - switch ($arrRangeLeaseTime[2]) { - case 'h': - $hselected = ' selected="selected"'; - break; - case 'm': - $mselected = ' selected="selected"'; - break; - case 'd': - $dselected = ' selected="selected"'; - break; - } - } - exec("ip -o link show | awk -F': ' '{print $2}'", $interfaces); exec('cat ' . RASPI_DNSMASQ_LEASES, $leases); + $ap_iface = $_SESSION['ap_interface']; echo renderTemplate( "dhcp", compact( "status", "serviceStatus", - "RangeStart", - "RangeEnd", - "DNS1", - "DNS2", - "upstreamServers", - "arrRangeLeaseTime", - "mselected", - "hselected", - "dselected", - "infiniteselected", "dnsmasq_state", + "ap_iface", "conf", "dhcpHost", "interfaces", @@ -202,3 +65,196 @@ function DisplayDHCPConfig() ) ); } + +/** + * Saves a DHCP configuration + * + * @return object $status + */ +function saveDHCPConfig($status) +{ + $iface = $_POST['interface']; + $return = 1; + + // handle disable dhcp option + if (!isset($_POST['dhcp-iface']) && file_exists(RASPI_DNSMASQ_PREFIX.$iface.'.conf')) { + // remove dhcp + dnsmasq configs for selected interface + $return = removeDHCPConfig($iface,$status); + $return = removeDnsmasqConfig($iface,$status); + } else { + $errors = validateDHCPInput(); + if (empty($errors)) { + $return = updateDHCPConfig($iface,$status); + } else { + $status->addMessage($errors, 'danger'); + } + if ($return == 1) { + $status->addMessage('Dnsmasq configuration failed to be updated.', 'danger'); + return false; + } + + if (($_POST['dhcp-iface'] == "1")) { + $return = updateDnsmasqConfig($iface,$status); + } + if ($return == 0) { + $status->addMessage('Dnsmasq configuration updated successfully.', 'success'); + } else { + $status->addMessage('Dnsmasq configuration failed to be updated.', 'danger'); + return false; + } + return true; + } +} + +/** + * Validates DHCP user input from the $_POST object + * + * @return string $errors + */ +function validateDHCPInput() +{ + define('IFNAMSIZ', 16); + $iface = $_POST['interface']; + if (!preg_match('/^[a-zA-Z0-9]+$/', $iface) + || strlen($iface) >= IFNAMSIZ + ) { + $errors .= _('Invalid interface name.').'
'.PHP_EOL; + } + if (!filter_var($_POST['StaticIP'], FILTER_VALIDATE_IP) && !empty($_POST['StaticIP'])) { + $errors .= _('Invalid static IP address.').'
'.PHP_EOL; + } + if (!filter_var($_POST['SubnetMask'], FILTER_VALIDATE_IP) && !empty($_POST['SubnetMask'])) { + $errors .= _('Invalid subnet mask.').'
'.PHP_EOL; + } + if (!filter_var($_POST['DefaultGateway'], FILTER_VALIDATE_IP) && !empty($_POST['DefaultGateway'])) { + $errors .= _('Invalid default gateway.').'
'.PHP_EOL; + var_dump($_POST['DefaultGateway']); + die(); + } + if (($_POST['dhcp-iface'] == "1")) { + if (!filter_var($_POST['RangeStart'], FILTER_VALIDATE_IP) && !empty($_POST['RangeStart'])) { + $errors .= _('Invalid DHCP range start.').'
'.PHP_EOL; + } + if (!filter_var($_POST['RangeEnd'], FILTER_VALIDATE_IP) && !empty($_POST['RangeEnd'])) { + $errors .= _('Invalid DHCP range end.').'
'.PHP_EOL; + } + if (!ctype_digit($_POST['RangeLeaseTime']) && $_POST['RangeLeaseTimeUnits'] !== 'infinite') { + $errors .= _('Invalid DHCP lease time, not a number.').'
'.PHP_EOL; + } + if (!in_array($_POST['RangeLeaseTimeUnits'], array('m', 'h', 'd', 'infinite'))) { + $errors .= _('Unknown DHCP lease time unit.').'
'.PHP_EOL; + } + if ($_POST['Metric'] !== '' && !ctype_digit($_POST['Metric'])) { + $errors .= _('Invalid metric value, not a number.').'
'.PHP_EOL; + } + } + return $errors; +} + +/** + * Updates a dnsmasq configuration + * + * @param string $iface + * @param object $status + * @return boolean $result + */ +function updateDnsmasqConfig($iface,$status) +{ + $config = '# RaspAP '.$iface.' configuration'.PHP_EOL; + $config .= 'interface='.$iface.PHP_EOL. + 'dhcp-range='.$_POST['RangeStart'].','.$_POST['RangeEnd']. + ',255.255.255.0,'; + if ($_POST['RangeLeaseTimeUnits'] !== 'infinite') { + $config .= $_POST['RangeLeaseTime']; + } + $config .= $_POST['RangeLeaseTimeUnits'].PHP_EOL; + for ($i=0; $i < count($_POST["static_leases"]["mac"]); $i++) { + $mac = trim($_POST["static_leases"]["mac"][$i]); + $ip = trim($_POST["static_leases"]["ip"][$i]); + if ($mac != "" && $ip != "") { + $config .= "dhcp-host=$mac,$ip".PHP_EOL; + } + } + if ($_POST['no-resolv'] == "1") { + $config .= "no-resolv".PHP_EOL; + } + foreach ($_POST['server'] as $server) { + $config .= "server=$server".PHP_EOL; + } + if ($_POST['DNS1']) { + $config .= "dhcp-option=6," . $_POST['DNS1']; + if ($_POST['DNS2']) { + $config .= ','.$_POST['DNS2']; + } + $config .= PHP_EOL; + } + file_put_contents("/tmp/dnsmasqdata", $config); + $msg = file_exists(RASPI_DNSMASQ_PREFIX.$iface.'.conf') ? 'updated' : 'added'; + system('sudo cp /tmp/dnsmasqdata '.RASPI_DNSMASQ_PREFIX.$iface.'.conf', $result); + if ($result == 0) { + $status->addMessage('Dnsmasq configuration for '.$iface.' '.$msg.'.', 'success'); + } + + // write default 090_raspap.conf + $config = '# RaspAP default config'.PHP_EOL; + $config .='log-facility=/tmp/dnsmasq.log'.PHP_EOL; + $config .='conf-dir=/etc/dnsmasq.d'.PHP_EOL; + // handle log option + if ($_POST['log-dhcp'] == "1") { + $config .= "log-dhcp".PHP_EOL; + } + if ($_POST['log-queries'] == "1") { + $config .= "log-queries".PHP_EOL; + } + $config .= PHP_EOL; + file_put_contents("/tmp/dnsmasqdata", $config); + system('sudo cp /tmp/dnsmasqdata '.RASPI_DNSMASQ_PREFIX.'raspap.conf', $result); + + return $result; +} + +/** + * Updates a dhcp configuration + * + * @param string $iface + * @param object $status + * @return boolean $result + */ +function updateDHCPConfig($iface,$status) +{ + $cfg[] = '# RaspAP '.$iface.' configuration'; + $cfg[] = 'interface '.$iface; + if (isset($_POST['StaticIP'])) { + $mask = ($_POST['SubnetMask'] !== '' && $_POST['SubnetMask'] !== '0.0.0.0') ? '/'.mask2cidr($_POST['SubnetMask']) : null; + $cfg[] = 'static ip_address='.$_POST['StaticIP'].$mask; + } + if (isset($_POST['DefaultGateway'])) { + $cfg[] = 'static routers='.$_POST['DefaultGateway']; + } + if ($_POST['DNS1'] !== '' || $_POST['DNS2'] !== '') { + $cfg[] = 'static domain_name_server='.$_POST['DNS1'].' '.$_POST['DNS2']; + } + if ($_POST['Metric'] !== '') { + $cfg[] = 'metric '.$_POST['Metric']; + } + if ($_POST['Fallback'] == 1) { + $cfg[] = 'profile static_'.$iface; + $cfg[] = 'fallback static_'.$iface; + } + $dhcp_cfg = file_get_contents(RASPI_DHCPCD_CONFIG); + if (!preg_match('/^interface\s'.$iface.'$/m', $dhcp_cfg)) { + $cfg[] = PHP_EOL; + $cfg = join(PHP_EOL, $cfg); + $dhcp_cfg .= $cfg; + $status->addMessage('DHCP configuration for '.$iface.' added.', 'success'); + } else { + $cfg = join(PHP_EOL, $cfg); + $dhcp_cfg = preg_replace('/^#\sRaspAP\s'.$iface.'\s.*?(?=\s*^\s*$)/ms', $cfg, $dhcp_cfg, 1); + $status->addMessage('DHCP configuration for '.$iface.' updated.', 'success'); + } + file_put_contents("/tmp/dhcpddata", $dhcp_cfg); + system('sudo cp /tmp/dhcpddata '.RASPI_DHCPCD_CONFIG, $result); + + return $result; +} + diff --git a/includes/functions.php b/includes/functions.php index 1304d61f..af505380 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -1,6 +1,12 @@ addMessage('DHCP configuration for '.$iface.' removed.', 'success'); + } else { + $status->addMessage('Failed to remove DHCP configuration for '.$iface.'.', 'danger'); + return $result; + } +} + +/** + * Removes a dhcp configuration block for the specified interface + * + * @param string $dhcp_cfg + * @param string $iface + * @return string $dhcp_cfg + */ +function removeDHCPIface($dhcp_cfg,$iface) +{ + $dhcp_cfg = preg_replace('/^#\sRaspAP\s'.$iface.'\s.*?(?=\s*^\s*$)([\s]+)/ms', '', $dhcp_cfg, 1); + return $dhcp_cfg; +} + +/** + * Removes a dnsmasq configuration block for the specified interface + * + * @param string $iface + * @param object $status + * @return boolean $result + */ +function removeDnsmasqConfig($iface,$status) +{ + system('sudo rm '.RASPI_DNSMASQ_PREFIX.$iface.'.conf', $result); + if ($result == 0) { + $status->addMessage('Dnsmasq configuration for '.$iface.' removed.', 'success'); + } else { + $status->addMessage('Failed to remove dnsmasq configuration for '.$iface.'.', 'danger'); + } + return $result; +} + +/** + * Scans dnsmasq configuration dir for the specified interface + * Non-matching configs are removed, optional adblock.conf is protected + * + * @param string $dir_conf + * @param string $interface + * @param object $status + */ +function scanConfigDir($dir_conf,$interface,$status) +{ + $syscnf = preg_grep('~\.(conf)$~', scandir($dir_conf)); + foreach ($syscnf as $cnf) { + if ($cnf !== '090_adblock.conf' && !preg_match('/.*_'.$interface.'.conf/', $cnf)) { + system('sudo rm /etc/dnsmasq.d/'.$cnf, $result); + } + } + return $status; +} + +/** + * Returns a default (fallback) value for the selected service, interface & setting + * from /etc/raspap/networking/defaults.json + * + * @param string $svc + * @param string $iface + * @return string $value + */ +function getDefaultNetValue($svc,$iface,$key) +{ + $json = json_decode(file_get_contents(RASPI_CONFIG_NETWORK), true); + if ($json === null) { + return false; + } else { + return $json[$svc][$iface][$key][0]; + } +} + +/** + * 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 */ function write_php_ini($array, $file) @@ -213,6 +339,19 @@ function ParseConfig($arrConfig) return $config; } +/** + * Fetches DHCP configuration for an interface, returned as JSON data + * + * @param string $interface + * @return json $jsonData + */ +function getNetConfig($interface) +{ + $URI = $_SERVER['REQUEST_SCHEME'].'://'.$_SERVER['SERVER_NAME'] .'/ajax/networking/get_netcfg.php?iface='.$interface; + $jsonData = file_get_contents($URI); + return $jsonData; +} + /** * * @param string $freq diff --git a/includes/hostapd.php b/includes/hostapd.php index 9b698480..f16fd8ad 100755 --- a/includes/hostapd.php +++ b/includes/hostapd.php @@ -8,7 +8,7 @@ require_once 'includes/config.php'; getWifiInterface(); /** - * + * Initialize hostapd values, display interface * */ function DisplayHostAPDConfig() @@ -34,7 +34,6 @@ function DisplayHostAPDConfig() SaveHostAPDConfig($arrSecurity, $arrEncType, $arr80211Standard, $interfaces, $status); } } - $arrHostapdConf = parse_ini_file('/etc/raspap/hostapd.ini'); if (!RASPI_MONITOR_ENABLED) { @@ -71,7 +70,6 @@ function DisplayHostAPDConfig() if (strlen($hostapdconfigline) === 0) { continue; } - if ($hostapdconfigline[0] != "#") { $arrLine = explode("=", $hostapdconfigline); $arrConfig[$arrLine[0]]=$arrLine[1]; @@ -107,6 +105,16 @@ function DisplayHostAPDConfig() ); } +/** + * Validate user input, save configs for hostapd, dnsmasq & dhcp + * + * @param array $wpa_array + * @param array $enc_types + * @param array $modes + * @param string $interface + * @param object $status + * @return boolean + */ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status) { // It should not be possible to send bad data for these fields so clearly @@ -125,14 +133,12 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status) $status->addMessage('Attempting to set channel to invalid number.', 'danger'); $good_input = false; } - if (intval($_POST['channel']) < 1 || intval($_POST['channel']) > RASPI_5GHZ_MAX_CHANNEL) { $status->addMessage('Attempting to set channel outside of permitted range', 'danger'); $good_input = false; } - $arrHostapdConf = parse_ini_file('/etc/raspap/hostapd.ini'); - + // Check for Bridged AP mode checkbox $bridgedEnable = 0; if ($arrHostapdConf['BridgedEnable'] == 0) { @@ -144,7 +150,6 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status) $bridgedEnable = 1; } } - // Check for WiFi client AP mode checkbox $wifiAPEnable = 0; if ($bridgedEnable == 0) { // enable client mode actions when not bridged @@ -158,7 +163,6 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status) } } } - // Check for Logfile output checkbox $logEnable = 0; if ($arrHostapdConf['LogEnable'] == 0) { @@ -176,17 +180,21 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status) exec('sudo '.RASPI_CONFIG.'/hostapd/disablelog.sh'); } } + // set AP interface default, override for ap-sta & bridged options + $ap_iface = $_POST['interface']; + if ($wifiAPEnable) { $ap_iface = 'uap0'; } + if ($bridgedEnable) { $ap_iface = 'br0'; } + // persist user options to /etc/raspap $cfg = []; $cfg['WifiInterface'] = $_POST['interface']; $cfg['LogEnable'] = $logEnable; // Save previous Client mode status when Bridged - $cfg['WifiAPEnable'] = ($bridgedEnable == 1 ? - $arrHostapdConf['WifiAPEnable'] : $wifiAPEnable); + $cfg['WifiAPEnable'] = ($bridgedEnable == 1 ? $arrHostapdConf['WifiAPEnable'] : $wifiAPEnable); $cfg['BridgedEnable'] = $bridgedEnable; - $cfg['WifiManaged'] = $_POST['interface']; + $cfg['WifiManaged'] = $ap_iface; write_php_ini($cfg, RASPI_CONFIG.'/hostapd.ini'); - $_SESSION['ap_interface'] = $_POST['interface']; + $_SESSION['ap_interface'] = $ap_iface; // Verify input if (empty($_POST['ssid']) || strlen($_POST['ssid']) > 32) { @@ -240,153 +248,95 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status) $_POST['max_num_sta'] = $_POST['max_num_sta'] < 1 ? null : $_POST['max_num_sta']; if ($good_input) { - // Fixed values - $country_code = $_POST['country_code']; - $config = 'driver=nl80211'.PHP_EOL; - $config.= 'ctrl_interface='.RASPI_HOSTAPD_CTRL_INTERFACE.PHP_EOL; - $config.= 'ctrl_interface_group=0'.PHP_EOL; - $config.= 'auth_algs=1'.PHP_EOL; - $config.= 'wpa_key_mgmt=WPA-PSK'.PHP_EOL; - if (isset($_POST['beaconintervalEnable'])) { - $config.= 'beacon_int='.$_POST['beacon_interval'].PHP_EOL; - } - if (isset($_POST['disassoc_low_ackEnable'])) { - $config.= 'disassoc_low_ack=0'.PHP_EOL; - } - $config.= 'ssid='.$_POST['ssid'].PHP_EOL; - $config.= 'channel='.$_POST['channel'].PHP_EOL; - if ($_POST['hw_mode'] === 'n') { - $config.= 'hw_mode=g'.PHP_EOL; - $config.= 'ieee80211n=1'.PHP_EOL; - // Enable basic Quality of service - $config.= 'wmm_enabled=1'.PHP_EOL; - } elseif ($_POST['hw_mode'] === 'ac') { - $config.= 'hw_mode=a'.PHP_EOL.PHP_EOL; - $config.= '# N'.PHP_EOL; - $config.= 'ieee80211n=1'.PHP_EOL; - $config.= 'require_ht=1'.PHP_EOL; - $config.= 'ht_capab=[MAX-AMSDU-3839][HT40+][SHORT-GI-20][SHORT-GI-40][DSSS_CCK-40]'.PHP_EOL.PHP_EOL; - $config.= '# AC'.PHP_EOL; - $config.= 'ieee80211ac=1'.PHP_EOL; - $config.= 'require_vht=1'.PHP_EOL; - $config.= 'ieee80211d=0'.PHP_EOL; - $config.= 'ieee80211h=0'.PHP_EOL; - $config.= 'vht_capab=[MAX-AMSDU-3839][SHORT-GI-80]'.PHP_EOL; - $config.= 'vht_oper_chwidth=1'.PHP_EOL; - $config.= 'vht_oper_centr_freq_seg0_idx=42'.PHP_EOL.PHP_EOL; - } elseif ($_POST['hw_mode'] === 'w') { - $config.= 'ieee80211w=2'.PHP_EOL; - $config.= 'wpa_key_mgmt=WPA-EAP-SHA256'.PHP_EOL; - } else { - $config.= 'hw_mode='.$_POST['hw_mode'].PHP_EOL; - $config.= 'ieee80211n=0'.PHP_EOL; - } - if ($_POST['wpa'] !== 'none') { - $config.= 'wpa_passphrase='.$_POST['wpa_passphrase'].PHP_EOL; - } - if ($wifiAPEnable == 1) { - $config.= 'interface=uap0'.PHP_EOL; - } elseif ($bridgedEnable == 1) { - $config.='interface='.$_POST['interface'].PHP_EOL; - $config.= 'bridge=br0'.PHP_EOL; - } else { - $config.= 'interface='.$_POST['interface'].PHP_EOL; - } - $config.= 'wpa='.$_POST['wpa'].PHP_EOL; - $config.= 'wpa_pairwise='.$_POST['wpa_pairwise'].PHP_EOL; - $config.= 'country_code='.$_POST['country_code'].PHP_EOL; - $config.= 'ignore_broadcast_ssid='.$ignore_broadcast_ssid.PHP_EOL; - if (isset($_POST['max_num_sta'])) { - $config.= 'max_num_sta='.$_POST['max_num_sta'].PHP_EOL; - } - - file_put_contents("/tmp/hostapddata", $config); - system("sudo cp /tmp/hostapddata " . RASPI_HOSTAPD_CONFIG, $return); + $return = updateHostapdConfig($ignore_broadcast_ssid,$wifiAPEnble,$bridgedEnable); // Fetch dhcp-range, lease time from system config - $dhcpConfig = parse_ini_file(RASPI_DNSMASQ_CONFIG, false, INI_SCANNER_RAW); + $syscfg = parse_ini_file(RASPI_DNSMASQ_PREFIX.$ap_iface.'.conf', false, INI_SCANNER_RAW); if ($wifiAPEnable == 1) { - // Enable uap0 configuration in dnsmasq for Wifi client AP mode - // Set dhcp-range from system config. If undefined, fallback to default - $dhcp_range = ($dhcpConfig['dhcp-range'] =='10.3.141.50,10.3.141.255,255.255.255.0,12h' || - $dhcpConfig['dhcp-range'] =='') ? '192.168.50.50,192.168.50.150,12h' : $dhcpConfig['dhcp-range']; - $config = 'interface=lo,uap0 # Enable uap0 interface for wireless client AP mode'.PHP_EOL; - $config.= 'bind-dynamic # Hybrid between --bind-interfaces and default'.PHP_EOL; - $config.= 'server=8.8.8.8 # Forward DNS requests to Google DNS'.PHP_EOL; - $config.= 'domain-needed # Don\'t forward short names'.PHP_EOL; - $config.= 'bogus-priv # Never forward addresses in the non-routed address spaces'.PHP_EOL; - $config.= 'dhcp-range='.$dhcp_range.PHP_EOL; - if (!empty($dhcpConfig['dhcp-option'])) { - $config.= 'dhcp-option='.$dhcpConfig['dhcp-option'].PHP_EOL; + // Enable uap0 configuration for ap-sta mode + // Set dhcp-range from system config, fallback to default if undefined + $dhcp_range = ($syscfg['dhcp-range'] == '') ? getDefaultNetValue('dnsmasq','uap0','dhcp-range') : $syscfg['dhcp-range']; + $config = [ '# RaspAP uap0 configuration' ]; + $config[] = 'interface=lo,uap0 # Enable uap0 interface for wireless client AP mode'; + $config[] = 'bind-dynamic # Hybrid between --bind-interfaces and default'; + $config[] = 'server=8.8.8.8 # Forward DNS requests to Google DNS'; + $config[] = 'domain-needed # Don\'t forward short names'; + $config[] = 'bogus-priv # Never forward addresses in the non-routed address spaces'; + $config[] = 'dhcp-range='.$dhcp_range; + if (!empty($syscfg['dhcp-option'])) { + $config[] = 'dhcp-option='.$syscfg['dhcp-option']; } - } else { - // Set dhcp-range from system config. If undefined, fallback to default - $dhcp_range = ($dhcpConfig['dhcp-range'] =='192.168.50.50,192.168.50.150,12h' || - $dhcpConfig['dhcp-range'] =='') ? '10.3.141.50,10.3.141.255,255.255.255.0,12h' : $dhcpConfig['dhcp-range']; - $config = 'domain-needed'.PHP_EOL; - $config.= 'interface='.$_POST['interface'].PHP_EOL; - $config.= 'dhcp-range='.$dhcp_range.PHP_EOL; - if (!empty($dhcpConfig['dhcp-option'])) { - $config.= 'dhcp-option='.$dhcpConfig['dhcp-option'].PHP_EOL; + $config[] = PHP_EOL; + scanConfigDir('/etc/dnsmasq.d/','uap0',$status); + $config = join(PHP_EOL, $config); + 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']; + $config = [ '# RaspAP '.$_POST['interface'].' configuration' ]; + $config[] = 'interface='.$_POST['interface']; + $config[] = 'domain-needed'; + $config[] = 'dhcp-range='.$dhcp_range; + if (!empty($syscfg['dhcp-option'])) { + $config[] = 'dhcp-option='.$syscfg['dhcp-option']; } + $config[] = PHP_EOL; + $config = join(PHP_EOL, $config); + file_put_contents("/tmp/dnsmasqdata", $config); + system('sudo cp /tmp/dnsmasqdata '.RASPI_DNSMASQ_PREFIX.$ap_iface.'.conf', $return); } - file_put_contents("/tmp/dnsmasqdata", $config); - 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.'/'.$_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']; - - // write options to dhcpcd.conf - $config = [ '# RaspAP '.$_POST['interface'].' 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'; + // 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',$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 ($bridgedEnable == 1) { - $config[] = 'denyinterfaces eth0 wlan0'; + $config = array_keys(getDefaultNetOpts('dhcp')); + $config[] = PHP_EOL.'# RaspAP br0 configuration'; $config[] = 'interface br0'; + $config[] = 'denyinterfaces eth0 wlan0'; + $config[] = PHP_EOL; } elseif ($wifiAPEnable == 1) { - // Enable uap0 configuration in dhcpcd for Wifi client AP mode - $intConfig = parse_ini_file(RASPI_CONFIG_NETWORKING.'/uap0.ini', false, INI_SCANNER_RAW); - $ip_address = ($intConfig['ip_address'] == '') ? '192.168.50.1/24' : $intConfig['ip_address']; + $config = array_keys(getDefaultNetOpts('dhcp')); + $config[] = PHP_EOL.'# RaspAP uap0 configuration'; $config[] = 'interface uap0'; $config[] = 'static ip_address='.$ip_address; $config[] = 'nohook wpa_supplicant'; - } else { - // 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 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"); + } else { + // Default wlan0 config + $def_ip = array(); + $config = [ '# RaspAP wlan0 configuration' ]; + $config[] = 'interface wlan0'; + $config[] = 'static ip_address='.$ip_address; + $config[] = 'static routers='.$routers; + $config[] = 'static domain_name_server='.$domain_name_server; + if (! is_null($jsonData['Metric'])) { $config[] = 'metric '.$jsonData['Metric']; } } - - $config = join(PHP_EOL, $config); - file_put_contents("/tmp/dhcpddata", $config); + $dhcp_cfg = file_get_contents(RASPI_DHCPCD_CONFIG); + if ($bridgedEnable == 1 || $wifiAPEnable == 1) { + $dhcp_cfg = join(PHP_EOL, $config); + $status->addMessage('DHCP configuration for '.$ap_iface.' enabled.', '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'); + } 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'); + } + file_put_contents("/tmp/dhcpddata", $dhcp_cfg); system('sudo cp /tmp/dhcpddata '.RASPI_DHCPCD_CONFIG, $return); if ($return == 0) { @@ -398,6 +348,77 @@ function SaveHostAPDConfig($wpa_array, $enc_types, $modes, $interfaces, $status) $status->addMessage('Unable to save wifi hotspot settings', 'danger'); return false; } - return true; } + +/** + * Updates a hostapd configuration + * + * @return boolean $result + */ +function updateHostapdConfig($ignore_broadcast_ssid,$wifiAPEnble,$bridgedEnable) +{ + // Fixed values + $country_code = $_POST['country_code']; + $config = 'driver=nl80211'.PHP_EOL; + $config.= 'ctrl_interface='.RASPI_HOSTAPD_CTRL_INTERFACE.PHP_EOL; + $config.= 'ctrl_interface_group=0'.PHP_EOL; + $config.= 'auth_algs=1'.PHP_EOL; + $config.= 'wpa_key_mgmt=WPA-PSK'.PHP_EOL; + if (isset($_POST['beaconintervalEnable'])) { + $config.= 'beacon_int='.$_POST['beacon_interval'].PHP_EOL; + } + if (isset($_POST['disassoc_low_ackEnable'])) { + $config.= 'disassoc_low_ack=0'.PHP_EOL; + } + $config.= 'ssid='.$_POST['ssid'].PHP_EOL; + $config.= 'channel='.$_POST['channel'].PHP_EOL; + if ($_POST['hw_mode'] === 'n') { + $config.= 'hw_mode=g'.PHP_EOL; + $config.= 'ieee80211n=1'.PHP_EOL; + // Enable basic Quality of service + $config.= 'wmm_enabled=1'.PHP_EOL; + } elseif ($_POST['hw_mode'] === 'ac') { + $config.= 'hw_mode=a'.PHP_EOL.PHP_EOL; + $config.= '# N'.PHP_EOL; + $config.= 'ieee80211n=1'.PHP_EOL; + $config.= 'require_ht=1'.PHP_EOL; + $config.= 'ht_capab=[MAX-AMSDU-3839][HT40+][SHORT-GI-20][SHORT-GI-40][DSSS_CCK-40]'.PHP_EOL.PHP_EOL; + $config.= '# AC'.PHP_EOL; + $config.= 'ieee80211ac=1'.PHP_EOL; + $config.= 'require_vht=1'.PHP_EOL; + $config.= 'ieee80211d=0'.PHP_EOL; + $config.= 'ieee80211h=0'.PHP_EOL; + $config.= 'vht_capab=[MAX-AMSDU-3839][SHORT-GI-80]'.PHP_EOL; + $config.= 'vht_oper_chwidth=1'.PHP_EOL; + $config.= 'vht_oper_centr_freq_seg0_idx=42'.PHP_EOL.PHP_EOL; + } elseif ($_POST['hw_mode'] === 'w') { + $config.= 'ieee80211w=2'.PHP_EOL; + $config.= 'wpa_key_mgmt=WPA-EAP-SHA256'.PHP_EOL; + } else { + $config.= 'hw_mode='.$_POST['hw_mode'].PHP_EOL; + $config.= 'ieee80211n=0'.PHP_EOL; + } + if ($_POST['wpa'] !== 'none') { + $config.= 'wpa_passphrase='.$_POST['wpa_passphrase'].PHP_EOL; + } + if ($wifiAPEnable == 1) { + $config.= 'interface=uap0'.PHP_EOL; + } elseif ($bridgedEnable == 1) { + $config.='interface='.$_POST['interface'].PHP_EOL; + $config.= 'bridge=br0'.PHP_EOL; + } else { + $config.= 'interface='.$_SESSION['ap_interface'].PHP_EOL; + } + $config.= 'wpa='.$_POST['wpa'].PHP_EOL; + $config.= 'wpa_pairwise='.$_POST['wpa_pairwise'].PHP_EOL; + $config.= 'country_code='.$_POST['country_code'].PHP_EOL; + $config.= 'ignore_broadcast_ssid='.$ignore_broadcast_ssid.PHP_EOL; + if (isset($_POST['max_num_sta'])) { + $config.= 'max_num_sta='.$_POST['max_num_sta'].PHP_EOL; + } + file_put_contents("/tmp/hostapddata", $config); + system("sudo cp /tmp/hostapddata " . RASPI_HOSTAPD_CONFIG, $result); + return $result; +} + diff --git a/index.php b/index.php index 04aee0d1..99e555ed 100755 --- a/index.php +++ b/index.php @@ -14,7 +14,7 @@ * @author Lawrence Yau * @author Bill Zimmerman * @license GNU General Public License, version 3 (GPL-3.0) - * @version 2.5.2 + * @version 2.6-beta * @link https://github.com/billz/raspap-webgui/ * @link https://raspap.com/ * @see http://sirlagz.net/2013/02/08/raspap-webgui/ diff --git a/installers/common.sh b/installers/common.sh index 77392501..927b4762 100755 --- a/installers/common.sh +++ b/installers/common.sh @@ -20,9 +20,11 @@ set -o errtrace readonly raspap_dir="/etc/raspap" readonly raspap_user="www-data" readonly raspap_sudoers="/etc/sudoers.d/090_raspap" -readonly raspap_dnsmasq="/etc/dnsmasq.d/090_raspap.conf" +readonly raspap_default="/etc/dnsmasq.d/090_raspap.conf" +readonly raspap_wlan0="/etc/dnsmasq.d/090_wlan0.conf" readonly raspap_adblock="/etc/dnsmasq.d/090_adblock.conf" readonly raspap_sysctl="/etc/sysctl.d/90_raspap.conf" +readonly raspap_network="$raspap_dir/networking/" readonly rulesv4="/etc/iptables/rules.v4" readonly notracking_url="https://raw.githubusercontent.com/notracking/hosts-blocklists/master/" webroot_dir="/var/www/html" @@ -167,11 +169,7 @@ function _create_raspap_directories() { # Create a directory to store networking configs echo "Creating $raspap_dir/networking" sudo mkdir -p "$raspap_dir/networking" - # Copy existing dhcpcd.conf to use as base config - echo "Adding /etc/dhcpcd.conf as base configuration" - cat /etc/dhcpcd.conf | sudo tee -a /etc/raspap/networking/defaults > /dev/null - echo "Changing file ownership of $raspap_dir" - sudo chown -R $raspap_user:$raspap_user "$raspap_dir" || _install_status 1 "Unable to change file ownership for '$raspap_dir'" + } # Generate hostapd logging and service control scripts @@ -258,9 +256,9 @@ function _install_adblock() { echo "addn-hosts=$raspap_dir/adblock/hostnames.txt" | sudo tee -a "$raspap_adblock" > /dev/null || _install_status 1 "Unable to write to $raspap_adblock" fi - # Remove dhcp-option=6 in dnsmasq.d/090_raspap.conf to force local DNS resolution for DHCP clients + # Remove dhcp-option=6 in dnsmasq.d/090_wlan0.conf to force local DNS resolution for DHCP clients echo "Enabling local DNS name resolution for DHCP clients" - sudo sed -i '/dhcp-option=6/d' $raspap_dnsmasq || _install_status 1 "Unable to modify $raspap_dnsmasq" + sudo sed -i '/dhcp-option=6/d' $raspap_wlan0 || _install_status 1 "Unable to modify $raspap_dnsmasq" echo "Enabling ad blocking management option" sudo sed -i "s/\('RASPI_ADBLOCK_ENABLED', \)false/\1true/g" "$webroot_dir/includes/config.php" || _install_status 1 "Unable to modify config.php" @@ -358,9 +356,14 @@ function _check_for_old_configs() { sudo ln -sf "$raspap_dir/backups/hostapd.conf.`date +%F-%R`" "$raspap_dir/backups/hostapd.conf" fi - if [ -f $raspap_dnsmasq ]; then - sudo cp $raspap_dnsmasq "$raspap_dir/backups/dnsmasq.conf.`date +%F-%R`" - sudo ln -sf "$raspap_dir/backups/dnsmasq.conf.`date +%F-%R`" "$raspap_dir/backups/dnsmasq.conf" + if [ -f $raspap_default ]; then + sudo cp $raspap_default "$raspap_dir/backups/090_raspap.conf.`date +%F-%R`" + sudo ln -sf "$raspap_dir/backups/090_raspap.conf.`date +%F-%R`" "$raspap_dir/backups/090_raspap.conf" + fi + + if [ -f $raspap_wlan0 ]; then + sudo cp $raspap_wlan0 "$raspap_dir/backups/090_wlan0.conf.`date +%F-%R`" + sudo ln -sf "$raspap_dir/backups/090_wlan0.conf.`date +%F-%R`" "$raspap_dir/backups/090_wlan0.conf" fi if [ -f /etc/dhcpcd.conf ]; then @@ -394,13 +397,15 @@ function _move_config_file() { function _default_configuration() { if [ "$upgrade" == 0 ]; then _install_log "Applying default configuration to installed services" - if [ -f /etc/default/hostapd ]; then - sudo mv /etc/default/hostapd /tmp/default_hostapd.old || _install_status 1 "Unable to remove old /etc/default/hostapd file" - fi - sudo cp $webroot_dir/config/default_hostapd /etc/default/hostapd || _install_status 1 "Unable to move hostapd defaults file" + sudo cp $webroot_dir/config/hostapd.conf /etc/hostapd/hostapd.conf || _install_status 1 "Unable to move hostapd configuration file" - sudo cp $webroot_dir/config/dnsmasq.conf $raspap_dnsmasq || _install_status 1 "Unable to move dnsmasq configuration file" + sudo cp $webroot_dir/config/090_raspap.conf $raspap_default || _install_status 1 "Unable to move dnsmasq default configuration file" + sudo cp $webroot_dir/config/090_wlan0.conf $raspap_wlan0 || _install_status 1 "Unable to move dnsmasq wlan0 configuration file" sudo cp $webroot_dir/config/dhcpcd.conf /etc/dhcpcd.conf || _install_status 1 "Unable to move dhcpcd configuration file" + sudo cp $webroot_dir/config/defaults.json $raspap_network || _install_status 1 "Unable to move defaults.json settings" + + echo "Changing file ownership of $raspap_dir" + sudo chown -R $raspap_user:$raspap_user "$raspap_dir" || _install_status 1 "Unable to change file ownership for '$raspap_dir'" echo "Checking for existence of /etc/dnsmasq.d" [ -d /etc/dnsmasq.d ] || sudo mkdir /etc/dnsmasq.d diff --git a/installers/raspap.sudoers b/installers/raspap.sudoers index ae42393c..00e1d1c7 100644 --- a/installers/raspap.sudoers +++ b/installers/raspap.sudoers @@ -20,7 +20,8 @@ www-data ALL=(ALL) NOPASSWD:/bin/systemctl stop openvpn-client@client www-data ALL=(ALL) NOPASSWD:/bin/systemctl disable openvpn-client@client www-data ALL=(ALL) NOPASSWD:/bin/cp /tmp/ovpnclient.ovpn /etc/openvpn/client/client.conf www-data ALL=(ALL) NOPASSWD:/bin/cp /tmp/authdata /etc/openvpn/client/login.conf -www-data ALL=(ALL) NOPASSWD:/bin/cp /tmp/dnsmasqdata /etc/dnsmasq.d/090_raspap.conf +www-data ALL=(ALL) NOPASSWD:/bin/cp /tmp/dnsmasqdata /etc/dnsmasq.d/090_*.conf +www-data ALL=(ALL) NOPASSWD:/bin/rm /etc/dnsmasq.d/090_*.conf www-data ALL=(ALL) NOPASSWD:/bin/cp /tmp/dhcpddata /etc/dhcpcd.conf www-data ALL=(ALL) NOPASSWD:/sbin/shutdown -h now www-data ALL=(ALL) NOPASSWD:/sbin/reboot diff --git a/installers/uninstall.sh b/installers/uninstall.sh index 542ddc65..cad1fb3e 100755 --- a/installers/uninstall.sh +++ b/installers/uninstall.sh @@ -18,8 +18,10 @@ set -o errtrace readonly raspap_dir="/etc/raspap" readonly raspap_user="www-data" readonly raspap_sudoers="/etc/sudoers.d/090_raspap" -readonly raspap_dnsmasq="/etc/dnsmasq.d/090_raspap.conf" +readonly raspap_default="/etc/dnsmasq.d/090_raspap.conf" +readonly raspap_wlan0="/etc/dnsmasq.d/090_wlan0.conf" readonly raspap_sysctl="/etc/sysctl.d/90_raspap.conf" +readonly raspap_adblock="/etc/dnsmasq.d/090_adblock.conf" readonly raspap_network="/etc/systemd/network/" readonly rulesv4="/etc/iptables/rules.v4" webroot_dir="/var/www/html" @@ -139,7 +141,9 @@ function _remove_raspap_directories() { # Removes raspapd.service function _remove_raspap_service() { _install_log "Removing raspapd.service" - sudo rm /lib/systemd/system/raspapd.service || _install_error "Unable to remove raspap.service file" + if [ -f /lib/systemd/system/raspapd.service ]; then + sudo rm /lib/systemd/system/raspapd.service || _install_error "Unable to remove raspap.service file" + fi sudo systemctl daemon-reload sudo systemctl disable raspapd.service || _install_error "Failed to disable raspap.service" echo "Done." @@ -172,9 +176,19 @@ function _restore_networking() { echo "Done." # Remove dnsmasq and bridge configs echo "Removing 090_raspap.conf from dnsmasq" - sudo rm "$raspap_dnsmasq" || _install_error "Unable to remove $raspap_dnsmasq" + if [ -f $raspap_default ]; then + sudo rm "$raspap_default" || _install_error "Unable to remove $raspap_default" + fi + echo "Removing 090_wlan0.conf from dnsmasq" + if [ -f $raspap_wlan0 ]; then + sudo rm "$raspap_wlan0" || _install_error "Unable to remove $raspap_wlan0" + fi echo "Removing raspap bridge configurations" sudo rm "$raspap_network"/raspap* || _install_error "Unable to remove bridge config" + if [ -f $raspap_adblock ]; then + echo "Removing raspap adblock configuration" + sudo rm "$raspap_adblock" || _install_error "Unable to remove adblock config" + fi } # Removes installed packages diff --git a/locale/en_US/LC_MESSAGES/messages.mo b/locale/en_US/LC_MESSAGES/messages.mo index 606d982e..34d53bd3 100644 Binary files a/locale/en_US/LC_MESSAGES/messages.mo and b/locale/en_US/LC_MESSAGES/messages.mo differ diff --git a/locale/en_US/LC_MESSAGES/messages.po b/locale/en_US/LC_MESSAGES/messages.po index 82189da3..8c4d5f97 100644 --- a/locale/en_US/LC_MESSAGES/messages.po +++ b/locale/en_US/LC_MESSAGES/messages.po @@ -254,6 +254,12 @@ msgstr "Client list" msgid "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" msgstr "DNS Server" @@ -347,6 +353,9 @@ msgstr "Format" msgid "Choose a hosted server" msgstr "Choose a hosted server" +msgid "Enable these options to log DHCP server activity." +msgstr "Enable these options to log DHCP server activity." + msgid "Log DHCP requests" msgstr "Log DHCP requests" @@ -456,6 +465,15 @@ msgstr "Disable disassoc_low_ack" msgid "Do not disassociate stations based on excessive transmission failures." msgstr "Do not disassociate stations based on excessive transmission failures." +msgid "Executing RaspAP service start" +msgstr "Executing RaspAP service start" + +msgid "Close" +msgstr "Close" + +msgid "Enable this option to log hostapd activity." +msgstr "Enable this option to log hostapd activity." + #: includes/networking.php msgid "Summary" msgstr "Summary" diff --git a/locale/tr_TR/LC_MESSAGES/messages.mo b/locale/tr_TR/LC_MESSAGES/messages.mo index 96e433d7..a5dc3a1d 100644 Binary files a/locale/tr_TR/LC_MESSAGES/messages.mo and b/locale/tr_TR/LC_MESSAGES/messages.mo differ diff --git a/templates/dhcp/advanced.php b/templates/dhcp/advanced.php index 6366977c..69804d86 100644 --- a/templates/dhcp/advanced.php +++ b/templates/dhcp/advanced.php @@ -4,7 +4,6 @@
-
@@ -42,7 +41,7 @@ ]/[domain/]][[#][@|[#]]"); ?>

- diff --git a/templates/dhcp/general.php b/templates/dhcp/general.php index e4023392..49758696 100644 --- a/templates/dhcp/general.php +++ b/templates/dhcp/general.php @@ -3,41 +3,99 @@
- +
+ +
+
+
+
+ + +
+
+
+ +
+
+
+ + +
+

+ +

+
+
+ +
Static IP options
+
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
DHCP options
+
+
+
+
+ + +
+

+ +

+
+
+
+
- +
- +
- +
- + + + +
@@ -45,14 +103,21 @@
- +
- + +
+
+ +
+
+ +
diff --git a/templates/dhcp/logging.php b/templates/dhcp/logging.php index 2a39e236..ce451e6d 100644 --- a/templates/dhcp/logging.php +++ b/templates/dhcp/logging.php @@ -12,9 +12,17 @@
- '.htmlspecialchars($log, ENT_QUOTES).''; - ?> +
+
+ '.htmlspecialchars($log, ENT_QUOTES).''; + } else { + echo ''; + } + ?> +
+
diff --git a/templates/hostapd.php b/templates/hostapd.php index 38b24521..201bd212 100755 --- a/templates/hostapd.php +++ b/templates/hostapd.php @@ -2,11 +2,30 @@ " /> - "/> + " data-toggle="modal" data-target="#hostapdModal"/> "/> - "/> + " data-toggle="modal" data-target="#hostapdModal"/> + + diff --git a/templates/hostapd/advanced.php b/templates/hostapd/advanced.php index 0ee47899..d0559cfe 100644 --- a/templates/hostapd/advanced.php +++ b/templates/hostapd/advanced.php @@ -19,15 +19,6 @@
-
-
-
- - /> - -
-
-
diff --git a/templates/hostapd/logging.php b/templates/hostapd/logging.php index 3c56e69c..fa83395b 100644 --- a/templates/hostapd/logging.php +++ b/templates/hostapd/logging.php @@ -1,15 +1,23 @@

+

hostapd activity.") ?>

+ +
+ + /> + +
+
-
+
'; + echo ''; } else { - echo "
Logfile output not enabled"; + echo ''; } ?>
diff --git a/templates/networking.php b/templates/networking.php index 3d229c9e..bbcb84c5 100755 --- a/templates/networking.php +++ b/templates/networking.php @@ -18,12 +18,6 @@ // defaults to false $bridgedEnabled = $arrHostapdConf['BridgedEnable']; ?> - - - - - -
diff --git a/templates/wifi_stations.php b/templates/wifi_stations.php index bd34246c..176050c4 100755 --- a/templates/wifi_stations.php +++ b/templates/wifi_stations.php @@ -1,6 +1,8 @@ -

-

+
+

+

+