Save debug to /tmp/debug.log for WireGuard too, do not use temporary file to redact IPs in the OpenVPN log.

This commit is contained in:
Orazio 2020-10-27 12:19:46 +01:00
parent 8b69904b69
commit 7f1c5ba33c
3 changed files with 12 additions and 8 deletions

View file

@ -32,10 +32,10 @@ function listOVPNFunc {
function debugFunc {
echo "::: Generating Debug Output"
$SUDO ${scriptDir}/${vpn}/pivpnDebug.sh | tee /tmp/debug.txt
$SUDO ${scriptDir}/${vpn}/pivpnDebug.sh | tee /tmp/debug.log
echo "::: "
echo "::: Debug output completed above."
echo "::: Copy saved to /tmp/debug.txt"
echo "::: Copy saved to /tmp/debug.log"
echo "::: "
exit 0
}

View file

@ -34,16 +34,15 @@ echo -e ":::: Having trouble connecting? Take a look at the FAQ:"
echo -e ":::: \e[1mhttps://github.com/pivpn/pivpn/wiki/FAQ\e[0m"
printf "=============================================\n"
echo -e ":::: \e[4mSnippet of the server log\e[0m ::::"
tail -20 /var/log/openvpn.log > /tmp/snippet
OVPNLOG="$(tail -n 20 /var/log/openvpn.log)"
# Regular expession taken from https://superuser.com/a/202835, it will match invalid IPs
# like 123.456.789.012 but it's fine since the log only contains valid ones.
declare -a IPS_TO_HIDE=($(grepcidr -v 10.0.0.0/8,172.16.0.0/12,192.168.0.0/16 /tmp/snippet | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | uniq))
declare -a IPS_TO_HIDE=($(grepcidr -v 10.0.0.0/8,172.16.0.0/12,192.168.0.0/16 <<< "$OVPNLOG" | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | uniq))
for IP in "${IPS_TO_HIDE[@]}"; do
sed -i "s/$IP/REDACTED/g" /tmp/snippet
OVPNLOG="${OVPNLOG//"$IP"/REDACTED}"
done
cat /tmp/snippet
rm /tmp/snippet
echo "$OVPNLOG"
printf "=============================================\n"
echo -e "::::\t\t\e[4mDebug complete\e[0m\t\t ::::"

View file

@ -26,7 +26,12 @@ listConnected(){
}
debug(){
$SUDO ${scriptdir}/${vpn}/pivpnDEBUG.sh
echo "::: Generating Debug Output"
$SUDO ${scriptdir}/${vpn}/pivpnDEBUG.sh | tee /tmp/debug.log
echo "::: "
echo "::: Debug output completed above."
echo "::: Copy saved to /tmp/debug.log"
echo "::: "
exit 0
}