From 171bdb9e6607d6b31f440623770add68275e29c3 Mon Sep 17 00:00:00 2001 From: Omar-AE Date: Wed, 12 Oct 2022 19:35:42 +0300 Subject: [PATCH] Now MAC filter deny is supported. (Only accept was supported.) --- lnxrouter | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/lnxrouter b/lnxrouter index 7e5fda1..8dd1c6b 100755 --- a/lnxrouter +++ b/lnxrouter @@ -179,8 +179,9 @@ define_global_variables(){ WIFI_IFACE= CHANNEL=default WPA_VERSION=2 - MAC_FILTER=0 + MAC_FILTER=3 # 3 is not valid MAC_FILTER_ACCEPT=/etc/hostapd/hostapd.accept + MAC_FILTER_DENY=/etc/hostapd/hostapd.deny IEEE80211N=0 IEEE80211AC=0 HT_CAPAB='[HT40+]' @@ -356,13 +357,34 @@ parse_user_options(){ shift HIDDEN=1 ;; - --mac-filter) + + --mac-filter-accept) shift + if [ "$MAC_FILTER_TYPE" == "deny" ] + then + printf "ERROR: Can't use --mac-filter-accept and --mac-filter-deny together.\n" + exit 1 + fi + MAC_FILTER_TYPE=accept MAC_FILTER=1 + MAC_FILTER_FILE=$MAC_FILTER_ACCEPT ;; - --mac-filter-accept) + + --mac-filter-deny) shift - MAC_FILTER_ACCEPT="$1" + if [ "$MAC_FILTER_TYPE" == "accept" ] + then + printf "ERROR: Can't use --mac-filter-accept and --mac-filter-deny together.\n" + exit 1 + fi + MAC_FILTER_TYPE=deny + MAC_FILTER=0 + MAC_FILTER_FILE=$MAC_FILTER_DENY + ;; + + --mac-filter-file) + shift + MAC_FILTER_FILE="$1" shift ;; @@ -1715,8 +1737,15 @@ write_hostapd_conf() { if [[ $MAC_FILTER -eq 1 ]]; then cat <<- EOF >> "$CONFDIR/hostapd.conf" - macaddr_acl=${MAC_FILTER} - accept_mac_file=${MAC_FILTER_ACCEPT} + macaddr_acl=1 + accept_mac_file=${MAC_FILTER_FILE} + EOF + fi + + if [[ $MAC_FILTER -eq 0 ]]; then + cat <<- EOF >> "$CONFDIR/hostapd.conf" + macaddr_acl=0 + deny_mac_file=${MAC_FILTER_FILE} EOF fi