Quiet all the greps
parent
e4d7140e66
commit
418ba05366
|
@ -45,7 +45,7 @@ token_fail(){
|
||||||
}
|
}
|
||||||
saved_token="$(grep "${ip}" "${TOKENS_FILE}" | cut -f2)"
|
saved_token="$(grep "${ip}" "${TOKENS_FILE}" | cut -f2)"
|
||||||
[ "${saved_token}" == "" ] && token_fail 'missing'
|
[ "${saved_token}" == "" ] && token_fail 'missing'
|
||||||
<<<"${qs}" grep -x "t=${saved_token}" >/dev/null || token_fail 'mismatched'
|
<<<"${qs}" grep -qx "t=${saved_token}" || token_fail 'mismatched'
|
||||||
printf '%s token was valid\n' "${ip}" >>"${LOGFILE}"
|
printf '%s token was valid\n' "${ip}" >>"${LOGFILE}"
|
||||||
|
|
||||||
# Check user
|
# Check user
|
||||||
|
@ -54,7 +54,7 @@ username="$("${LIB_DIR}/ns_lookup_rdns" "${REMOTE_ADDR}" | cut -d'.' -f2)" || (
|
||||||
printf 'User not found' | "${LIB_DIR}/http_res" 403
|
printf 'User not found' | "${LIB_DIR}/http_res" 403
|
||||||
exit 17
|
exit 17
|
||||||
)
|
)
|
||||||
printf '%s identified as %s\n' "${ip}" "${username}" >>"${LOGFILE}"
|
printf '%s identified as %s\n' "${ip}" "${username}" >>"${LOGFILE}"
|
||||||
domain="${hostname}.${username}.${TLD}"
|
domain="${hostname}.${username}.${TLD}"
|
||||||
|
|
||||||
# Check if new peer already exists
|
# Check if new peer already exists
|
||||||
|
@ -75,7 +75,7 @@ ipv6s="$(<<<"${peers}" awk '{print $3}')"
|
||||||
usernumber="$(<<<"${ipv4s}" head -n1 | cut -d'.' -f3)"
|
usernumber="$(<<<"${ipv4s}" head -n1 | cut -d'.' -f3)"
|
||||||
# Increment hostnumber from 1 until an unused one is found
|
# Increment hostnumber from 1 until an unused one is found
|
||||||
used_hostnumbers="$(<<<"${ipv4s}" cut -d'.' -f4 | sort | uniq)"
|
used_hostnumbers="$(<<<"${ipv4s}" cut -d'.' -f4 | sort | uniq)"
|
||||||
hostnumber=1; while <<<"${used_hostnumbers}" grep "${hostnumber}"
|
hostnumber=1; while <<<"${used_hostnumbers}" grep -q "${hostnumber}"
|
||||||
do ((hostnumber++))
|
do ((hostnumber++))
|
||||||
done
|
done
|
||||||
ipv4="${IPV4_NET%.*.*}.${usernumber}.${hostnumber}"
|
ipv4="${IPV4_NET%.*.*}.${usernumber}.${hostnumber}"
|
||||||
|
|
Loading…
Reference in New Issue