diff --git a/scripts/openvpn/pivpn.sh b/scripts/openvpn/pivpn.sh index 0b7feb7..59ca5c1 100755 --- a/scripts/openvpn/pivpn.sh +++ b/scripts/openvpn/pivpn.sh @@ -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 } diff --git a/scripts/openvpn/pivpnDebug.sh b/scripts/openvpn/pivpnDebug.sh index 38a8d7e..46d5edd 100755 --- a/scripts/openvpn/pivpnDebug.sh +++ b/scripts/openvpn/pivpnDebug.sh @@ -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 ::::" diff --git a/scripts/wireguard/pivpn.sh b/scripts/wireguard/pivpn.sh index 61db6d9..ad4b0e7 100755 --- a/scripts/wireguard/pivpn.sh +++ b/scripts/wireguard/pivpn.sh @@ -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 }