diff --git a/emhttp/plugins/dynamix/Browse.page b/emhttp/plugins/dynamix/Browse.page index 1d18c2a97..9f9ca88dd 100644 --- a/emhttp/plugins/dynamix/Browse.page +++ b/emhttp/plugins/dynamix/Browse.page @@ -488,7 +488,7 @@ function doAction(action, title, id) { case 4: // move folder case 9: // move file // disallow mixing of disk and user shares - var valid = ud ? /^\/mnt\/.+/ : (user ? /^\/mnt\/(user0?|rootshare)\/.+/ : /^\/mnt\/(?!.*(user0?|rootshare)).+$|^\/boot\/.+/); + var valid = ud ? /^\/mnt\/.+/ : (user ? /^\/mnt\/(user0?|disks|remotes)\/.+/ : /^\/mnt\/(?!.*(user0?|rootshare)\/).+$|^\/boot\/.+/); // check if 'mv' can be used if (path.length > 2) { if (user) { @@ -520,7 +520,7 @@ function doAction(action, title, id) { break; default: // disallow mixing of disk and user shares - var valid = ud ? /^\/mnt\/.+/ : (user ? /^\/mnt\/(user0?|rootshare)\/.+/ : /^\/mnt\/(?!.*(user0?|rootshare)).+$|^\/boot\/.+/); + var valid = ud ? /^\/mnt\/.+/ : (user ? /^\/mnt\/(user0?|disks|remotes)\/.+/ : /^\/mnt\/(?!.*(user0?|rootshare)\/).+$|^\/boot\/.+/); break; } if (!target || !valid.test(target)) {errorTarget(); return;} @@ -558,7 +558,7 @@ function doAction(action, title, id) { case 4: // move folder case 9: // move file // disallow mixing of disk and user shares - var valid = ud ? /^\/mnt\/.+/ : (user ? /^\/mnt\/(user0?|rootshare)\/.+/ : /^\/mnt\/(?!.*(user0?|rootshare)).+$|^\/boot\/.+/); + var valid = ud ? /^\/mnt\/.+/ : (user ? /^\/mnt\/(user0?|disks|remotes)\/.+/ : /^\/mnt\/(?!.*(user0?|rootshare)\/).+$|^\/boot\/.+/); // check if 'mv' can be used if (path.length > 2) { if (user) { @@ -583,7 +583,7 @@ function doAction(action, title, id) { break; default: // disallow mixing of disk and user shares - var valid = ud ? /^\/mnt\/.+/ : (user ? /^\/mnt\/(user0?|rootshare)\/.+/ : /^\/mnt\/(?!.*(user0?|rootshare)).+$|^\/boot\/.+/); + var valid = ud ? /^\/mnt\/.+/ : (user ? /^\/mnt\/(user0?|disks|remotes)\/.+/ : /^\/mnt\/(?!.*(user0?|rootshare)\/).+$|^\/boot\/.+/); break; } if (!target || !valid.test(target)) {errorTarget(); return;} @@ -767,7 +767,7 @@ function doActions(action, title) { break; case 4: // move object // disallow mixing of disk and user shares - var valid = ud ? /\/mnt\/.+/ : (user ? /^\/mnt\/(user0?|rootshare)\/.+/ : /^\/mnt\/(?!.*(user0?|rootshare)).+$|^\/boot\/.+/); + var valid = ud ? /^\/mnt\/.+/ : (user ? /^\/mnt\/(user0?|disks|remotes)\/.+/ : /^\/mnt\/(?!.*(user0?|rootshare)\/).+$|^\/boot\/.+/); // check if 'mv' can be used if (path.length > 2) { if (user) { @@ -801,7 +801,7 @@ function doActions(action, title) { break; default: // disallow mixing of disk and user shares - var valid = ud ? /\/mnt\/.+/ : (user ? /^\/mnt\/(user0?|rootshare)\/.+/ : /^\/mnt\/(?!.*(user0?|rootshare)).+$|^\/boot\/.+/); + var valid = ud ? /^\/mnt\/.+/ : (user ? /^\/mnt\/(user0?|disks|remotes)\/.+/ : /^\/mnt\/(?!.*(user0?|rootshare)\/).+$|^\/boot\/.+/); break; } if (!target || !valid.test(target)) {errorTarget(); return;} @@ -839,7 +839,7 @@ function doActions(action, title) { break; case 4: // move object // disallow mixing of disk and user shares - var valid = ud ? /\/mnt\/.+/ : (user ? /^\/mnt\/(user0?|rootshare)\/.+/ : /^\/mnt\/(?!.*(user0?|rootshare)).+$|^\/boot\/.+/); + var valid = ud ? /^\/mnt\/.+/ : (user ? /^\/mnt\/(user0?|disks|remotes)\/.+/ : /^\/mnt\/(?!.*(user0?|rootshare)\/).+$|^\/boot\/.+/); // check if 'mv' can be used if (path.length > 2) { if (user) { @@ -866,7 +866,7 @@ function doActions(action, title) { break; default: // disallow mixing of disk and user shares - var valid = ud ? /\/mnt\/.+/ : (user ? /^\/mnt\/(user0?|rootshare)\/.+/ : /^\/mnt\/(?!.*(user0?|rootshare)).+$|^\/boot\/.+/); + var valid = ud ? /^\/mnt\/.+/ : (user ? /^\/mnt\/(user0?|disks|remotes)\/.+/ : /^\/mnt\/(?!.*(user0?|rootshare)\/).+$|^\/boot\/.+/); break; } if (!target || !valid.test(target)) {errorTarget(); return;} diff --git a/emhttp/plugins/dynamix/include/Browse.php b/emhttp/plugins/dynamix/include/Browse.php index 1e58d5811..4486f04bf 100644 --- a/emhttp/plugins/dynamix/include/Browse.php +++ b/emhttp/plugins/dynamix/include/Browse.php @@ -25,18 +25,18 @@ function write(&$rows) { function validdir($dir) { $path = realpath($dir); - return in_array(explode('/',$path)[1]??'',['mnt','boot']) ? $path : ''; + return in_array(explode('/', $path)[1] ?? '', ['mnt','boot']) ? $path : ''; } function escapeQuote($data) { - return str_replace('"','"',$data); + return str_replace('"','"', $data); } function add($number, $name, $single='', $plural='s') { return $number.' '._($name.($number==1 ? $single : $plural)); } -function age($number,$time) { +function age($number, $time) { return sprintf(_('%s '.($number==1 ? $time : $time.'s').' ago'),$number); } @@ -44,25 +44,25 @@ function my_age($time) { if (!is_numeric($time)) $time = time(); $age = new DateTime('@'.$time); $age = date_create('now')->diff($age); - if ($age->y > 0) return age($age->y,'year'); - if ($age->m > 0) return age($age->m,'month'); - if ($age->d > 0) return age($age->d,'day'); - if ($age->h > 0) return age($age->h,'hour'); - if ($age->i > 0) return age($age->i,'minute'); - return age($age->s,'second'); + if ($age->y > 0) return age($age->y, 'year'); + if ($age->m > 0) return age($age->m, 'month'); + if ($age->d > 0) return age($age->d, 'day'); + if ($age->h > 0) return age($age->h, 'hour'); + if ($age->i > 0) return age($age->i, 'minute'); + return age($age->s, 'second'); } function parent_link() { - global $dir,$path; + global $dir, $path; $parent = dirname($dir); - return $parent=='/' ? false : ''._('Parent Directory').''; + return $parent == '/' ? false : ''._('Parent Directory').''; } function my_devs(&$devs,$name,$menu) { - global $disks,$lock; + global $disks, $lock; $text = []; $i = 0; foreach ($devs as $dev) { - if ($lock=='---') { + if ($lock == '---') { $text[$i] = ' ---'; } else { switch ($disks[$dev]['luksState']??0) { @@ -72,7 +72,7 @@ function my_devs(&$devs,$name,$menu) { case 3: $text[$i] = ''._('Locked: wrong encryption key').''; break; default: $text[$i] = ''._('Locked: unknown error').''; break; } - $root = $dev=='flash' ? "/boot/$name" : "/mnt/$dev/$name"; + $root = ($dev == 'flash' ? "/boot/$name" : "/mnt/$dev/$name"); $text[$i] .= ''.compress($dev,11,0).''; } $i++; @@ -141,8 +141,8 @@ $path = unscript($_GET['path']); $fmt = "%F {$display['time']}"; $dirs = $files = []; $total = $objs = 0; -[$null,$root,$main,$next,$rest] = my_explode('/',$dir,5); -$user = $root=='mnt' && in_array($main,['user','user0']); +[$null,$root,$main,$next,$rest] = my_explode('/', $dir, 5); +$user = $root=='mnt' && in_array($main, ['user','user0']); $lock = $root=='mnt' ? ($main ?: '---') : ($root=='boot' ? _('flash') : '---'); $ishare = $root=='mnt' && (!$main || !$next || ($main=='rootshare' && !$rest)); $folder = $lock=='---' ? _('DEVICE') : ($ishare ? _('SHARE') : _('FOLDER')); @@ -154,13 +154,14 @@ if ($user ) { } $stat = popen("shopt -s dotglob;stat -L -c'%F|%U|%A|%s|%Y|%n' ".escapeshellarg($dir)."/* 2>/dev/null",'r'); -while (($row = fgets($stat))!==false) { + +while (($row = fgets($stat)) !== false) { [$type,$owner,$perm,$size,$time,$name] = explode('|',rtrim($row,"\n"),6); - $dev = explode('/',$name,5); - $devs = explode(',',$user ? $set[basename($name)]??$shares[$dev[3]]['cachePool']??'' : $lock); + $dev = explode('/', $name, 5); + $devs = explode(',', $user ? $set[basename($name)] ?? $shares[$dev[3]]['cachePool'] ?? '' : $lock); $objs++; $text = []; - if ($type[0]=='d') { + if ($type[0] == 'd') { $text[] = ''; $text[] = ''; $text[] = ''.htmlspecialchars(basename($name)).''; @@ -172,8 +173,8 @@ while (($row = fgets($stat))!==false) { $text[] = '...'; $dirs[] = gzdeflate(implode($text)); } else { - $ext = strtolower(pathinfo($name,PATHINFO_EXTENSION)); - $tag = count($devs)>1 ? 'warning' : ''; + $ext = strtolower(pathinfo($name, PATHINFO_EXTENSION)); + $tag = count($devs) > 1 ? 'warning' : ''; $text[] = ''; $text[] = ''; $text[] = ''.htmlspecialchars(basename($name)).''; @@ -189,6 +190,7 @@ while (($row = fgets($stat))!==false) { } pclose($stat); + if ($link = parent_link()) echo '',$link,''; echo write($dirs),write($files),'',add($objs,'object'),': ',add($dirs,'director','y','ies'),', ',add($files,'file'),' (',my_scale($total,$unit),' ',$unit,' ',_('total'),')'; ?> diff --git a/emhttp/plugins/dynamix/include/FileTree.php b/emhttp/plugins/dynamix/include/FileTree.php index 377b6657f..010aa5712 100644 --- a/emhttp/plugins/dynamix/include/FileTree.php +++ b/emhttp/plugins/dynamix/include/FileTree.php @@ -9,6 +9,7 @@ * * History: * + * 1.2.2 - allow user shares to UD shares * 1.2.1 - exclude folders from the /mnt/ root folder * 1.2.0 - adapted by Bergware for use in Unraid - support UTF-8 encoding & hardening * 1.1.1 - SECURITY: forcing root to prevent users from determining system's file structure (per DaveBrad) @@ -29,13 +30,19 @@ function path($dir) { return mb_substr($dir,-1) == '/' ? $dir : $dir.'/'; } + function is_top($dir) { global $root; return mb_strlen($dir) > mb_strlen($root); } -function is_low($dir) { - global $root; - return mb_substr($dir,0,mb_strlen($root)) == $root; + +function no_dots($name) { + return !in_array($name, ['.','..']); +} + +function my_dir($name) { + global $rootdir, $userdir, $topdir, $UDincluded; + return ($rootdir === $userdir && in_array($name, $UDincluded)) ? $topdir : $rootdir; } $root = path(realpath($_POST['root'])); @@ -44,62 +51,60 @@ if (!$root) exit("ERROR: Root filesystem directory not set in jqueryFileTree.php $docroot = '/usr/local/emhttp'; require_once "$docroot/webGui/include/Secure.php"; -$rootdir = path(realpath($_POST['dir'])); -$topdir = '/mnt/'; +$mntdir = '/mnt/'; $userdir = '/mnt/user/'; +$rootdir = path(realpath($_POST['dir'])); +$topdir = str_replace($userdir, $mntdir, $rootdir); $filters = (array)$_POST['filter']; $match = $_POST['match']; $checkbox = $_POST['multiSelect'] == 'true' ? "" : ""; -/* Excluded folders to not show in the dropdown in the '/mnt/' directory only. */ -$excludedFolders = ['RecycleBin', 'addons', 'rootshare']; -$udShares = ['disks','remotes']; +// Excluded UD shares to hide under '/mnt' +$UDexcluded = ['RecycleBin', 'addons', 'rootshare']; +// Included UD shares to show under '/mnt/user' +$UDincluded = ['disks','remotes']; echo ""; if ($_POST['show_parent'] == 'true' && is_top($rootdir)) { echo "$checkbox.."; } -if (is_low($rootdir) && is_dir($rootdir)) { - $dirs = $files = []; - $names = array_filter(scandir($rootdir, SCANDIR_SORT_NONE), function($n){return $n != '.' && $n != '..';}); +if (is_dir($rootdir)) { + $dirs = $files = []; + $names = array_filter(scandir($rootdir, SCANDIR_SORT_NONE), 'no_dots'); + // add UD shares under /mnt/user + foreach ($UDincluded as $name) { + if (!is_dir($topdir.$name)) continue; + if ($rootdir === $userdir) { + if (!in_array($name, $names)) $names[] = $name; + } else { + if (explode('/', $topdir)[2] === $name) $names = array_merge($names, array_filter(scandir($topdir, SCANDIR_SORT_NONE), 'no_dots')); + } + } natcasesort($names); foreach ($names as $name) { - if (is_dir($rootdir.$name)) { + if (is_dir(my_dir($name).$name)) { $dirs[] = $name; } else { $files[] = $name; } } foreach ($dirs as $name) { - $htmlRel = htmlspecialchars($rootdir.$name); + // Exclude '.Recycle.Bin' from all shares and UD folders from '/mnt' + if ($name === '.Recycle.Bin' || ($rootdir === $mntdir && in_array($name, $UDexcluded))) continue; + $htmlRel = htmlspecialchars(my_dir($name).$name); $htmlName = htmlspecialchars(mb_strlen($name) <= 33 ? $name : mb_substr($name, 0, 30).'...'); - - /* Exclude '.Recycle.Bin' from all directories */ - if ($name === '.Recycle.Bin') continue; - - /* Exclude folders only when directory is '/mnt/' */ - if (in_array($name, $excludedFolders) && $rootdir === $topdir) continue; - if (empty($match) || preg_match("/$match/", $rootdir.$name.'/')) { echo "$checkbox$htmlName"; } } - if ($rootdir === $userdir) { - // add unassigned devices top level shares - foreach ($udShares as $name) if (is_dir($topdir.$name)) { - echo "$checkbox$name"; - } - } foreach ($files as $name) { - $htmlRel = htmlspecialchars($rootdir . $name); + $htmlRel = htmlspecialchars(my_dir($name).$name); $htmlName = htmlspecialchars($name); $ext = mb_strtolower(pathinfo($name, PATHINFO_EXTENSION)); - foreach ($filters as $filter) { - if (empty($filter) || $ext == $filter) { - if (empty($match) || preg_match("/$match/", $name)) { - echo "$checkbox$htmlName"; - } + foreach ($filters as $filter) if (empty($filter) || $ext === $filter) { + if (empty($match) || preg_match("/$match/", $name)) { + echo "$checkbox$htmlName"; } } } diff --git a/emhttp/plugins/dynamix/include/Wireless.php b/emhttp/plugins/dynamix/include/Wireless.php index 5ffcb6c55..ede2fa052 100644 --- a/emhttp/plugins/dynamix/include/Wireless.php +++ b/emhttp/plugins/dynamix/include/Wireless.php @@ -167,7 +167,7 @@ case 'join': $hide4 = $dhcp6 == 'no' ? '' : 'hide'; $hide5 = $dhcp6 == '' ? 'hide' : ''; $hide6 = $dns6 == 'no' ? 'hide' : ''; - echo ""; + echo ""; echo ""; echo ""; echo ""; @@ -195,35 +195,35 @@ case 'join': echo mk_option($safe, 'IEEE 802.1X/SHA-256', _('WPA3 Enterprise')); echo ""; } - if ($ieee1 || $manual || $safe) echo ""._('Username').":"; - if ($attr3 || $manual || $safe) echo ""._('Password').":"; + if ($ieee1 || $manual || $safe) echo ""._('Username').":"; + if ($attr3 || $manual || $safe) echo ""._('Password').":"; echo " "; echo ""._('IPv4 address assignment').":"; echo mk_option($dhcp4, 'yes', _('Automatic')); echo mk_option($dhcp4, 'no', _('Static')); echo ""; - echo ""._('IPv4 address').":/"; + echo ""._('IPv4 address').":/"; foreach ($masks as $mask => $prefix) echo mk_option($mask4, $mask, $prefix); echo ""; - echo ""._('IPv4 default gateway').":"; + echo ""._('IPv4 default gateway').":"; echo ""._('IPv4 DNS assignment').":"; echo mk_option($dns4, "no", _("Automatic")); echo mk_option($dns4, "yes", _("Static")); echo ""; - echo ""._('DNSv4 server').":"; + echo ""._('DNSv4 server').":"; echo " "; echo ""._('IPv6 address assignment').":"; echo mk_option($dhcp6, '', _('None')); echo mk_option($dhcp6, 'yes', _('Automatic')); echo mk_option($dhcp6, 'no', _('Static')); echo ""; - echo ""._('IPv6 address').":/"; - echo ""._('IPv6 default gateway').":"; + echo ""._('IPv6 address').":/"; + echo ""._('IPv6 default gateway').":"; echo ""._('IPv6 DNS assignment').":"; echo mk_option($dns6, "no", _("Automatic")); echo mk_option($dns6, "yes", _("Static")); echo ""; - echo ""._('DNSv6 server').":"; + echo ""._('DNSv6 server').":"; echo " "; echo ""; echo ""; diff --git a/emhttp/plugins/dynamix/scripts/open_ssl b/emhttp/plugins/dynamix/scripts/open_ssl index e62a0b3fa..77942b72c 100755 --- a/emhttp/plugins/dynamix/scripts/open_ssl +++ b/emhttp/plugins/dynamix/scripts/open_ssl @@ -19,7 +19,7 @@ switch ($argv[1]) { case 'reload': if (file_exists($ssl_input)) break; case 'load': - $key = exec("dmidecode -qt1 | grep -Pom1 'Manufacturer: \K.+' | sed 's/ /_/g'")."ABCDEFGH"; + $key = exec("dmidecode -qt1 | grep -Pom1 'Manufacturer: \K.+' | sed -r 's/[^0-9a-zA-Z._-]/_/g'")."ABCDEFGH"; $iv = "12".exec("cat /sys/class/net/wlan0/address | sed 's/://g'")."34"; file_put_contents($ssl_input, "cipher=aes-256-cbc\nkey=".substr($key,0,63)."\niv=$iv\n"); break; diff --git a/emhttp/plugins/dynamix/sheets/SMBExtras.css b/emhttp/plugins/dynamix/sheets/SMBExtras.css index 58fc35623..d7bdf943e 100644 --- a/emhttp/plugins/dynamix/sheets/SMBExtras.css +++ b/emhttp/plugins/dynamix/sheets/SMBExtras.css @@ -1,5 +1,6 @@ textarea { resize: none; font-family: bitstream; - width: 63%; + width: 60%; + margin: 0; } diff --git a/etc/rc.d/rc.wireless b/etc/rc.d/rc.wireless index 2e4d9f058..6f413faf9 100755 --- a/etc/rc.d/rc.wireless +++ b/etc/rc.d/rc.wireless @@ -28,6 +28,18 @@ CONF6=/proc/sys/net/ipv6/conf [[ -r $INI ]] && . $INI PORT=${PORT:-wlan0} +# translate security to informational text +trans(){ + case "$1" in + "open") echo "Open network" ;; + "PSK") echo "WPA2 Personal" ;; + "SAE") echo "WPA3 Personal" ;; + "IEEE 802.1X") echo "WPA2 Enterprise" ;; + "IEEE 802.1X/SHA-256") echo "WPA3 Enterprise" ;; + *) echo "$1" ;; + esac +} + # function to remove leading zeros in IPv4 address unzero(){ local M Q @@ -138,30 +150,36 @@ ipaddr_down(){ # WPA3 OK # WPA2 Enterprise OK # WPA2/WPA3 Enterprise OK -# WPA3 Enterprise dynamic IP NOK, static IP OK +# WPA3 Enterprise OK wpa_configuration(){ - PSK=$(wpa_passphrase "$SSID" "$PASSWORD" 2>/dev/null | grep -Pom1 '^\s+psk=\K.+') - [[ -z $PSK ]] && PSK="\"$PASSWORD\"" - [[ -z $2 ]] && echo "bgscan=\"\"" >$WPA || echo >$WPA - [[ -z $2 && -n $CC ]] && echo "country=${CC,,}" >>$WPA + if [[ ! -e $WPA ]]; then + echo "bgscan=\"\"" >$WPA + [[ -n $CC ]] && echo "country=${CC,,}" >>$WPA + fi + if [[ $1 == "PSK" ]]; then + PSK=$(wpa_passphrase "$SSID" "$PASSWORD" 2>/dev/null | grep -Pom1 '^\s+psk=\K.+') + [[ -z $PSK ]] && PSK="\"$PASSWORD\"" + fi + [[ -z $2 && $1 == "SAE" ]] && echo "sae_pwe=1" >>$WPA echo "network={" >>$WPA echo "ssid=\"$SSID\"" >>$WPA echo "scan_ssid=1" >>$WPA + [[ $1 == "open" ]] && echo "key_mgmt=NONE" >>$WPA [[ $1 == "PSK" ]] && echo "key_mgmt=WPA-PSK" >>$WPA [[ $1 == "SAE" ]] && echo "key_mgmt=SAE" >>$WPA - [[ $1 =~ "IEEE" && $1 != "IEEE 802.1X/SHA-256" ]] && echo "key_mgmt=WPA-EAP" >>$WPA + [[ $1 == "IEEE 802.1X" ]] && echo "key_mgmt=WPA-EAP" >>$WPA [[ $1 == "IEEE 802.1X/SHA-256" ]] && echo "key_mgmt=WPA-EAP-SHA256" >>$WPA - [[ $1 =~ "IEEE 802.1X" ]] && echo "eap=PEAP" >>$WPA - [[ $1 != "SAE" && ! $1 =~ "IEEE" ]] && echo "psk=$PSK" >>$WPA + [[ $1 == "PSK" ]] && echo "psk=$PSK" >>$WPA + [[ $1 == "SAE" ]] && echo "sae_password=\"$PASSWORD\"" >>$WPA + [[ $1 =~ "IEEE" ]] && echo "eap=PEAP" >>$WPA [[ $1 =~ "IEEE" ]] && echo "identity=\"$USERNAME\"" >>$WPA - [[ $1 =~ "IEEE" && $1 != "IEEE 802.1X/SHA-256" ]] && echo "password=\"$PASSWORD\"" >>$WPA - [[ $1 == "SAE" || $1 == "IEEE 802.1X/SHA-256" ]] && echo "sae_password=\"$PASSWORD\"" >>$WPA + [[ $1 =~ "IEEE" ]] && echo "password=\"$PASSWORD\"" >>$WPA + [[ $1 == "IEEE 802.1X" ]] && echo "ieee80211w=1" >>$WPA [[ $1 == "SAE" || $1 == "IEEE 802.1X/SHA-256" ]] && echo "ieee80211w=2" >>$WPA [[ $1 =~ "IEEE" ]] && echo "phase2=\"auth=MSCHAPV2\"" >>$WPA [[ -n $2 ]] && echo "priority=$2" >>$WPA echo "}" >>$WPA - [[ -n $2 ]] && cat $WPA >>$WPA.tmp } wifi_running(){ @@ -182,6 +200,8 @@ wifi_start(){ fi LINK=shim-$PORT [[ -e $SYSTEM/$LINK ]] || run ip link add link $PORT name $LINK type ipvtap mode l2 bridge + run ip link set $PORT up + run ip link set $LINK up # set regulatory region (if set) upon start REGION=$(var REGION $CFG) REGION_XX=$(var REGION_XX $CFG) @@ -253,27 +273,28 @@ wifi_join(){ REGION=$(grep -Pom1 '^REGION="\K[^"]+' $CFG) REGION_XX=$(grep -Pom1 '^REGION_XX="\K[^"]+' $CFG) [[ $REGION == '00' ]] && CC=$REGION_XX || CC=$REGION - if [[ ${SECURITY^^} == AUTO ]]; then - # auto generate config - log "wpa_configuration AUTO" - echo "bgscan=\"\"" >$WPA.tmp - [[ -n $CC ]] && echo "country=${CC,,}" >>$WPA.tmp + [[ -n $(pgrep wpa_supplicant) ]] && pkill wpa_supplicant + rm -f $WPA + if [[ $SECURITY == "auto" ]]; then + log "wpa_configuration: Automatic detection" wpa_configuration "IEEE 802.1X/SHA-256" 25 wpa_configuration "IEEE 802.1X" 18 wpa_configuration "SAE" 15 wpa_configuration "PSK" 12 - mv $WPA.tmp $WPA - [[ -n $(pgrep wpa_supplicant) ]] && pkill wpa_supplicant - run wpa_supplicant -B -i $PORT -c $WPA - elif [[ -z $SECURITY || ${SECURITY^^} == "OPEN" ]]; then - # open network - run iw dev $PORT connect "$SSID" auth open + wpa_configuration "open" 10 + elif [[ $SECURITY == "IEEE 802.1X IEEE 802.1X/SHA-256" ]]; then + log "wpa_configuration: WPA2/WPA3 Enterprise" + wpa_configuration "IEEE 802.1X/SHA-256" 25 + wpa_configuration "IEEE 802.1X" 18 + elif [[ $SECURITY == "PSK SAE" ]]; then + log "wpa_configuration: WPA2/WPA3 Personal" + wpa_configuration "SAE" 15 + wpa_configuration "PSK" 12 else - # WPA encryption - run wpa_configuration "$SECURITY" - [[ -n $(pgrep wpa_supplicant) ]] && pkill wpa_supplicant - run wpa_supplicant -B -i $PORT -c $WPA + log "wpa_configuration: $(trans "$SECURITY")" + wpa_configuration "$SECURITY" fi + run wpa_supplicant -B -q -i $PORT -c $WPA # IPv4 address assignment IP=ipv4 DHCP=$DHCP4