Merge pull request #1797 from pi-hole/Ugh/Codacy

Ugh/codacy
This commit is contained in:
Adam Warner 2017-12-07 00:49:59 +00:00 committed by GitHub
commit b3e969f000
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 8 deletions

View file

@ -19,7 +19,6 @@ addmode=true
verbose=true verbose=true
domList=() domList=()
domToRemoveList=()
listMain="" listMain=""
listAlt="" listAlt=""
@ -240,7 +239,6 @@ for var in "$@"; do
"-wild" | "wildcard" ) listMain="${wildcardlist}";; "-wild" | "wildcard" ) listMain="${wildcardlist}";;
"-nr"| "--noreload" ) reload=false;; "-nr"| "--noreload" ) reload=false;;
"-d" | "--delmode" ) addmode=false;; "-d" | "--delmode" ) addmode=false;;
"-f" | "--force" ) force=true;;
"-q" | "--quiet" ) verbose=false;; "-q" | "--quiet" ) verbose=false;;
"-h" | "--help" ) helpFunc;; "-h" | "--help" ) helpFunc;;
"-l" | "--list" ) Displaylist;; "-l" | "--list" ) Displaylist;;

View file

@ -499,7 +499,7 @@ does_ip_match_setup_vars() {
# IP address to check for # IP address to check for
local ip_address="${2}" local ip_address="${2}"
# See what IP is in the setupVars.conf file # See what IP is in the setupVars.conf file
local setup_vars_ip=$(cat ${PIHOLE_SETUP_VARS_FILE} | grep IPV${protocol}_ADDRESS | cut -d '=' -f2) local setup_vars_ip=$(< ${PIHOLE_SETUP_VARS_FILE} grep IPV${protocol}_ADDRESS | cut -d '=' -f2)
# If it's an IPv6 address # If it's an IPv6 address
if [[ "${protocol}" == "6" ]]; then if [[ "${protocol}" == "6" ]]; then
# Strip off the / (CIDR notation) # Strip off the / (CIDR notation)

View file

@ -503,15 +503,21 @@ testIPv6() {
# first will contain fda2 (ULA) # first will contain fda2 (ULA)
first="$(cut -f1 -d":" <<< "$1")" first="$(cut -f1 -d":" <<< "$1")"
# value1 will contain 253 which is the decimal value corresponding to 0xfd # value1 will contain 253 which is the decimal value corresponding to 0xfd
value1=$(((0x$first)/256)) value1=$(( (0x$first)/256 ))
# will contain 162 which is the decimal value corresponding to 0xa2 # will contain 162 which is the decimal value corresponding to 0xa2
value2=$(((0x$first)%256)) value2=$(( (0x$first)%256 ))
# the ULA test is testing for fc00::/7 according to RFC 4193 # the ULA test is testing for fc00::/7 according to RFC 4193
(((value1&254)==252)) && echo "ULA" || true if (( (value1&254)==252 )); then
echo "ULA"
fi
# the GUA test is testing for 2000::/3 according to RFC 4291 # the GUA test is testing for 2000::/3 according to RFC 4291
(((value1&112)==32)) && echo "GUA" || true if (( (value1&112)==32 )); then
echo "GUA"
fi
# the LL test is testing for fe80::/10 according to RFC 4193 # the LL test is testing for fe80::/10 according to RFC 4193
(((value1==254) && ((value2&192)==128))) && echo "Link-local" || true if (( (value1)==254 )) && (( (value2&192)==128 )); then
echo "Link-local"
fi
} }
# A dialog for showing the user about IPv6 blocking # A dialog for showing the user about IPv6 blocking