Skip to content

Commit

Permalink
v4.3.4
Browse files Browse the repository at this point in the history
CHANGED: When enabling FORCEDNS, DNS1 is copied to DNS2 and DNS2 is disabled
CHANGED: service-event hook is more selective when it calls YazFi
  • Loading branch information
jackyaz authored Aug 4, 2021
2 parents c131006 + 959e411 commit c5a41d2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 21 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
30 changes: 14 additions & 16 deletions YazFi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
;;
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion YazFi_www.asp

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions YazFi_www.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
}
}

Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit c5a41d2

Please sign in to comment.