diff --git a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php index 0cc843528..6c42ebf9c 100644 --- a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php +++ b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php @@ -325,10 +325,12 @@ $xml2 = build_xml_templates($strXML); #disable rename if snapshots exist $snapshots = getvmsnapshots($arrConfig['domain']['name']); -if ($snapshots != null && count($snapshots) && !$boolNew) { +if ($snapshots!=null && count($snapshots) && !$boolNew) { + $snaphidden = ""; $namedisable = "disabled"; $snapcount = count($snapshots); } else { + $snaphidden = "hidden"; $namedisable = ""; $snapcount = "0"; } @@ -347,11 +349,16 @@ if ($snapshots != null && count($snapshots) && !$boolNew) {
| + | _(Rename disabled, =$snapcount?> snapshot(s) exists)_. | ++ |
|
- _(Rename disabled, =$snapcount?> snapshot(s) exists.)_
- _(Name contains invalid characters or does not start with an alphanumberic for a ZFS storage location Only these special characters are valid Underscore (_) Hyphen (-) Colon (:) Period (.))_ + _(Name contains invalid characters or does not start with an alphanumberic for a ZFS storage location)_ + _(Only these special characters are valid Underscore (_) Hyphen (-) Colon (:) Period (.))_ |
||
| _(BIOS)_: | - |
@@ -2033,34 +2040,25 @@ function ShareChange(share) { } } -function BusChange(bus) { - var value = bus.value; - var index = bus.name.indexOf("]") + 1; - var name = bus.name.substr(0,index); +function BusChange(value, index) { + $('input[id="disk['+index+'][rotation]"]').removeClass('hidden'); + $('span[id="disk['+index+'][rotatetext]"]').removeClass('hidden'); if (value == "virtio" || value == "usb" ) { - $('#'+name+"[rotatetext]").hide(); - $('#'+name+"[rotation]").hide(); - } else { - $('#'+name+"[rotation]").show(); - $('#'+name+"[rotatetext]").show(); + $('input[id="disk['+index+'][rotation]"]').addClass('hidden'); + $('span[id="disk['+index+'][rotatetext]"]').addClass('hidden'); } } function updateSSDCheck(ssd) { - var value = ssd.value; - var index = ssd.name.indexOf("]") + 1; - var name = ssd.name.substr(0,index); - ssd.value = $('#'+name+"[rotation]").prop('checked') ? "1" : "0"; + ssd.value = $(ssd).prop('checked') ? "1" : "0"; } -function BIOSChange(bios) { - var value = bios.value; +function BIOSChange(value) { + $("#USBBoottext").removeClass('hidden'); + $("#domain_usbboot").removeClass('hidden'); if (value == "0") { - $("#USBBoottext").hide(); - $("#domain_usbboot").hide(); - } else { - $("#USBBoottext").show(); - $("#domain_usbboot").show(); + $("#USBBoottext").addClass('hidden'); + $("#domain_usbboot").addClass('hidden'); } } @@ -2117,17 +2115,19 @@ function SetBootorderfields(usbbootvalue) { /* Remove characters not allowed in share name. */ function checkName(name) { - /* Declare variables at the function scope */ var isValidName - $('#zfs-name').hide(); isValidName = /^[A-Za-z0-9][A-Za-z0-9\-_.: ]*$/.test(name); + $('#zfs-name').removeClass(); if (isValidName) { $('#btnSubmit').prop("disabled",false); + $('#zfs-name').addClass('hidden') } else { if (storageType == "zfs") { - $('#btnSubmit').prop("disabled",true); $('#zfs-name').show(); + $('#btnSubmit').prop("disabled",true); + } else { + $('#btnSubmit').prop("disabled",false); + $('#zfs-name').addClass('hidden') } - else $('#btnSubmit').prop("disabled",false); } } @@ -2151,54 +2151,50 @@ function USBBootChange(usbboot) { } function AutoportChange(autoport) { + $("#port").removeClass('hidden'); + $("#Porttext").removeClass('hidden'); + $("#wsport").removeClass('hidden'); + $("#WSPorttext").removeClass('hidden'); if (autoport.value == "yes") { - $("#port").hide(); - $("#Porttext").hide(); - $("#wsport").hide(); - $("#WSPorttext").hide(); + $("#port").addClass('hidden'); + $("#Porttext").addClass('hidden'); + $("#wsport").addClass('hidden'); + $("#WSPorttext").addClass('hidden'); } else { var protocol = document.getElementById("protocol").value; - $("#port").show(); - $("#Porttext").show(); - if (protocol == "vnc") { - $("#wsport").show(); - $("#WSPorttext").show(); - } else { - $("#wsport").hide(); - $("#WSPorttext").hide(); + if (protocol != "vnc") { + $("#wsport").addClass('hidden'); + $("#WSPorttext").addClass('hidden'); } } } function VMConsoleDriverChange(driver) { + $("#vncrender").removeClass('hidden'); + $("#vncrendertext").removeClass('hidden'); if (driver.value != "virtio3d") { - $("#vncrender").hide(); - $("#vncrendertext").hide(); - } else { - $("#vncrender").show(); - $("#vncrendertext").show(); + $("#vncrender").addClass('hidden'); + $("#vncrendertext").addClass('hidden'); } + $("#vncdspopt").removeClass('hidden'); + $("#vncdspopttext").removeClass('hidden'); if (driver.value != "qxl") { - $("#vncdspopt").hide(); - $("#vncdspopttext").hide(); - } else { - $("#vncdspopt").show(); - $("#vncdspopttext").show(); + $("#vncdspopt").addClass('hidden'); + $("#vncdspopttext").addClass('hidden'); } } function ProtocolChange(protocol) { var autoport = $("#autoport").val(); + $("port").removeClass('hidden'); + $("Porttext").removeClass('hidden'); + $("wsport").removeClass('hidden'); + $("WSPorttext").removeClass('hidden'); if (autoport == "yes") { - $("port").hide(); - $("Porttext").hide(); - $("wsport").hide(); - $("WSPorttext").hide(); - } else { - $("port").show(); - $("Porttext").show(); - $("wsport").show(); - $("WSPorttext").show(); + $("port").addClass('hidden'); + $("Porttext").addClass('hidden'); + $("wsport").addClass('hidden'); + $("WSPorttext").addClass('hidden'); } } @@ -2440,16 +2436,11 @@ $(function() { }); $("#vmform").on("change", ".cpu", function changeCPUEvent(){ - var myvalue = $(this).val(); - var mylabel = $(this).children('option:selected').text(); - var cpumigrate = document.getElementById("domain_cpumigrate_text"); - var cpumigrate_text = document.getElementById("domain_cpumigrate"); - if (myvalue == "custom") { - $("#domain_cpumigrate_text").hide(); - $("#domain_cpumigrate").hide(); - } else { - $("#domain_cpumigrate_text").show(); - $("#domain_cpumigrate").show(); + $("#domain_cpumigrate_text").removeClass('hidden'); + $("#domain_cpumigrate").removeClass('hidden'); + if ($(this).val() == "custom") { + $("#domain_cpumigrate_text").addClass('hidden'); + $("#domain_cpumigrate").addClass('hidden'); } }); @@ -2465,19 +2456,17 @@ $(function() { slideDownRows($vnc_sections.not(isVMAdvancedMode() ? '.basic' : '.advanced')); var MultiSel = document.getElementById("GPUMultiSel0"); MultiSel.disabled = true; - if ($("#vncmodel").val() == "virtio3d") { - $("#vncrender").show(); - $("#vncrendertext").show(); - } else { - $("#vncrender").hide(); - $("#vncrendertext").hide(); + $("#vncrender").removeClass('hidden'); + $("#vncrendertext").removeClass('hidden'); + if ($("#vncmodel").val() != "virtio3d") { + $("#vncrender").addClass('hidden'); + $("#vncrendertext").addClass('hidden'); } - if ($("#vncmodel").val() == "qxl") { - $("#vncdspopt").show(); - $("#vncdspopttext").show(); - } else { - $("#vncdspopt").hide(); - $("#vncdspopttext").hide(); + $("#vncdspopt").removeClass('hidden'); + $("#vncdspopttext").removeClass('hidden'); + if ($("#vncmodel").val() != "qxl") { + $("#vncdspopt").addClass('hidden'); + $("#vncdspopttext").addClass('hidden'); } } else { slideUpRows($vnc_sections); @@ -2486,12 +2475,15 @@ $(function() { if (myvalue=="nogpu") MultiSel.disabled = true; else MultiSel.disabled = false; } } - if (mylabel == "_(None)_") $("#gpubootvga"+myindex).hide(); - if (myvalue != "_(virtual)_" && myvalue != '' && myvalue != "_(nogpu)_") { - if (ValidGPUs[myvalue].bootvga == "1") $("#gpubootvga"+myindex).show(); else $("#gpubootvga"+myindex).hide(); + $("#gpubootvga"+myindex).removeClass(); + if (mylabel == "_(None)_") $("#gpubootvga"+myindex).addClass('hidden'); + if (myvalue != "_(virtual)_" && myvalue != "" && myvalue != "_(nogpu)_") { + if (ValidGPUs[myvalue].bootvga != "1") $("#gpubootvga"+myindex).addClass('hidden'); + } else { + $("#gpubootvga"+myindex).addClass('hidden'); } $romfile = $(this).closest('table').find('.romfile'); - if (myvalue == '_(virtual)_' || myvalue == '' || myvalue =="_(nogpu)_") { + if (myvalue == "_(virtual)_" || myvalue == "" || myvalue == "_(nogpu)_") { slideUpRows($romfile.not(isVMAdvancedMode() ? '.basic' : '.advanced')); $romfile.filter('.advanced').removeClass('advanced').addClass('wasadvanced'); } else { @@ -2642,13 +2634,13 @@ $(function() { $panel.find('input').prop('disabled', true); $button.val($button.attr('busyvalue')); swal({ - title: '_(Template Name)_', - text: "_(Enter name:\nIf name already exists it will be replaced.)_", + title: "_(Template Name)_", + text: "_(Enter name)_:\n_(If name already exists it will be replaced)_.", type: "input", showCancelButton: true, closeOnConfirm: false, //animation: "slide-from-top", - inputPlaceholder: "_(Leaving blank will use OS name.)_" + inputPlaceholder: "_(Leaving blank will use OS name)_." }, function(inputValue) { postdata=postdata+"&templatename="+inputValue; @@ -2710,12 +2702,12 @@ $(function() { $button.val($button.attr('busyvalue')); swal({ title: "_(Template Name)_", - text: "_(Enter name:\nIf name already exists it will be replaced.)_", + text: "_(Enter name)_:\n_(If name already exists it will be replaced)_.", type: "input", showCancelButton: true, closeOnConfirm: false, //animation: "slide-from-top", - inputPlaceholder: "_(Leaving blank will use OS name.)_" + inputPlaceholder: "_(Leaving blank will use OS name)_." }, function(inputValue) { postdata=postdata+"&templatename="+inputValue; diff --git a/emhttp/plugins/dynamix/ArrayOperation.page b/emhttp/plugins/dynamix/ArrayOperation.page index 6c59f0fd6..c4682f30a 100644 --- a/emhttp/plugins/dynamix/ArrayOperation.page +++ b/emhttp/plugins/dynamix/ArrayOperation.page @@ -48,6 +48,7 @@ function check_encryption() { echo ""; echo " ",_('Retype passphrase'),": "; } + function maintenance_mode() { echo " ",_('Keyfile'),": "; echo " "; } + function status_indicator() { global $var; switch (_var($var,'mdColor')) { @@ -65,15 +67,18 @@ function status_indicator() { } echo "$help"; } + function missing_cache() { global $disks; $missing = false; foreach (cache_filter($disks) as $disk) $missing |= (strpos(_var($disk,'status'),'_MISSING')!==false); return $missing; } + function resync($d) { return in_array($d,['P','Q']) ? 'Parity-Sync' : 'Data-Rebuild'; } + function print_error($error) { return sprintf(_('Finding **%s** error'.($error==1?'':'s')),$error?:'0'); } @@ -111,6 +116,7 @@ function toggle_state(device,name,action) { devices.stop(); $.post('/webGui/include/ToggleState.php',{device:device,name:name,action:action},function(){setTimeout(function(){devices.start();},1000);if (button) $(button).prop('disabled',false);}); } + function display_diskio() { if ($.cookie('diskio')===undefined) { $('span.diskio').show(); $('span.number').hide(); @@ -118,20 +124,25 @@ function display_diskio() { $('span.number').show(); $('span.diskio').hide(); } } + function toggle_diskio(init) { if (!init) { if ($.cookie('diskio')===undefined) $.cookie('diskio','diskio',{expires:3650}); else $.removeCookie('diskio'); } if ($.cookie('diskio')===undefined) { $('i.toggle').removeClass('fa-list').addClass('fa-tachometer'); + $('#clearstats').addClass('hidden'); } else { $('i.toggle').removeClass('fa-tachometer').addClass('fa-list'); + $('#clearstats').removeClass('hidden'); } display_diskio(); } + function base64(str) { return window.btoa(unescape(encodeURIComponent(str))); } + function selectInput(form) { form.input.value = 'file'; @@ -175,12 +186,14 @@ function selectInput(form) { item.prop('disabled',!form.file.value); } } + function getFileContent(event,form) { var input = event.target; var reader = new FileReader(); reader.onload = function(){form.file.value=reader.result;selectInput(form);}; reader.readAsDataURL(input.files[0]); } + function prepareInput(form,button) { if (button) button.disabled = true; $.post('/webGui/include/Report.php',{cmd:'state',pools:'=implode(',',$pools)?>'},function(state) { @@ -220,6 +233,7 @@ function prepareInput(form,button) { } }); } + function parityWarning(form) { if (form.md_invalidslot.checked) { @@ -232,10 +246,12 @@ function parityWarning(form) { } swal({title:"_(Proceed to start)_",text:text,html:true,type:'warning',showCancelButton:true,confirmButtonText:"_(Proceed)_",cancelButtonText:"_(Cancel)_"},function(){prepareInput(form);}); } + function tab0() { $.removeCookie('one'); $.cookie('tab','tab0'); } + function stopArray(form) { $(form).append(''); @@ -244,6 +260,7 @@ function stopArray(form) { form.submit(); } + function stopParity(form,text) { $(form).append(''); @@ -252,6 +269,7 @@ function stopParity(form,text) { form.submit(); } + function pauseParity(form) { $.post('/webGui/include/ParityControl.php',{action:'pause'},function(){ $('#pauseButton').val("_(Resume)_").prop('disabled',true).prop('onclick',null).off('click').click(function(){resumeParity(form);}); @@ -259,6 +277,7 @@ function pauseParity(form) { form.submit(); }); } + function resumeParity(form) { $.post('/webGui/include/ParityControl.php',{action:'resume'},function(){ $('#pauseButton').val("_(Pause)_").prop('disabled',true).prop('onclick',null).off('click').click(function(){pauseParity(form);}); @@ -266,9 +285,11 @@ function resumeParity(form) { form.submit(); }); } + function parityHistory() { openChanges("parity_history", "_(Parity Operation History)_", "phistory"); } + function shutdown_now(form,cmd) { $(form).append(''); @@ -281,9 +302,11 @@ function shutdown_now(form,cmd) { form.submit(); } + function toggleApply(checked) { $('input[name="#apply"]').prop('disabled',!checked); } + $('.tabs').append(ctrl); if ($.cookie('tab')=='tab0') $('i.toggle').hide(); @@ -292,7 +315,6 @@ $('#tab'+$('input[name$="tabs"]').length).click(function(){tab0(); $('i.toggle') $('div[class=title]:not(":last, .disable_diskio")').each(function(){$(this).append(ctrl);}); $('.tooltip_diskio').tooltipster({delay:100,trigger:'custom',triggerOpen:{mouseenter:true},triggerClose:{click:false,scroll:true,mouseleave:true}}); -toggle_diskio(true); var mymonitor = new NchanSubscriber('/sub/mymonitor',{subscriber:'websocket'}); @@ -422,7 +444,9 @@ setTimeout(function(){paritymonitor.start();},5000); $(function(){ var form = document.arrayOps; if (form.input !== undefined) selectInput(form); + toggle_diskio(true); }); + function formatWarning(val) { if (val==true) { swal({ @@ -720,7 +744,7 @@ endswitch;"; @@ -55,6 +56,7 @@ function maintenance_mode() { echo " ",_('Maintenance mode')," - ",_('if checked, Start array but do not mount disks')," "; echo "diff --git a/emhttp/plugins/dynamix/Wireless.page b/emhttp/plugins/dynamix/Wireless.page index 07cff7675..c2da55b00 100644 --- a/emhttp/plugins/dynamix/Wireless.page +++ b/emhttp/plugins/dynamix/Wireless.page @@ -64,24 +64,24 @@ function enable_wifi(state) { $('input[name="#arg[1]"]').val(state); } -function update_wifi() { - $.post('/webGui/include/Wireless.php',{cmd:'list'},function(text) { +function update_wifi(load) { + $.post('/webGui/include/Wireless.php',{cmd:'list',load:load},function(text) { if (text.length > 0) { var wifi = JSON.parse(text); $('#connected').html(wifi.active); $('#my_networks').html(wifi.saved); - $('#other_networks').html(wifi.other); + if (wifi.other.length) $('#other_networks').html(wifi.other); } }); - timers.wifi = setTimeout(update_wifi,10000); + timers.wifi = setTimeout(update_wifi,6000); } function manage_wifi(ssid,task) { if (task==2) { + clearTimeout(timers.wifi); $.post('/webGui/include/Wireless.php',{cmd:'forget',ssid:ssid},function(){ - clearTimeout(timers.wifi); swal.close(); - setTimeout(update_wifi); + setTimeout(function(){update_wifi(1);}); }); return; } @@ -146,7 +146,7 @@ function showSecurity(val) { $(function() { $('#wifi').show(); - update_wifi(); + update_wifi(1); }); diff --git a/emhttp/plugins/dynamix/include/NetworkInfo.php b/emhttp/plugins/dynamix/include/NetworkInfo.php index 186e1ff50..0c9d33891 100644 --- a/emhttp/plugins/dynamix/include/NetworkInfo.php +++ b/emhttp/plugins/dynamix/include/NetworkInfo.php @@ -23,50 +23,51 @@ if (isset($_POST['listen'])) { function port($eth) { $sys = "/sys/class/net"; if (substr($eth,0,4)=='wlan') return $eth; - $x = preg_replace('/[^0-9]/','',$eth); - return file_exists("$sys/br{$x}") ? "br${x}" : (file_exists("$sys/bond{$x}") ? "bond{$x}" : "eth{$x}"); + $x = preg_replace('/[^0-9]/','',$eth) ?: '0'; + return file_exists("$sys/br{$x}") ? "br{$x}" : (file_exists("$sys/bond{$x}") ? "bond{$x}" : "eth{$x}"); } exec("grep -Po 'nameserver \K\S+' /etc/resolv.conf 2>/dev/null",$ns); -$eth = $_POST['port']; -$vlan = $_POST['vlan']; +$eth = $_POST['port'] ?? ''; +$vlan = $_POST['vlan'] ?? ''; +$wlan0 = $eth == 'wlan0'; $port = port($eth).($vlan ? ".$vlan" : ""); $v6on = trim(file_get_contents("/proc/sys/net/ipv6/conf/$port/disable_ipv6"))==='0'; $none = _('None'); $error = ""._('Missing').""; $note = in_array($eth,['eth0','wlan0']) && !$vlan ? $error : $none; -$link = _(ucfirst(exec("ethtool $eth 2>/dev/null | awk '$1==\"Link\" {print $3;exit}'")) ?: 'Unknown')." ("._(exec("ethtool $eth 2>/dev/null | grep -Pom1 '^\s+Port: \K.*'") ?: ($eth=='wlan0' ? 'wifi' :'not present')).")"; -$speed = _(preg_replace(['/^(\d+)/','/!/'],['$1 ',''],exec("ethtool $eth 2>/dev/null | awk '$1==\"Speed:\" {print $2;exit}'")) ?: 'Unknown'); -$ipv4 = array_filter(explode(' ',exec("ip -4 -br addr show $port scope global 2>/dev/null | awk '{\$1=\$2=\"\";print;exit}' | sed -r 's/ metric [0-9]+//g; s/\/[0-9]+//g'"))); -$gw4 = exec("ip -4 route show default dev $port 2>/dev/null | awk '{print \$3;exit}'") ?: $note; +$ipv4 = array_filter(explode(' ',exec("ip -4 -br addr show ".escapeshellarg($port)." scope global 2>/dev/null | awk '{\$1=\$2=\"\";print;exit}' | sed -r 's/ metric [0-9]+//g; s/\/[0-9]+//g'"))); +$gw4 = exec("ip -4 route show default dev ".escapeshellarg($port)." 2>/dev/null | awk '{print \$3;exit}'") ?: $note; $dns4 = array_filter($ns,function($ns){return strpos($ns,':')===false;}); $domain = exec("grep -Pom1 'domain \K.*' /etc/resolv.conf 2>/dev/null") ?: '---'; if ($v6on) { - $ipv6 = array_filter(explode(' ',exec("ip -6 -br addr show $port scope global -temporary 2>/dev/null | awk '{\$1=\$2=\"\";print;exit}' | sed -r 's/ metric [0-9]+//g; s/\/[0-9]+//g'"))); - $gw6 = exec("ip -6 route show default dev $port 2>/dev/null | awk '{print \$3;exit}'") ?: $note; + $ipv6 = array_filter(explode(' ',exec("ip -6 -br addr show ".escapeshellarg($port)." scope global -temporary 2>/dev/null | awk '{\$1=\$2=\"\";print;exit}' | sed -r 's/ metric [0-9]+//g; s/\/[0-9]+//g'"))); + $gw6 = exec("ip -6 route show default dev ".escapeshellarg($port)." 2>/dev/null | awk '{print \$3;exit}'") ?: $note; $dns6 = array_filter($ns,function($ns){return strpos($ns,':')!==false;}); } echo "
- **_(Spin Up)_** _(will immediately spin up all disks)_.
**_(Spin Down)_** _(will immediately spin down all disks)_.+ **_(Clear Stats)_** _(will immediately clear all disk statistics)_. **_(Clear Stats)_** _(will immediately clear all disk statistics)_. "; echo "
"; -echo " "; -echo " "._('Interface link').": $link "; -if ($eth=='wlan0') { - $ini = '/boot/config/wireless-networks.cfg'; - $wifi = (array)@parse_ini_file($ini,true); - $att1 = $att2 = $att3 = ''; - foreach ($wifi as $network => $option) { - if (isset($option['GROUP']) && $option['GROUP']=='active') { - $att1 = $network; - $att2 = $option['ATTR2']; - $att3 = $option['ATTR3']; - break; - } +if ($wlan0) { + exec("iw wlan0 link | awk '/^\s+(SSID|signal|[rt]x bitrate): /{print $1,$2,$3,$4}'",$speed); + if (count($speed)==4) { + $network = explode(': ',$speed[0])[1]; + $signal = explode(': ',$speed[1])[1]; + $rxrate = explode(': ',$speed[2])[1]; + $txrate = explode(': ',$speed[3])[1]; + } else { + $network = $signal = $rxrate = $txrate = _('Unknown'); } - if ($att1) echo " "._('Interface speed').": $speed "; - if ($att2) echo " "._('Network').": $att1 "; - if ($att3) echo " "._('Health').": $att2 "; + echo " "._('Security').": $att3 "; + echo " "._('Network name').": $network "; + echo " "._('Signal level').": $signal "; + echo " "._('Receive bitrate').": $rxrate "; +} else { + $link = _(ucfirst(exec("ethtool ".escapeshellarg($eth)." 2>/dev/null | awk '$1==\"Link\" {print $3;exit}'")) ?: 'Unknown')." ("._(exec("ethtool ".escapeshellarg($eth)." 2>/dev/null | grep -Pom1 '^\s+Port: \K.*'") ?: 'not present').")"; + $speed = _(preg_replace(['/^(\d+)/','/!/'],['$1 ',''],exec("ethtool ".escapeshellarg($eth)." 2>/dev/null | awk '$1==\"Speed:\" {print $2;exit}'")) ?: 'Unknown'); + echo " "._('Transmit bitrate').": $txrate "; + echo " "._('Interface link').": $link "; } if (count($ipv4)) foreach ($ipv4 as $ip) { echo " "._('Interface speed').": $speed "; diff --git a/emhttp/plugins/dynamix/include/RoutingTable.php b/emhttp/plugins/dynamix/include/RoutingTable.php index 7908083f5..2bfa73efb 100644 --- a/emhttp/plugins/dynamix/include/RoutingTable.php +++ b/emhttp/plugins/dynamix/include/RoutingTable.php @@ -27,7 +27,7 @@ case 'Add Route': break; default: exec("ip -4 route show table all|grep -Pv '^(127\\.0\\.0\\.0)|table local|unreachable'",$ipv4); - exec("ip -6 route show table all|grep -Pv '^([am:]|(f[ef][0-9][0-9])::)|expires|table local|unreachable'",$ipv6); + exec("ip -6 route show table all|grep -Pv '^([am:]|(f[ef][0-9][0-9])::)|table local|unreachable'",$ipv6); foreach ($ipv4 as $info) { $cell = explode(' ',$info); $route = $cell[0]; diff --git a/emhttp/plugins/dynamix/include/Wireless.php b/emhttp/plugins/dynamix/include/Wireless.php index 54e82c1a8..77a5b0099 100644 --- a/emhttp/plugins/dynamix/include/Wireless.php +++ b/emhttp/plugins/dynamix/include/Wireless.php @@ -20,7 +20,7 @@ $tmp = '/var/tmp/attr'; $wifi = is_readable($cfg) ? (array)parse_ini_file($cfg,true) : []; $attr = is_readable($tmp) ? (array)parse_ini_file($tmp,true) : []; $md5 = md5(json_encode($attr),true); -$cmd = $_POST['cmd']; +$cmd = $_POST['cmd'] ?? ''; $masks = [ '255.0.0.0' => '8', '255.255.0.0' => '16', '255.255.128.0' => '17', '255.255.192.0' => '18', '255.255.224.0' => '19', '255.255.240.0' => '20', '255.255.248.0' => '21', '255.255.252.0' => '22', @@ -74,14 +74,27 @@ function saveAttr() { switch ($cmd) { case 'list': + $load = $_POST['load'] ?? false; $title = _('Connect to WiFi network'); $port = array_key_first($wifi); $carrier = "/sys/class/net/$port/carrier"; - $wlan = scanWifi($port); $echo = []; $index = 0; + if ($load && count(array_keys($wifi)) > 1) { + foreach ($wifi as $network => $block) { + if ($network == $port) continue; + $wlan[$index]['bss'] = $block['ATTR1']; + $wlan[$index]['signal'] = $block['ATTR2']; + $wlan[$index]['security'] = $block['ATTR3'] ?? $block['SECURITY']; + $wlan[$index]['ssid'] = $network; + $index++; + } + $index = 0; + } else { + $wlan = scanWifi($port); + } if (count(array_column($wlan,'ssid'))) { - $up = file_exists($carrier) && file_get_contents($carrier)==1; + $up = is_readable($carrier) && file_get_contents($carrier)==1; $alive = $up ? exec("iw ".escapeshellarg($port)." link 2>/dev/null | grep -Pom1 'SSID: \K.+'") : ''; $state = $up ? _('Connected') : _('Disconnected'); $color = $up ? 'blue' : 'red'; @@ -106,7 +119,7 @@ case 'list': } if (empty($echo['active'])) $echo['active'][] = " "._('IPv4 address').": $ip
- "._('Connected').":
- "._('None')."
"; if (empty($echo['saved'])) $echo['saved'][] = "
- "._('My networks').":
- "._('None')."
"; - if (empty($echo['other'])) $echo['other'][] = "
- "._('Other networks').":
- "._('None')."
"; + if (empty($echo['other'])) $echo['other'][] = $load ? "" : "
- "._('Other networks').":
- "._('None')."
"; $echo['active'] = implode($echo['active']); $echo['saved'] = implode($echo['saved']); $echo['other'] = implode($echo['other']); @@ -133,7 +146,7 @@ case 'join': $dns6 = _var($wifi[$ssid],'DNS6','no'); $ip6 = _var($wifi[$ssid],'IP6'); $mask6 = _var($wifi[$ssid],'MASK6','64'); - $gwv6 = _var($wifi[$ssid],'GATEWAY6'); + $gw6 = _var($wifi[$ssid],'GATEWAY6'); $server6 = _var($wifi[$ssid],'SERVER6'); $safe = _var($wifi[$ssid],'SECURITY'); $attr1 = $attr[$ssid]['ATTR1']; diff --git a/emhttp/plugins/dynamix/include/Wrappers.php b/emhttp/plugins/dynamix/include/Wrappers.php index 157ae7139..1878f7793 100644 --- a/emhttp/plugins/dynamix/include/Wrappers.php +++ b/emhttp/plugins/dynamix/include/Wrappers.php @@ -270,6 +270,6 @@ function check_network_connectivity(): bool { function lan_port($port, $state=false) { $system = '/sys/class/net'; $exist = file_exists("$system/$port"); - return !$state ? $exist : ($exist ? file_get_contents("$system/$port/carrier") : false); + return !$state ? $exist : ($exist ? (@file_get_contents("$system/$port/carrier") ?: 0) : false); } ?> diff --git a/emhttp/plugins/dynamix/nchan/wlan0 b/emhttp/plugins/dynamix/nchan/wlan0 index 543086726..5ec3e1b08 100755 --- a/emhttp/plugins/dynamix/nchan/wlan0 +++ b/emhttp/plugins/dynamix/nchan/wlan0 @@ -53,10 +53,12 @@ while (true) { $locale_init = _var($display,'locale'); update_translation($locale_init); } - if (file_exists($ini) && file_exists($wlan0)) { + if (is_readable($ini) && is_readable($wlan0)) { + $wifi = parse_ini_file($ini); $up = file_get_contents($wlan0)==1; - $echo['color'] = $up ? 'blue-text' : 'red-text'; - $echo['title'] = $up ? _('WiFi connected') : _('WiFi disconnected'); + $alive = $up ? exec("iw wlan0 link 2>/dev/null | grep -Pom1 'SSID: \K.+'") : ''; + $echo['color'] = $alive==$wifi['SSID'] ? 'blue-text' : 'red-text'; + $echo['title'] = $alive==$wifi['SSID'] ? _('WiFi connected') : _('WiFi disconnected'); } else { $echo['color'] = 'grey-text'; $echo['title'] = _('No active WiFi'); diff --git a/emhttp/plugins/dynamix/scripts/netconfig b/emhttp/plugins/dynamix/scripts/netconfig index 1f0879134..81d12d4ab 100755 --- a/emhttp/plugins/dynamix/scripts/netconfig +++ b/emhttp/plugins/dynamix/scripts/netconfig @@ -26,7 +26,7 @@ $cfg = '/boot/config/network.cfg'; function port($x) { $sys = "/sys/class/net"; - return file_exists("$sys/br{$x}") ? "br${x}" : (file_exists("$sys/bond{$x}") ? "bond{$x}" : "eth{$x}"); + return file_exists("$sys/br{$x}") ? "br{$x}" : (file_exists("$sys/bond{$x}") ? "bond{$x}" : "eth{$x}"); } function update_wireguard($ifname) { diff --git a/emhttp/plugins/dynamix/scripts/notify b/emhttp/plugins/dynamix/scripts/notify index cbf0c0fb8..8a5adc246 100755 --- a/emhttp/plugins/dynamix/scripts/notify +++ b/emhttp/plugins/dynamix/scripts/notify @@ -211,9 +211,9 @@ case 'add': $noBrowser = true; break; case 'l': - $nginx = parse_ini_file('/var/local/emhttp/nginx.ini'); + $nginx = (array)@parse_ini_file('/var/local/emhttp/nginx.ini'); $link = $value; - $fqdnlink = (strpos($link,"http") === 0) ? $link : $nginx['NGINX_DEFAULTURL'].$link; + $fqdnlink = (strpos($link,"http") === 0) ? $link : ($nginx['NGINX_DEFAULTURL']??'').$link; break; } } diff --git a/emhttp/plugins/dynamix/scripts/wireless b/emhttp/plugins/dynamix/scripts/wireless index 2b522f62f..ca72260a3 100755 --- a/emhttp/plugins/dynamix/scripts/wireless +++ b/emhttp/plugins/dynamix/scripts/wireless @@ -28,10 +28,10 @@ if ($arg == 'yes') { } elseif ($arg == 'no') { exec("/etc/rc.d/rc.wireless stop"); exec("$docroot/webGui/scripts/update_services 5"); -} else { +} elseif (($wifi['wlan0']['WIFI']??'') == 'yes') { foreach ($wifi as $network => $block) { if ($network == $port) continue; - if ($block['GROUP'] == $state && (!$arg || $arg == $network)) { + if (($block['GROUP']??'') == $state && (!$arg || $arg == $network)) { $text[] = "SSID=\"$network\""; unset($block['GROUP']); foreach ($block as $key => $value) $text[] = "$key=\"$value\""; diff --git a/emhttp/plugins/dynamix/sheets/ArrayOperation.css b/emhttp/plugins/dynamix/sheets/ArrayOperation.css index 938141281..184e8de9c 100644 --- a/emhttp/plugins/dynamix/sheets/ArrayOperation.css +++ b/emhttp/plugins/dynamix/sheets/ArrayOperation.css @@ -3,3 +3,4 @@ td.gap{padding-left:26px!important} td.wrap{white-space:normal!important} span#pass{display:none;margin-left:20px} input[type=checkbox]{margin-left:0} +.hidden{display:none} \ No newline at end of file diff --git a/etc/rc.d/rc.docker b/etc/rc.d/rc.docker index b633c9352..c86d8c1a3 100755 --- a/etc/rc.d/rc.docker +++ b/etc/rc.d/rc.docker @@ -438,7 +438,7 @@ docker_network_start(){ if [[ $DOCKER_ALLOW_ACCESS == yes && -n $IPV4 ]]; then # create shim interface and copy parent IPv4 address to shim interface [[ -e $SYSTEM/$LINK ]] || run ip link add link $NETWORK name $LINK type $ATTACH mode $MODE - run ip addr flush dev $LINK + run ip addr flush dev $LINK scope global run ip -4 addr add $IPV4 dev $LINK metric 0 # disable IPv6 on shim interface echo 1 >$CONF6/$LINK/disable_ipv6 @@ -464,13 +464,19 @@ docker_network_start(){ fi elif [[ $TYPE != wlan ]]; then if [[ $DOCKER_ALLOW_ACCESS == yes && -n $IPV4 ]]; then - run ip addr flush dev $VHOST + run ip addr flush dev $VHOST scope global # copy IPv4 address to vhost interface run ip -4 addr add $IPV4 dev $VHOST metric 0 log "prepared network $VHOST for host access" - elif [[ -e $SYSTEM/$VHOST ]]; then - # remove IP addresses - run ip addr flush dev $VHOST + else + VHOST=vhost${NETWORK//[^0-9.]/} + if [[ -e $SYSTEM/$VHOST ]]; then + # remove IP addresses of vhost + run ip addr flush dev $VHOST scope global + # remove routing of vhost + run ip -4 route flush dev $VHOST + run ip -6 route flush dev $VHOST + fi fi fi fi