diff --git a/README.md b/README.md index 573ee34..ffa61c4 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![Codacy Badge](https://api.codacy.com/project/badge/Grade/a2cf9bdec17b4b6f9b6e113f802be694)](https://app.codacy.com/app/jackyaz/YazFi?utm_source=github.com&utm_medium=referral&utm_content=jackyaz/YazFi&utm_campaign=Badge_Grade_Dashboard) ![Shellcheck](https://github.com/jackyaz/YazFi/actions/workflows/shellcheck.yml/badge.svg) -## v4.3.3 -### Updated on 2021-07-31 +## v4.3.4 +### Updated on 2021-08-04 ## About Feature expansion of guest WiFi networks on AsusWRT-Merlin, including, but not limited to: diff --git a/YazFi.sh b/YazFi.sh index 211facf..6363c3a 100644 --- a/YazFi.sh +++ b/YazFi.sh @@ -36,8 +36,8 @@ ### Start of script variables ### readonly SCRIPT_NAME="YazFi" readonly SCRIPT_CONF="/jffs/addons/$SCRIPT_NAME.d/config" -readonly YAZFI_VERSION="v4.3.3" -readonly SCRIPT_VERSION="v4.3.3" +readonly YAZFI_VERSION="v4.3.4" +readonly SCRIPT_VERSION="v4.3.4" SCRIPT_BRANCH="master" SCRIPT_REPO="https://raw.githubusercontent.com/jackyaz/$SCRIPT_NAME/$SCRIPT_BRANCH" readonly SCRIPT_DIR="/jffs/addons/$SCRIPT_NAME.d" @@ -249,20 +249,20 @@ Auto_ServiceEvent(){ case $1 in create) if [ -f /jffs/scripts/service-event ]; then - STARTUPLINECOUNT=$(grep -c '# '"$SCRIPT_NAME"' Guest Networks' /jffs/scripts/service-event) - STARTUPLINECOUNTEX=$(grep -cx "/jffs/scripts/$SCRIPT_NAME service_event"' "$@" & # '"$SCRIPT_NAME Guest Networks" /jffs/scripts/service-event) + STARTUPLINECOUNT=$(grep -c '# '"$SCRIPT_NAME Guest Networks" /jffs/scripts/service-event) + STARTUPLINECOUNTEX=$(grep -cx 'if echo "$2" | /bin/grep -q "'"$SCRIPT_NAME"'" || { [ "$1" = "restart" ] && [ "$2" = "wireless" ]; }; then { /jffs/scripts/'"$SCRIPT_NAME"' service_event "$@" & }; fi # '"$SCRIPT_NAME Guest Networks" /jffs/scripts/service-event) if [ "$STARTUPLINECOUNT" -gt 1 ] || { [ "$STARTUPLINECOUNTEX" -eq 0 ] && [ "$STARTUPLINECOUNT" -gt 0 ]; }; then sed -i -e '/# '"$SCRIPT_NAME"' Guest Networks/d' /jffs/scripts/service-event fi if [ "$STARTUPLINECOUNTEX" -eq 0 ]; then - echo "/jffs/scripts/$SCRIPT_NAME service_event"' "$@" & # '"$SCRIPT_NAME Guest Networks" >> /jffs/scripts/service-event + echo 'if echo "$2" | /bin/grep -q "'"$SCRIPT_NAME"'" || { [ "$1" = "restart" ] && [ "$2" = "wireless" ]; }; then { /jffs/scripts/'"$SCRIPT_NAME"' service_event "$@" & }; fi # '"$SCRIPT_NAME Guest Networks" >> /jffs/scripts/service-event fi else echo "#!/bin/sh" > /jffs/scripts/service-event echo "" >> /jffs/scripts/service-event - echo "/jffs/scripts/$SCRIPT_NAME service_event"' "$@" & # '"$SCRIPT_NAME Guest Networks" >> /jffs/scripts/service-event + echo 'if echo "$2" | /bin/grep -q "'"$SCRIPT_NAME"'" || { [ "$1" = "restart" ] && [ "$2" = "wireless" ]; }; then { /jffs/scripts/'"$SCRIPT_NAME"' service_event "$@" & }; fi # '"$SCRIPT_NAME Guest Networks" >> /jffs/scripts/service-event chmod 0755 /jffs/scripts/service-event fi ;; @@ -958,15 +958,20 @@ Conf_Validate(){ fi fi - if ! Validate_IP "${IFACETMP}_DNS1" "$(eval echo '$'"${IFACETMP}_DNS1")" "DNS"; then + if ! Validate_TrueFalse "${IFACETMP}_FORCEDNS" "$(eval echo '$'"${IFACETMP}_FORCEDNS")"; then IFACE_PASS="false" + else + if [ "$(eval echo '$'"${IFACETMP}_FORCEDNS")" = "true" ]; then + Print_Output false "$IFACE has FORCEDNS enabled, setting DNS2 to match DNS1..." "$WARN" + sed -i -e "s/${IFACETMP}_DNS2=.*/${IFACETMP}_DNS2=$(eval echo '$'"${IFACETMP}_DNS1")/" "$SCRIPT_CONF" + fi fi - if ! Validate_IP "${IFACETMP}_DNS2" "$(eval echo '$'"${IFACETMP}_DNS2")" "DNS"; then + if ! Validate_IP "${IFACETMP}_DNS1" "$(eval echo '$'"${IFACETMP}_DNS1")" "DNS"; then IFACE_PASS="false" fi - if ! Validate_TrueFalse "${IFACETMP}_FORCEDNS" "$(eval echo '$'"${IFACETMP}_FORCEDNS")"; then + if ! Validate_IP "${IFACETMP}_DNS2" "$(eval echo '$'"${IFACETMP}_DNS2")" "DNS"; then IFACE_PASS="false" fi @@ -1371,13 +1376,6 @@ Firewall_Rules(){ Firewall_DNS(){ ACTIONS="" IFACE="$2" - IFACE_WAN="" - - if [ "$(nvram get wan0_proto)" = "pppoe" ] || [ "$(nvram get wan0_proto)" = "pptp" ] || [ "$(nvram get wan0_proto)" = "l2tp" ]; then - IFACE_WAN="ppp0" - else - IFACE_WAN="$(nvram get wan0_ifname)" - fi case $1 in create) diff --git a/YazFi_www.asp b/YazFi_www.asp index 00fbb39..197c7d6 100644 --- a/YazFi_www.asp +++ b/YazFi_www.asp @@ -161,7 +161,7 @@ function jy_checkIPConflict(CompareItem,sourceIP,sourceMask,compareIP,compareMas } return ipConflict; } -var tout,clientswl01=[],sortnamewl01="Hostname",sortdirwl01="asc",clientswl02=[],sortnamewl02="Hostname",sortdirwl02="asc",clientdwl03=[],sortnamewl03="Hostname",sortdirwl03="asc",clientswl11=[],sortnamewl11="Hostname",sortdirwl11="asc",clientswl12=[],sortnamewl12="Hostname",sortdirwl12="asc",clientswl13=[],sortnamewl13="Hostname",sortdirwl13="asc",clientswl21=[],sortnamewl21="Hostname",sortdirwl21="asc",clientswl22=[],sortnamewl22="Hostname",sortdirwl22="asc",clientswl23=[],sortnamewl23="Hostname",sortdirwl23="asc",bands=0,failedfields=[],$j=jQuery.noConflict();function initial(){SetCurrentPage(),LoadCustomSettings(),show_menu(),get_conf_file(),ScriptUpdateLayout(),document.formScriptActions.action_script.value="start_YazFiconnectedclients",document.formScriptActions.submit(),tout=setTimeout(get_connected_clients_file,5e3)}function YazHint(a){for(var b=document.getElementsByTagName("a"),c=0;c=i2;i2++)"yazfi_wl"+i.toString()+i2.toString()+"_ipaddr"!=inputname&&eval("document.form.yazfi_wl"+i.toString()+i2.toString()+"_ipaddr.value")==fixedip&&(matchfound=!0);return matchfound?($j(forminput).addClass("invalid"),failedfields.push([$j(forminput),"Conflict with another YazFi network"]),$j(forminput).on("mouseover",function(){return overlib("Conflict with another YazFi network",0,0)}),$j(forminput)[0].onmouseout=nd,!1):($j(forminput).removeClass("invalid"),$j(forminput).off("mouseover"),!0)}return $j(forminput).addClass("invalid"),failedfields.push([$j(forminput),"LAN IP conflict"]),$j(forminput).on("mouseover",function(){return overlib("LAN IP conflict",0,0)}),$j(forminput)[0].onmouseout=nd,!1}return $j(forminput).addClass("invalid"),failedfields.push([$j(forminput),"Not a private IP address"]),$j(forminput).on("mouseover",function(){return overlib("Not a private IP address",0,0)}),$j(forminput)[0].onmouseout=nd,!1}return $j(forminput).removeClass("invalid"),$j(forminput).off("mouseover"),!0}return $j(forminput).addClass("invalid"),failedfields.push([$j(forminput),"Invalid IP Address"]),$j(forminput).on("mouseover",function(){return overlib("Invalid IP Address",0,0)}),$j(forminput)[0].onmouseout=nd,!1}function Validate_DHCP(forminput){var startend="",inputname=forminput.name,inputvalue=1*forminput.value;return startend=-1==inputname.indexOf("start")?"end":"start","start"==startend?inputvalue>=1*eval("document.form."+inputname.substring(0,inputname.indexOf("start"))+"end.value")?($j(forminput).addClass("invalid"),failedfields.push([$j(forminput),"DHCP start is greater than DHCP end"]),$j(forminput).on("mouseover",function(){return overlib("DHCP start is greater than DHCP end",0,0)}),$j(forminput)[0].onmouseout=nd,!1):254inputvalue?($j(forminput).addClass("invalid"),failedfields.push([$j(forminput),"Value not between 2 and 254"]),$j(forminput).on("mouseover",function(){return overlib("Value not between 2 and 254",0,0)}),$j(forminput)[0].onmouseout=nd,!1):($j(forminput).removeClass("invalid"),$j(forminput).off("mouseover"),!0):inputvalue<=1*eval("document.form."+inputname.substring(0,inputname.indexOf("end"))+"start.value")?($j(forminput).addClass("invalid"),failedfields.push([$j(forminput),"DHCP end is less than DHCP start"]),$j(forminput).on("mouseover",function(){return overlib("DHCP end is less than DHCP start",0,0)}),$j(forminput)[0].onmouseout=nd,!1):254inputvalue?($j(forminput).addClass("invalid"),failedfields.push([$j(forminput),"Value not between 2 and 254"]),$j(forminput).on("mouseover",function(){return overlib("Value not between 2 and 254",0,0)}),$j(forminput)[0].onmouseout=nd,!1):($j(forminput).removeClass("invalid"),$j(forminput).off("mouseover"),!0)}function Validate_VPNClientNo(a){var b=a.name,c=1*a.value;return 5c?($j(a).addClass("invalid"),failedfields.push([$j(a),"Value not between 1 and 5"]),$j(a).on("mouseover",function(){return overlib("Value not between 1 and 5",0,0)}),$j(a)[0].onmouseout=nd,!1):($j(a).removeClass("invalid"),$j(a).off("mouseover"),!0)}function Validate_OneTwoWay(forminput){var onetwo="",inputname=forminput.name,inputvalue=forminput.value;onetwo=-1==inputname.indexOf("oneway")?"two":"one","one"==onetwo?"true"==inputvalue&&eval("document.form."+inputname.substring(0,inputname.indexOf("one"))+"twowaytoguest.value=false"):"true"==inputvalue&&eval("document.form."+inputname.substring(0,inputname.indexOf("two"))+"onewaytoguest.value=false")}function Validate_All(){var validationfailed=!1;failedfields=[];for(var i=0;i=i2;i2++)Validate_IP(eval("document.form.yazfi_wl"+i+i2+"_ipaddr"),"IP")||(validationfailed=!0),Validate_DHCP(eval("document.form.yazfi_wl"+i+i2+"_dhcpstart"))||(validationfailed=!0),Validate_DHCP(eval("document.form.yazfi_wl"+i+i2+"_dhcpend"))||(validationfailed=!0),Validate_IP(eval("document.form.yazfi_wl"+i+i2+"_dns1"),"DNS")||(validationfailed=!0),Validate_IP(eval("document.form.yazfi_wl"+i+i2+"_dns2"),"DNS")||(validationfailed=!0),Validate_VPNClientNo(eval("document.form.yazfi_wl"+i+i2+"_vpnclientnumber"))||(validationfailed=!0);for(var failedfieldsstring="",i=0;i"),$j("#table_config").append(BuildConfigTable("wl1","5GHz Guest Networks"))):(wl_info.band2g_support&&($j("#table_config").append(BuildConfigTable("wl0","2.4GHz Guest Networks")),++bands),wl_info.band5g_support&&($j("#table_config").append(""),$j("#table_config").append(BuildConfigTable("wl1","5GHz Guest Networks")),++bands),wl_info.band5g_2_support&&($j("#table_config").append(""),$j("#table_config").append(BuildConfigTable("wl2","5GHz-2 Guest Networks")),++bands)),$j("#table_config").append("");var buttonshtml="";buttonshtml+="",$j("#table_config").append(buttonshtml);for(var settingcount=3*(12*bands),i=0;i1*$j("#firmver").text()&&("RT-AX88U"==productid||"RT-AX3000"==productid)&&($j("input[name*=clientisolation][value=false]").prop("checked",!0),$j("input[name*=clientisolation]").attr("disabled",!0));for(var i=0;i=i2;i2++)0==eval("document.form.wl"+i+i2+"_bss_enabled").value&&(OptionsEnableDisable($j("#yazfi_wl"+i+i2+"_en_false")[0]),$j("input[name=yazfi_wl"+i+i2+"_enabled]").prop("disabled",!0))}})}function get_connected_clients_file(){d3.csv("/ext/YazFi/connectedclients.htm").then(function(data){if(0=i2;i2++)YazFiInterface="wl"+i.toString()+i2.toString(),window["clients"+YazFiInterface]=data.filter(function(a){return a.INTERFACE.replace(".","")==YazFiInterface}).map(function(a){return{Hostname:a.HOSTNAME,IPAddress:a.IP,MACAddress:a.MAC,Connected:a.CONNECTED,Rx:a.RX,Tx:a.TX,RSSI:a.RSSI,PHY:a.PHY}}),"true"==eval("document.form.yazfi_"+YazFiInterface+"_enabled.value")&&1==eval("document.form."+YazFiInterface+"_bss_enabled.value")&&($j("#table_connectedclients").append(BuildConnectedClientPlaceholderTable(YazFiInterface,eval("document.form."+YazFiInterface+"_ssid.value"))),0 (a."+sortfield+".toLowerCase() > b."+sortfield+".toLowerCase()) ? 1 : ((b."+sortfield+".toLowerCase() > a."+sortfield+".toLowerCase()) ? -1 : 0));"),window[sortdir]="asc"):-1==sorttext.indexOf("\u2193")?(eval(arrayid+" = "+arrayid+".sort((a,b) => (a."+sortfield+".toLowerCase() < b."+sortfield+".toLowerCase()) ? 1 : ((b."+sortfield+".toLowerCase() < a."+sortfield+".toLowerCase()) ? -1 : 0));"),window[sortdir]="desc"):(eval(arrayid+" = "+arrayid+".sort((a,b) => (a."+sortfield+".toLowerCase() > b."+sortfield+".toLowerCase()) ? 1 : ((b."+sortfield+".toLowerCase() > a."+sortfield+".toLowerCase()) ? -1 : 0));"),window[sortdir]="asc"):"number"==sorttype?-1==sorttext.indexOf("\u2193")&&-1==sorttext.indexOf("\u2191")?(eval(arrayid+" = "+arrayid+".sort((a,b) => parseFloat(a."+sortfield+".replace(\"m\",\"000\")) - parseFloat(b."+sortfield+".replace(\"m\",\"000\")));"),window[sortdir]="asc"):-1==sorttext.indexOf("\u2193")?(eval(arrayid+" = "+arrayid+".sort((a,b) => parseFloat(b."+sortfield+".replace(\"m\",\"000\")) - parseFloat(a."+sortfield+".replace(\"m\",\"000\")));"),window[sortdir]="desc"):(eval(arrayid+" = "+arrayid+".sort((a,b) => parseFloat(a."+sortfield+".replace(\"m\",\"000\")) - parseFloat(b."+sortfield+".replace(\"m\",\"000\")));"),window[sortdir]="asc"):"time"==sorttype&&(-1==sorttext.indexOf("\u2193")&&-1==sorttext.indexOf("\u2191")?(eval(arrayid+" = "+arrayid+".sort((a,b) => parseFloat(HHMMSStoS(a."+sortfield+".replace(\"m\",\"000\"))) - parseFloat(HHMMSStoS(b."+sortfield+".replace(\"m\",\"000\"))));"),window[sortdir]="asc"):-1==sorttext.indexOf("\u2193")?(eval(arrayid+" = "+arrayid+".sort((a,b) => parseFloat(HHMMSStoS(b."+sortfield+".replace(\"m\",\"000\"))) - parseFloat(HHMMSStoS(a."+sortfield+".replace(\"m\",\"000\"))));"),window[sortdir]="desc"):(eval(arrayid+" = "+arrayid+".sort((a,b) => parseFloat(HHMMSStoS(a."+sortfield+".replace(\"m\",\"000\"))) - parseFloat(HHMMSStoS(b."+sortfield+".replace(\"m\",\"000\"))));"),window[sortdir]="asc")),$j("#"+tableid).empty(),$j("#"+tableid).append(BuildConnectedClientsTable(tableid.replace("sortTable",""))),$j("#"+tableid).find(".sortable").each(function(a,b){b.innerHTML.replace(/ \(.*\)/,"").replace(" ","")==window[sortname]&&("asc"==window[sortdir]?b.innerHTML+=" \u2191":b.innerHTML+=" \u2193")})}function BuildConnectedClientPlaceholderTable(a,b){var c="
 
";return c+="",c+="",c+="",c+="",c+="",c+="",c+="",c+="",c+="",c+="",c+="
"+b+" (click to expand/collapse)
",c+="
",c+="
",c+="",c+="",c}function BuildConnectedClientsTableNoData(){var a="";return a+="",a+="",a+="",a+="
",a+="No connected clients",a+="
",a}function BuildConnectedClientsTable(a){var b="";b+="",b+="",b+="",b+="",b+="",b+="",b+="",b+="",b+="",b+="",b+="",b+="",b+="",b+="",b+="",b+="",b+="",b+="",b+="",b+="",b+="";for(var c=0;c",b+="",b+="",b+="",b+="",b+="",b+="",b+="",b+="",b+="";return b+="",b+="
HostnameIP AddressMAC AddressConnectedRx (Mbps)Tx (Mbps)RSSI (dBm)PHY
"+window["clients"+a][c].Hostname+""+window["clients"+a][c].IPAddress+""+window["clients"+a][c].MACAddress+""+StoHHMMSS(window["clients"+a][c].Connected)+""+window["clients"+a][c].Rx+""+window["clients"+a][c].Tx+""+window["clients"+a][c].RSSI+""+window["clients"+a][c].PHY+"
",b}function BuildConfigTable(prefix,title){var tablehtml="";tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="
"+title+" (click to expand/collapse)
",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="";var enabled1=eval("document.form."+prefix+"1_bss_enabled.value"),enabled2=eval("document.form."+prefix+"2_bss_enabled.value"),enabled3=eval("document.form."+prefix+"3_bss_enabled.value");return(0==enabled1||0==enabled2||0==enabled3)&&(tablehtml+="",tablehtml+="",tablehtml+=0==enabled1?"":"",tablehtml+=0==enabled2?"":"",tablehtml+=0==enabled3?"":"",tablehtml+=""),tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="
 Guest Network 1Guest Network 2Guest Network 3
 "+eval("document.form."+prefix+"1_ssid.value")+""+eval("document.form."+prefix+"2_ssid.value")+""+eval("document.form."+prefix+"3_ssid.value")+"
 Disabled on Guest Network Tab Disabled on Guest Network Tab Disabled on Guest Network Tab 
EnabledYesNoYesNoYesNo
IP Address
DHCP Start
DHCP End
DNS Server 1
DNS Server 2
Force DNSYesNoYesNoYesNo
Redirect all to VPNYesNoYesNoYesNo
VPN Client No.
Two way to guestYesNoYesNoYesNo
One way to guestYesNoYesNoYesNo
Client isolationYesNoYesNoYesNo
",tablehtml+="
",tablehtml+="",tablehtml}function SetCurrentPage(){document.form.next_page.value=window.location.pathname.substring(1),document.form.current_page.value=window.location.pathname.substring(1)}function ScriptUpdateLayout(){var a=GetVersionNumber("local"),b=GetVersionNumber("server");$j("#yazfi_version_local").text(a),a!=b&&"N/A"!=b&&($j("#yazfi_version_server").text("Updated version available: "+b),showhide("btnChkUpdate",!1),showhide("yazfi_version_server",!0),showhide("btnDoUpdate",!0))}function update_status(){$j.ajax({url:"/ext/YazFi/detect_update.js",dataType:"script",error:function(){setTimeout(update_status,1e3)},success:function(){"InProgress"==updatestatus?setTimeout(update_status,1e3):(document.getElementById("imgChkUpdate").style.display="none",showhide("yazfi_version_server",!0),"None"==updatestatus?($j("#yazfi_version_server").text("No update available"),showhide("btnChkUpdate",!0),showhide("btnDoUpdate",!1)):($j("#yazfi_version_server").text("Updated version available: "+updatestatus),showhide("btnChkUpdate",!1),showhide("btnDoUpdate",!0)))}})}function CheckUpdate(){showhide("btnChkUpdate",!1),document.formScriptActions.action_script.value="start_YazFicheckupdate",document.formScriptActions.submit(),document.getElementById("imgChkUpdate").style.display="",setTimeout(update_status,2e3)}function DoUpdate(){document.form.action_script.value="start_YazFidoupdate",document.form.action_wait.value=45,showLoading(),document.form.submit()}function GetVersionNumber(a){var b;return"local"==a?b=custom_settings.yazfi_version_local:"server"==a&&(b=custom_settings.yazfi_version_server),"undefined"==typeof b||null==b?"N/A":b}function GetCookie(a,b){if(null!=cookie.get("yazfi_"+a))return cookie.get("yazfi_"+a);return"string"==b?"":"number"==b?0:void 0}function SetCookie(a,b){cookie.set("yazfi_"+a,b,3650)}function SaveConfig(){return!!Validate_All()&&void($j("[name*=yazfi_]").prop("disabled",!1),document.getElementById("amng_custom").value=JSON.stringify($j("form").serializeObject()),document.form.action_script.value="start_YazFi",document.form.action_wait.value=45,$j("#auto_refresh").prop("checked",!1),clearTimeout(tout),showLoading(),document.form.submit())}function AddEventHandlers(){$j(".collapsible-jquery").off("click").on("click",function(){$j(this).siblings().toggle("fast",function(){"none"==$j(this).css("display")?SetCookie($j(this).siblings()[0].id,"collapsed"):SetCookie($j(this).siblings()[0].id,"expanded")})}),$j(".collapsible-jquery").each(function(){"collapsed"==GetCookie($j(this)[0].id,"string")?$j(this).siblings().toggle(!1):$j(this).siblings().toggle(!0)}),$j("#auto_refresh").off("click").on("click",function(){ToggleRefresh()})}function ToggleRefresh(){!0==$j("#auto_refresh").prop("checked")?(document.formScriptActions.action_script.value="start_YazFiconnectedclients",document.formScriptActions.submit(),tout=setTimeout(get_connected_clients_file,5e3)):clearTimeout(tout)}$j.fn.serializeObject=function(){var b=custom_settings,c=this.serializeArray();return $j.each(c,function(){void 0!==b[this.name]&&-1!=this.name.indexOf("yazfi")&&-1==this.name.indexOf("version")?(!b[this.name].push&&(b[this.name]=[b[this.name]]),b[this.name].push(this.value||"")):-1!=this.name.indexOf("yazfi")&&-1==this.name.indexOf("version")&&(b[this.name]=this.value||"")}),b};function StoHHMMSS(a){var b=parseInt(a,10),c=Math.floor(b/3600),d=Math.floor(b/60)%60;return[c,d,b%60].map(a=>10>a?"0"+a:a).filter((a,b)=>"00"!==a||0=i2;i2++)"yazfi_wl"+i.toString()+i2.toString()+"_ipaddr"!=inputname&&eval("document.form.yazfi_wl"+i.toString()+i2.toString()+"_ipaddr.value")==fixedip&&(matchfound=!0);return matchfound?($j(forminput).addClass("invalid"),failedfields.push([$j(forminput),"Conflict with another YazFi network"]),$j(forminput).on("mouseover",function(){return overlib("Conflict with another YazFi network",0,0)}),$j(forminput)[0].onmouseout=nd,!1):($j(forminput).removeClass("invalid"),$j(forminput).off("mouseover"),!0)}return $j(forminput).addClass("invalid"),failedfields.push([$j(forminput),"LAN IP conflict"]),$j(forminput).on("mouseover",function(){return overlib("LAN IP conflict",0,0)}),$j(forminput)[0].onmouseout=nd,!1}return $j(forminput).addClass("invalid"),failedfields.push([$j(forminput),"Not a private IP address"]),$j(forminput).on("mouseover",function(){return overlib("Not a private IP address",0,0)}),$j(forminput)[0].onmouseout=nd,!1}return $j(forminput).removeClass("invalid"),$j(forminput).off("mouseover"),!0}return $j(forminput).addClass("invalid"),failedfields.push([$j(forminput),"Invalid IP Address"]),$j(forminput).on("mouseover",function(){return overlib("Invalid IP Address",0,0)}),$j(forminput)[0].onmouseout=nd,!1}function Validate_DHCP(forminput){var startend="",inputname=forminput.name,inputvalue=1*forminput.value;return startend=-1==inputname.indexOf("start")?"end":"start","start"==startend?inputvalue>=1*eval("document.form."+inputname.substring(0,inputname.indexOf("start"))+"end.value")?($j(forminput).addClass("invalid"),failedfields.push([$j(forminput),"DHCP start is greater than DHCP end"]),$j(forminput).on("mouseover",function(){return overlib("DHCP start is greater than DHCP end",0,0)}),$j(forminput)[0].onmouseout=nd,!1):254inputvalue?($j(forminput).addClass("invalid"),failedfields.push([$j(forminput),"Value not between 2 and 254"]),$j(forminput).on("mouseover",function(){return overlib("Value not between 2 and 254",0,0)}),$j(forminput)[0].onmouseout=nd,!1):($j(forminput).removeClass("invalid"),$j(forminput).off("mouseover"),!0):inputvalue<=1*eval("document.form."+inputname.substring(0,inputname.indexOf("end"))+"start.value")?($j(forminput).addClass("invalid"),failedfields.push([$j(forminput),"DHCP end is less than DHCP start"]),$j(forminput).on("mouseover",function(){return overlib("DHCP end is less than DHCP start",0,0)}),$j(forminput)[0].onmouseout=nd,!1):254inputvalue?($j(forminput).addClass("invalid"),failedfields.push([$j(forminput),"Value not between 2 and 254"]),$j(forminput).on("mouseover",function(){return overlib("Value not between 2 and 254",0,0)}),$j(forminput)[0].onmouseout=nd,!1):($j(forminput).removeClass("invalid"),$j(forminput).off("mouseover"),!0)}function Validate_VPNClientNo(a){var b=a.name,c=1*a.value;return 5c?($j(a).addClass("invalid"),failedfields.push([$j(a),"Value not between 1 and 5"]),$j(a).on("mouseover",function(){return overlib("Value not between 1 and 5",0,0)}),$j(a)[0].onmouseout=nd,!1):($j(a).removeClass("invalid"),$j(a).off("mouseover"),!0)}function Validate_OneTwoWay(forminput){var onetwo="",inputname=forminput.name,inputvalue=forminput.value;onetwo=-1==inputname.indexOf("oneway")?"two":"one","one"==onetwo?"true"==inputvalue&&eval("document.form."+inputname.substring(0,inputname.indexOf("one"))+"twowaytoguest.value=false"):"true"==inputvalue&&eval("document.form."+inputname.substring(0,inputname.indexOf("two"))+"onewaytoguest.value=false")}function Validate_All(){var validationfailed=!1;failedfields=[];for(var i=0;i=i2;i2++)Validate_IP(eval("document.form.yazfi_wl"+i+i2+"_ipaddr"),"IP")||(validationfailed=!0),Validate_DHCP(eval("document.form.yazfi_wl"+i+i2+"_dhcpstart"))||(validationfailed=!0),Validate_DHCP(eval("document.form.yazfi_wl"+i+i2+"_dhcpend"))||(validationfailed=!0),Validate_IP(eval("document.form.yazfi_wl"+i+i2+"_dns1"),"DNS")||(validationfailed=!0),Validate_IP(eval("document.form.yazfi_wl"+i+i2+"_dns2"),"DNS")||(validationfailed=!0),Validate_VPNClientNo(eval("document.form.yazfi_wl"+i+i2+"_vpnclientnumber"))||(validationfailed=!0);for(var failedfieldsstring="",i=0;i"),$j("#table_config").append(BuildConfigTable("wl1","5GHz Guest Networks"))):(wl_info.band2g_support&&($j("#table_config").append(BuildConfigTable("wl0","2.4GHz Guest Networks")),++bands),wl_info.band5g_support&&($j("#table_config").append(""),$j("#table_config").append(BuildConfigTable("wl1","5GHz Guest Networks")),++bands),wl_info.band5g_2_support&&($j("#table_config").append(""),$j("#table_config").append(BuildConfigTable("wl2","5GHz-2 Guest Networks")),++bands)),$j("#table_config").append("");var buttonshtml="";buttonshtml+="",$j("#table_config").append(buttonshtml);for(var settingcount=3*(12*bands),i=0;i1*$j("#firmver").text()&&("RT-AX88U"==productid||"RT-AX3000"==productid)&&($j("input[name*=clientisolation][value=false]").prop("checked",!0),$j("input[name*=clientisolation]").attr("disabled",!0));for(var i=0;i=i2;i2++)0==eval("document.form.wl"+i+i2+"_bss_enabled").value&&(OptionsEnableDisable($j("#yazfi_wl"+i+i2+"_en_false")[0]),$j("input[name=yazfi_wl"+i+i2+"_enabled]").prop("disabled",!0))}})}function get_connected_clients_file(){d3.csv("/ext/YazFi/connectedclients.htm").then(function(data){if(0=i2;i2++)YazFiInterface="wl"+i.toString()+i2.toString(),window["clients"+YazFiInterface]=data.filter(function(a){return a.INTERFACE.replace(".","")==YazFiInterface}).map(function(a){return{Hostname:a.HOSTNAME,IPAddress:a.IP,MACAddress:a.MAC,Connected:a.CONNECTED,Rx:a.RX,Tx:a.TX,RSSI:a.RSSI,PHY:a.PHY}}),"true"==eval("document.form.yazfi_"+YazFiInterface+"_enabled.value")&&1==eval("document.form."+YazFiInterface+"_bss_enabled.value")&&($j("#table_connectedclients").append(BuildConnectedClientPlaceholderTable(YazFiInterface,eval("document.form."+YazFiInterface+"_ssid.value"))),0 (a."+sortfield+".toLowerCase() > b."+sortfield+".toLowerCase()) ? 1 : ((b."+sortfield+".toLowerCase() > a."+sortfield+".toLowerCase()) ? -1 : 0));"),window[sortdir]="asc"):-1==sorttext.indexOf("\u2193")?(eval(arrayid+" = "+arrayid+".sort((a,b) => (a."+sortfield+".toLowerCase() < b."+sortfield+".toLowerCase()) ? 1 : ((b."+sortfield+".toLowerCase() < a."+sortfield+".toLowerCase()) ? -1 : 0));"),window[sortdir]="desc"):(eval(arrayid+" = "+arrayid+".sort((a,b) => (a."+sortfield+".toLowerCase() > b."+sortfield+".toLowerCase()) ? 1 : ((b."+sortfield+".toLowerCase() > a."+sortfield+".toLowerCase()) ? -1 : 0));"),window[sortdir]="asc"):"number"==sorttype?-1==sorttext.indexOf("\u2193")&&-1==sorttext.indexOf("\u2191")?(eval(arrayid+" = "+arrayid+".sort((a,b) => parseFloat(a."+sortfield+".replace(\"m\",\"000\")) - parseFloat(b."+sortfield+".replace(\"m\",\"000\")));"),window[sortdir]="asc"):-1==sorttext.indexOf("\u2193")?(eval(arrayid+" = "+arrayid+".sort((a,b) => parseFloat(b."+sortfield+".replace(\"m\",\"000\")) - parseFloat(a."+sortfield+".replace(\"m\",\"000\")));"),window[sortdir]="desc"):(eval(arrayid+" = "+arrayid+".sort((a,b) => parseFloat(a."+sortfield+".replace(\"m\",\"000\")) - parseFloat(b."+sortfield+".replace(\"m\",\"000\")));"),window[sortdir]="asc"):"time"==sorttype&&(-1==sorttext.indexOf("\u2193")&&-1==sorttext.indexOf("\u2191")?(eval(arrayid+" = "+arrayid+".sort((a,b) => parseFloat(HHMMSStoS(a."+sortfield+".replace(\"m\",\"000\"))) - parseFloat(HHMMSStoS(b."+sortfield+".replace(\"m\",\"000\"))));"),window[sortdir]="asc"):-1==sorttext.indexOf("\u2193")?(eval(arrayid+" = "+arrayid+".sort((a,b) => parseFloat(HHMMSStoS(b."+sortfield+".replace(\"m\",\"000\"))) - parseFloat(HHMMSStoS(a."+sortfield+".replace(\"m\",\"000\"))));"),window[sortdir]="desc"):(eval(arrayid+" = "+arrayid+".sort((a,b) => parseFloat(HHMMSStoS(a."+sortfield+".replace(\"m\",\"000\"))) - parseFloat(HHMMSStoS(b."+sortfield+".replace(\"m\",\"000\"))));"),window[sortdir]="asc")),$j("#"+tableid).empty(),$j("#"+tableid).append(BuildConnectedClientsTable(tableid.replace("sortTable",""))),$j("#"+tableid).find(".sortable").each(function(a,b){b.innerHTML.replace(/ \(.*\)/,"").replace(" ","")==window[sortname]&&("asc"==window[sortdir]?b.innerHTML+=" \u2191":b.innerHTML+=" \u2193")})}function BuildConnectedClientPlaceholderTable(a,b){var c="
 
";return c+="",c+="",c+="",c+="",c+="",c+="",c+="",c+="",c+="",c+="",c+="
"+b+" (click to expand/collapse)
",c+="
",c+="
",c+="",c+="",c}function BuildConnectedClientsTableNoData(){var a="";return a+="",a+="",a+="",a+="
",a+="No connected clients",a+="
",a}function BuildConnectedClientsTable(a){var b="";b+="",b+="",b+="",b+="",b+="",b+="",b+="",b+="",b+="",b+="",b+="",b+="",b+="",b+="",b+="",b+="",b+="",b+="",b+="",b+="",b+="";for(var c=0;c",b+="",b+="",b+="",b+="",b+="",b+="",b+="",b+="",b+="";return b+="",b+="
HostnameIP AddressMAC AddressConnectedRx (Mbps)Tx (Mbps)RSSI (dBm)PHY
"+window["clients"+a][c].Hostname+""+window["clients"+a][c].IPAddress+""+window["clients"+a][c].MACAddress+""+StoHHMMSS(window["clients"+a][c].Connected)+""+window["clients"+a][c].Rx+""+window["clients"+a][c].Tx+""+window["clients"+a][c].RSSI+""+window["clients"+a][c].PHY+"
",b}function BuildConfigTable(prefix,title){var tablehtml="";tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="
"+title+" (click to expand/collapse)
",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="";var enabled1=eval("document.form."+prefix+"1_bss_enabled.value"),enabled2=eval("document.form."+prefix+"2_bss_enabled.value"),enabled3=eval("document.form."+prefix+"3_bss_enabled.value");return(0==enabled1||0==enabled2||0==enabled3)&&(tablehtml+="",tablehtml+="",tablehtml+=0==enabled1?"":"",tablehtml+=0==enabled2?"":"",tablehtml+=0==enabled3?"":"",tablehtml+=""),tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="",tablehtml+="
 Guest Network 1Guest Network 2Guest Network 3
 "+eval("document.form."+prefix+"1_ssid.value")+""+eval("document.form."+prefix+"2_ssid.value")+""+eval("document.form."+prefix+"3_ssid.value")+"
 Disabled on Guest Network Tab Disabled on Guest Network Tab Disabled on Guest Network Tab 
EnabledYesNoYesNoYesNo
IP Address
DHCP Start
DHCP End
DNS Server 1
DNS Server 2
Force DNSYesNoYesNoYesNo
Redirect all to VPNYesNoYesNoYesNo
VPN Client No.
Two way to guestYesNoYesNoYesNo
One way to guestYesNoYesNoYesNo
Client isolationYesNoYesNoYesNo
",tablehtml+="
",tablehtml+="",tablehtml}function SetCurrentPage(){document.form.next_page.value=window.location.pathname.substring(1),document.form.current_page.value=window.location.pathname.substring(1)}function ScriptUpdateLayout(){var a=GetVersionNumber("local"),b=GetVersionNumber("server");$j("#yazfi_version_local").text(a),a!=b&&"N/A"!=b&&($j("#yazfi_version_server").text("Updated version available: "+b),showhide("btnChkUpdate",!1),showhide("yazfi_version_server",!0),showhide("btnDoUpdate",!0))}function update_status(){$j.ajax({url:"/ext/YazFi/detect_update.js",dataType:"script",error:function(){setTimeout(update_status,1e3)},success:function(){"InProgress"==updatestatus?setTimeout(update_status,1e3):(document.getElementById("imgChkUpdate").style.display="none",showhide("yazfi_version_server",!0),"None"==updatestatus?($j("#yazfi_version_server").text("No update available"),showhide("btnChkUpdate",!0),showhide("btnDoUpdate",!1)):($j("#yazfi_version_server").text("Updated version available: "+updatestatus),showhide("btnChkUpdate",!1),showhide("btnDoUpdate",!0)))}})}function CheckUpdate(){showhide("btnChkUpdate",!1),document.formScriptActions.action_script.value="start_YazFicheckupdate",document.formScriptActions.submit(),document.getElementById("imgChkUpdate").style.display="",setTimeout(update_status,2e3)}function DoUpdate(){document.form.action_script.value="start_YazFidoupdate",document.form.action_wait.value=45,showLoading(),document.form.submit()}function GetVersionNumber(a){var b;return"local"==a?b=custom_settings.yazfi_version_local:"server"==a&&(b=custom_settings.yazfi_version_server),"undefined"==typeof b||null==b?"N/A":b}function GetCookie(a,b){if(null!=cookie.get("yazfi_"+a))return cookie.get("yazfi_"+a);return"string"==b?"":"number"==b?0:void 0}function SetCookie(a,b){cookie.set("yazfi_"+a,b,3650)}function SaveConfig(){return!!Validate_All()&&void($j("[name*=yazfi_]").prop("disabled",!1),document.getElementById("amng_custom").value=JSON.stringify($j("form").serializeObject()),document.form.action_script.value="start_YazFi",document.form.action_wait.value=45,$j("#auto_refresh").prop("checked",!1),clearTimeout(tout),showLoading(),document.form.submit())}function AddEventHandlers(){$j(".collapsible-jquery").off("click").on("click",function(){$j(this).siblings().toggle("fast",function(){"none"==$j(this).css("display")?SetCookie($j(this).siblings()[0].id,"collapsed"):SetCookie($j(this).siblings()[0].id,"expanded")})}),$j(".collapsible-jquery").each(function(){"collapsed"==GetCookie($j(this)[0].id,"string")?$j(this).siblings().toggle(!1):$j(this).siblings().toggle(!0)}),$j("#auto_refresh").off("click").on("click",function(){ToggleRefresh()})}function ToggleRefresh(){!0==$j("#auto_refresh").prop("checked")?(document.formScriptActions.action_script.value="start_YazFiconnectedclients",document.formScriptActions.submit(),tout=setTimeout(get_connected_clients_file,5e3)):clearTimeout(tout)}$j.fn.serializeObject=function(){var b=custom_settings,c=this.serializeArray();return $j.each(c,function(){void 0!==b[this.name]&&-1!=this.name.indexOf("yazfi")&&-1==this.name.indexOf("version")?(!b[this.name].push&&(b[this.name]=[b[this.name]]),b[this.name].push(this.value||"")):-1!=this.name.indexOf("yazfi")&&-1==this.name.indexOf("version")&&(b[this.name]=this.value||"")}),b};function StoHHMMSS(a){var b=parseInt(a,10),c=Math.floor(b/3600),d=Math.floor(b/60)%60;return[c,d,b%60].map(a=>10>a?"0"+a:a).filter((a,b)=>"00"!==a||0 diff --git a/YazFi_www.js b/YazFi_www.js index ed8d17e..9fa5a2a 100644 --- a/YazFi_www.js +++ b/YazFi_www.js @@ -79,8 +79,6 @@ function OptionsEnableDisable(forminput){ $j('input[name='+prefix+'_dhcpend]').prop('disabled',false); $j('input[name='+prefix+'_dns1]').removeClass('disabled'); $j('input[name='+prefix+'_dns1]').prop('disabled',false); - $j('input[name='+prefix+'_dns2]').removeClass('disabled'); - $j('input[name='+prefix+'_dns2]').prop('disabled',false); $j('input[name='+prefix+'_forcedns]').prop('disabled',false); $j('input[name='+prefix+'_redirectalltovpn]').prop('disabled',false); $j('input[name='+prefix+'_onewaytoguest]').prop('disabled',false); @@ -91,6 +89,11 @@ function OptionsEnableDisable(forminput){ $j('input[name='+prefix+'_vpnclientnumber]').removeClass('disabled'); $j('input[name='+prefix+'_vpnclientnumber]').prop('disabled',false); } + + if(eval('document.form.'+prefix+'_forcedns').value == 'false'){ + $j('input[name='+prefix+'_dns2]').removeClass('disabled'); + $j('input[name='+prefix+'_dns2]').prop('disabled',false); + } } } @@ -118,6 +121,7 @@ function ForceDNSEnableDisable(forminput){ if(eval('document.form.'+prefix+'_enabled').value == 'true'){ if(inputvalue == 'true'){ + $j('input[name='+prefix+'_dns2]').val($j('input[name='+prefix+'_dns1]').val()); $j('input[name='+prefix+'_dns2]').addClass('disabled'); $j('input[name='+prefix+'_dns2]').prop('disabled',true); }