diff --git a/emhttp/plugins/dynamix/Eth0.page b/emhttp/plugins/dynamix/Eth0.page index 03393acda..7b4858ea9 100644 --- a/emhttp/plugins/dynamix/Eth0.page +++ b/emhttp/plugins/dynamix/Eth0.page @@ -162,13 +162,6 @@ function prepareSettings(form) { if (brnics.length > 1) form.BRSTP.value = 'yes'; if ($(form).find('input[name="#arg[1]"]').val() == 'none') return true; - var metrics = [], metrics6 = []; - $(form).find('input[name^="METRIC:"]').each(function(){if($(this).val() > 0) metrics.push($(this).val());}); - $(form).find('input[name^="METRIC6:"]').each(function(){if($(this).val() > 0) metrics6.push($(this).val());}); - if (metrics.same() || metrics6.same()) { - swal({title:'Duplicate metrics', text:'List of default gateways contains duplicate metric values', animation:'none', type:'error', html:true, confirmButtonText:"_(Ok)_"}); - return false; - } // enable form items for submission $(form).find('input,select').prop('disabled',false); if (form.TYPE.value == 'access') { @@ -213,7 +206,6 @@ function prepareSettings(form) { $(form).find('select[name^="USE_DHCP:"]').each(function() { var i = $(this).prop('name').split(':')[1]; var protocol = $(form).find('select[name="PROTOCOL:'+i+'"]').val() || 'ipv4'; - var metric = $(form).find('input[name="METRIC:'+i+'"]').val(); var gw4 = (port == 'eth0') ? true : $(form).find('input[name="USE_GW4:'+i+'"]').prop('checked'); if (protocol != 'ipv6' && $(this).val() != 'no') { $(form).find('input[name="IPADDR:'+i+'"]').val(''); @@ -224,7 +216,6 @@ function prepareSettings(form) { $(form).find('select[name^="USE_DHCP6:"]').each(function() { var i = $(this).prop('name').split(':')[1]; var protocol = $(form).find('select[name="PROTOCOL:'+i+'"]').val() || 'ipv4'; - var metric = $(form).find('input[name="METRIC6:'+i+'"]').val(); var gw6 = (port == 'eth0') ? true : $(form).find('input[name="USE_GW6:'+i+'"]').prop('checked'); if (protocol != 'ipv4' && $(this).val() != 'no') { $(form).find('input[name="IPADDR6:'+i+'"]').val(''); @@ -240,6 +231,13 @@ function prepareSettings(form) { $(form).find('input[name="'+name+'"]').val(data); }); } + var metrics = [], metrics6 = []; + $(form).find('input[name^="METRIC:"]').each(function(){if($(this).val() > 0) metrics.push($(this).val());}); + $(form).find('input[name^="METRIC6:"]').each(function(){if($(this).val() > 0) metrics6.push($(this).val());}); + if (metrics.same() || metrics6.same()) { + swal({title:"_(Duplicate metrics)_", text:"_(List of default gateways contains duplicate metric values)_", animation:'none', type:'error', html:true, confirmButtonText:"_(Ok)_"}); + return false; + } // force default MTU if jumbo frames are not enabled if ($(form).find('input[name="USE_MTU"]').prop('checked') == false) $(form).find('input[name="MTU"]').val(''); $(form).find('input[name="#arg[1]"]').val(arg1[port]); diff --git a/emhttp/plugins/dynamix/include/Wireless.php b/emhttp/plugins/dynamix/include/Wireless.php index 1dabe0757..5ffcb6c55 100644 --- a/emhttp/plugins/dynamix/include/Wireless.php +++ b/emhttp/plugins/dynamix/include/Wireless.php @@ -48,7 +48,7 @@ function scanWifi($port) { // store MAC address only $wlan[$network][0] = substr($wlan[$network][0],4,17); // identify open network - $wlan[$network][4] = $wlan[$network][4] ?? 'open'; + $wlan[$network][4] ??= 'open'; } else { // group radio frequencies $wlan[$network][1] .= ' '.$attr[1]; diff --git a/etc/rc.d/rc.wireless b/etc/rc.d/rc.wireless index 2a19d65ee..2e4d9f058 100755 --- a/etc/rc.d/rc.wireless +++ b/etc/rc.d/rc.wireless @@ -172,56 +172,57 @@ wifi_running(){ wifi_start(){ log "Starting $DAEMON..." local REPLY - if [[ -e $SYSTEM/$PORT ]]; then - 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=$(grep -Pom1 '^REGION="\K[^"]+' $CFG) - REGION_XX=$(grep -Pom1 '^REGION_XX="\K[^"]+' $CFG) - [[ $REGION == '00' ]] && CC=$REGION_XX || CC=$REGION - [[ -n $CC ]] && run iw reg set $CC - # initialise openssl encryption parameters - $OPENSSL load - # start active SSID - $STARTWIFI - if ! carrier_up $PORT; then - # try the saved SSIDs - for SSID in $(grep -P '^\[.+\]$' $CFG 2>/dev/null | sed 1d | sed -r 's/\[|\]/"/g'); do - [[ -n $SSID ]] && $STARTWIFI "$SSID" || break - if carrier_up $PORT; then break; fi - done - fi - if wifi_running; then REPLY="Started"; else REPLY="Failed"; fi - else - REPLY="No Wifi present" + if [[ ! -e $SYSTEM/$PORT ]]; then + log "$DAEMON... No Wifi present." + return fi + if [[ $(var WIFI $CFG) != yes ]]; then + log "$DAEMON... Wifi not enabled." + return + fi + LINK=shim-$PORT + [[ -e $SYSTEM/$LINK ]] || run ip link add link $PORT name $LINK type ipvtap mode l2 bridge + # set regulatory region (if set) upon start + REGION=$(var REGION $CFG) + REGION_XX=$(var REGION_XX $CFG) + [[ $REGION == '00' ]] && CC=$REGION_XX || CC=$REGION + [[ -n $CC ]] && run iw reg set $CC + # initialise openssl encryption parameters + $OPENSSL load + # start active SSID + $STARTWIFI + if ! carrier_up $PORT; then + # try the saved SSIDs + for SSID in $(grep -P '^\[.+\]$' $CFG | sed 1d | sed -r 's/\[|\]/"/g'); do + [[ -n $SSID ]] && $STARTWIFI "$SSID" || break + if carrier_up $PORT; then break; fi + done + fi + if wifi_running; then REPLY="Started"; else REPLY="Failed"; fi log "$DAEMON... $REPLY." } wifi_stop(){ log "Stopping $DAEMON..." local REPLY - if [[ -e $SYSTEM/$PORT ]]; then - IP=ipv4 - DHCP=$DHCP4 - DNS=$DNS4 - ipaddr_down - if [[ -n $DHCP6 ]]; then - IP=ipv6 - DHCP=$DHCP6 - DNS=$DNS6 - ipaddr_down - fi - run pkill wpa_supplicant - run iw dev $PORT disconnect - run ip addr flush dev $PORT - run rm -f $INI - if ! wifi_running; then REPLY="Stopped"; else REPLY="Failed"; fi - else - REPLY="No Wifi present" + if [[ ! -e $SYSTEM/$PORT ]]; then + log "$DAEMON... No Wifi present." + return fi + IP=ipv4 + DHCP=$DHCP4 + DNS=$DNS4 + ipaddr_down + if [[ -n $DHCP6 ]]; then + IP=ipv6 + DHCP=$DHCP6 + DNS=$DNS6 + ipaddr_down + fi + run pkill wpa_supplicant + run iw dev $PORT disconnect + run rm -f $INI + if ! wifi_running; then REPLY="Stopped"; else REPLY="Failed"; fi log "$DAEMON... $REPLY." }