mirror of
https://github.com/unraid/webgui.git
synced 2026-05-05 20:00:52 -05:00
Wireless enhancements
- Added "Regulatory region" selection - Added "automatic" choice in security selection for manually configured networks - Added support for "auto" security setting on initial boot
This commit is contained in:
@@ -16,8 +16,9 @@ Cond="file_exists('/sys/class/net/wlan0')"
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
$title = _('Connect to WiFi network');
|
||||
$cfg = '/boot/config/wireless.cfg';
|
||||
$title = _('Connect to WiFi network');
|
||||
$cfg = '/boot/config/wireless.cfg';
|
||||
$regions = file("$docroot/webGui/include/regions.key", FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
||||
if (file_exists($cfg)) $wlan0 = parse_ini_file($cfg,true)['wlan0'];
|
||||
?>
|
||||
<div class="title nocontrol shift"> </div>
|
||||
@@ -27,14 +28,26 @@ if (file_exists($cfg)) $wlan0 = parse_ini_file($cfg,true)['wlan0'];
|
||||
<input type="hidden" name="#command" value="/webGui/scripts/wireless">
|
||||
<input type="hidden" name="#arg[1]" value=""/>
|
||||
_(Wi-Fi)_:
|
||||
: <select name="WIFI">
|
||||
: <select name="WIFI" class="wifi">
|
||||
<?=mk_option(_var($wlan0,'WIFI'), "no", _("Disabled"))?>
|
||||
<?=mk_option(_var($wlan0,'WIFI'), "yes", _("Enabled"))?>
|
||||
</select>
|
||||
|
||||
_(Regulatory region)_:
|
||||
: <select name="REGION" class="wifi" onchange="showManual(this.value)"><?
|
||||
echo mk_option(_var($wlan0,'REGION'), "", _("Automatic"));
|
||||
echo mk_option(_var($wlan0,'REGION'), "00", _("Manual"));
|
||||
echo mk_option(_var($wlan0,'REGION'), "--", "--------", 'disabled');
|
||||
foreach ($regions as $region) {
|
||||
[$code, $country] = my_explode('|', $region);
|
||||
echo mk_option(_var($wlan0,'REGION'), $code, _($country));
|
||||
}
|
||||
?></select><span id="manual" class="hide">_(Manual input)_ [XX]: <input type="text" name="REGION_XX" class="wifi" value="<?=_var($wlan0,'REGION_XX')?>" minlength="2" maxlength="2"></span>
|
||||
|
||||
|
||||
: <input type="submit" value="_(Apply)_" disabled><input type="button" value="_(Done)_" onclick="done()">
|
||||
</form>
|
||||
|
||||
<div id="wifi" class="hide">
|
||||
<div markdown="1" id="connected" class="shade-<?=$display['theme']?>">
|
||||
_(Connected)_:
|
||||
@@ -77,7 +90,7 @@ function update_wifi(load) {
|
||||
}
|
||||
|
||||
function manage_wifi(ssid,task) {
|
||||
if (task==2) {
|
||||
if (task == 2) {
|
||||
clearTimeout(timers.wifi);
|
||||
$.post('/webGui/include/Wireless.php',{cmd:'forget',ssid:ssid},function(){
|
||||
swal.close();
|
||||
@@ -96,18 +109,22 @@ function manage_wifi(ssid,task) {
|
||||
}
|
||||
}
|
||||
|
||||
function showDHCP(val,v) {
|
||||
if (val=='no') {
|
||||
function showManual(val) {
|
||||
if (val == '00') $('#manual').show(); else $('#manual').hide();
|
||||
}
|
||||
|
||||
function showDHCP(val, v) {
|
||||
if (val == 'no') {
|
||||
$('tr.static'+v).show();
|
||||
$('select[name=DNS'+v+']').val('yes');
|
||||
$('select[name=DNS'+v+'] option:eq(0)').prop('disabled',true);
|
||||
if (v=='6') $('tr.dns6').show();
|
||||
if (v == '6') $('tr.dns6').show();
|
||||
$('tr.server'+v).show();
|
||||
} else if (val=='yes') {
|
||||
} else if (val == 'yes') {
|
||||
$('tr.static'+v).hide();
|
||||
$('select[name=DNS'+v+']').val('no');
|
||||
$('select[name=DNS'+v+'] option:eq(0)').prop('disabled',false);
|
||||
if (v=='6') $('tr.dns6').show();
|
||||
if (v == '6') $('tr.dns6').show();
|
||||
$('tr.server'+v).hide();
|
||||
} else {
|
||||
$('tr.static'+v).hide();
|
||||
@@ -116,9 +133,9 @@ function showDHCP(val,v) {
|
||||
}
|
||||
}
|
||||
|
||||
function showDNS(val,v) {
|
||||
if (val=='no') $('tr.server'+v).hide();
|
||||
if (val=='yes') $('tr.server'+v).show();
|
||||
function showDNS(val, v) {
|
||||
if (val == 'no') $('tr.server'+v).hide();
|
||||
if (val == 'yes') $('tr.server'+v).show();
|
||||
}
|
||||
|
||||
function showPassword() {
|
||||
@@ -133,9 +150,9 @@ function showPassword() {
|
||||
}
|
||||
|
||||
function showSecurity(val) {
|
||||
if (val=='none') {
|
||||
if (val == 'open') {
|
||||
$('#username,#password').hide();
|
||||
} else if (val.slice(-1)=='e') {
|
||||
} else if (val.substr(0,4) == 'IEEE' || val == 'auto') {
|
||||
$('#username,#password').show();
|
||||
} else {
|
||||
$('#username').hide();
|
||||
|
||||
@@ -186,8 +186,8 @@ case 'join':
|
||||
}
|
||||
if ($manual || $safe) {
|
||||
echo "<tr><td>"._('Security')."</td><td><select name=\"SECURITY\" onclick=\"showSecurity(this.value)\">";
|
||||
echo mk_option($safe, 'OPEN', _('None'));
|
||||
echo mk_option($safe, 'WEP', _('WEP (deprecated)'));
|
||||
echo mk_option($safe, 'open', _('None'));
|
||||
echo mk_option($safe, 'auto', _('Automatic'));
|
||||
echo mk_option($safe, 'PSK', _('WPA2'));
|
||||
echo mk_option($safe, 'PSK SAE', _('WPA2/WPA3'));
|
||||
echo mk_option($safe, 'SAE', _('WPA3'));
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
DZ|Algeria
|
||||
AR|Argentina
|
||||
AU|Australia
|
||||
AT|Austria
|
||||
BH|Bahrain
|
||||
BM|Bermuda
|
||||
BO|Bolivia
|
||||
BR|Brazil
|
||||
BG|Bulgaria
|
||||
CA|Canada
|
||||
CL|Chile
|
||||
CN|China
|
||||
CO|Colombia
|
||||
CR|Costa Rica
|
||||
CY|Cyprus
|
||||
CZ|Czech Republic
|
||||
DK|Denmark
|
||||
DO|Dominican Republic
|
||||
EC|Ecuador
|
||||
EG|Egypt
|
||||
SV|El Salvador
|
||||
EE|Estonia
|
||||
FI|Finland
|
||||
FR|France
|
||||
DE|Germany
|
||||
GR|Greece
|
||||
GT|Guatemala
|
||||
HN|Honduras
|
||||
HK|Hong Kong
|
||||
IS|Iceland
|
||||
IN|India
|
||||
ID|Indonesia
|
||||
IE|Ireland
|
||||
IL|Israel
|
||||
IT|Italy
|
||||
JM|Jamaica
|
||||
JP|Japan
|
||||
JO|Jordan
|
||||
KE|Kenya
|
||||
KW|Kuwait
|
||||
LB|Lebanon
|
||||
LI|Liechtenstein
|
||||
LT|Lithuania
|
||||
LU|Luxembourg
|
||||
MU|Mauritius
|
||||
MX|Mexico
|
||||
MA|Morocco
|
||||
NL|Netherlands
|
||||
NZ|New Zealand
|
||||
NO|Norway
|
||||
OM|Oman
|
||||
PK|Pakistan
|
||||
PA|Panama
|
||||
PE|Peru
|
||||
PH|Philippines
|
||||
PL|Poland
|
||||
PT|Portugal
|
||||
PR|Puerto Rico
|
||||
QA|Qatar
|
||||
KR|Republic of Korea
|
||||
RO|Romania
|
||||
RU|Russia
|
||||
SA|Saudi Arabia
|
||||
CS|Serbia and Montenegro
|
||||
SG|Singapore
|
||||
SK|Slovak Republic
|
||||
SI|Slovenia
|
||||
ZA|South Africa
|
||||
ES|Spain
|
||||
LK|Sri Lanka
|
||||
CH|Switzerland
|
||||
TW|Taiwan
|
||||
TH|Thailand
|
||||
TT|Trinidad and Tobago
|
||||
TN|Tunisia
|
||||
TR|Turkey
|
||||
UA|Ukraine
|
||||
AE|United Arab Emirates
|
||||
GB|United Kingdom
|
||||
US|United States
|
||||
UY|Uruguay
|
||||
VE|Venezuela
|
||||
VN|Vietnam
|
||||
@@ -5,4 +5,6 @@ input.form{font-size:1rem;padding:5px 10px;margin:0}
|
||||
input[type=button].form{margin-left:20px}
|
||||
table.swal{text-align:left;font-size:1.2rem}
|
||||
table.swal td:nth-child(1){width:42%;text-align:right;padding-right:30px}
|
||||
#showPass{cursor:pointer;margin-left:10px}
|
||||
#showPass{cursor:pointer;margin-left:10px}
|
||||
select.wifi{max-width:100px}
|
||||
input.wifi{margin-left:10px;width:2.4rem;text-transform:uppercase}
|
||||
+21
-6
@@ -143,7 +143,8 @@ ipaddr_down(){
|
||||
wpa_configuration(){
|
||||
PSK=$(wpa_passphrase "$SSID" "$PASSWORD" 2>/dev/null | grep -Pom1 '^\s+psk=\K.+')
|
||||
[[ -z $PSK ]] && PSK="\"$PASSWORD\""
|
||||
echo "bgscan=\"\"" >$WPA
|
||||
[[ -z $2 ]] && echo "bgscan=\"\"" >$WPA || echo >$WPA
|
||||
[[ -z $2 && -n $CC ]] && echo "country=${CC,,}" >>$WPA
|
||||
echo "network={" >>$WPA
|
||||
echo "ssid=\"$SSID\"" >>$WPA
|
||||
[[ $1 == "PSK" ]] && echo "key_mgmt=WPA-PSK" >>$WPA
|
||||
@@ -156,9 +157,10 @@ wpa_configuration(){
|
||||
[[ $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 == "SAE" || $1 == "IEEE 802.1X/SHA-256" ]] && echo "ieee80211w=2" >>$WPA
|
||||
[[ $1 =~ "IEEE" ]] && echo "phase1=\"peaplabel=0\"" >>$WPA
|
||||
[[ $1 =~ "IEEE" ]] && echo "phase2=\"auth=MSCHAPV2\"" >>$WPA
|
||||
[[ -n $2 ]] && echo "priority=$2" >>$WPA
|
||||
echo "}" >>$WPA
|
||||
[[ -n $2 ]] && cat $WPA >>$WPA.tmp
|
||||
}
|
||||
|
||||
wifi_running(){
|
||||
@@ -239,12 +241,25 @@ wifi_join(){
|
||||
sed -ri "s/^(PASSWORD=\").+$/\1$ENCRYPT2\"/" $CFG
|
||||
fi
|
||||
SECURITY=${SECURITY:-$ATTR3}
|
||||
if [[ -z $SECURITY || ${SECURITY^^} == "OPEN" ]]; then
|
||||
# regulatory region
|
||||
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
|
||||
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
|
||||
elif [[ $SECURITY =~ "WEP" ]]; then
|
||||
# WEP encryption
|
||||
run iw dev $PORT connect "$SSID" auth shared key 0:$(hex "$PASSWORD")
|
||||
else
|
||||
# WPA encryption
|
||||
run wpa_configuration "$SECURITY"
|
||||
|
||||
Reference in New Issue
Block a user