Merge branch 'test' into wg_ipv6_client_config

This commit is contained in:
DerDanilo 2022-03-10 10:56:50 +01:00 committed by GitHub
commit 642aa383a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 12 deletions

View file

@ -34,7 +34,7 @@ PKG_INSTALL="${PKG_MANAGER} --yes --no-install-recommends install"
PKG_COUNT="${PKG_MANAGER} -s -o Debug::NoLocking=true upgrade | grep -c ^Inst || true"
# Dependencies that are required by the script, regardless of the VPN protocol chosen
BASE_DEPS=(git tar curl grep dnsutils whiptail net-tools bsdmainutils bash-completion)
BASE_DEPS=(git tar curl grep dnsutils grepcidr whiptail net-tools bsdmainutils bash-completion)
# Dependencies that where actually installed by the script. For example if the script requires
# grep and dnsutils but dnsutils is already installed, we save grep here. This way when uninstalling
@ -1150,13 +1150,38 @@ setVPNDefaultVars(){
fi
}
generateRandomSubnet() {
# Source: https://community.openvpn.net/openvpn/wiki/AvoidRoutingConflicts
declare -a SUBNET_EXCLUDE_LIST=(10.0.0.0/24 10.0.1.0/24 10.1.1.0/24 10.1.10.0/24 10.2.0.0/24 10.8.0.0/24 10.10.1.0/24 10.90.90.0/24 10.100.1.0/24 10.255.255.0/24)
readarray -t CURRENTLY_USED_SUBNETS <<< "$(ip route show | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\/[0-9]{1,2}')"
SUBNET_EXCLUDE_LIST=("${SUBNET_EXCLUDE_LIST[@]}" "${CURRENTLY_USED_SUBNETS[@]}")
local MATCHES
while true; do
MATCHES=0
pivpnNET="10.$((RANDOM%256)).$((RANDOM%256)).0"
for SUB in "${SUBNET_EXCLUDE_LIST[@]}"; do
if grepcidr "${SUB}" <<< "${pivpnNET}/$subnetClass" 2>&1 > /dev/null; then
((MATCHES++))
fi
done
if [ "${MATCHES}" -eq 0 ]; then
break
fi
done
echo "${pivpnNET}"
}
setOpenVPNDefaultVars(){
pivpnDEV="tun0"
# Allow custom NET via unattend setupVARs file. Use default if not provided.
if [ -z "$pivpnNET" ]; then
pivpnNET="10.8.0.0"
pivpnNET="$(generateRandomSubnet)"
fi
vpnGw="${pivpnNET/.0.0/.0.1}"
vpnGw="$(cut -d '.' -f 1-3 <<< "${pivpnNET}").1"
}
setWireguardDefaultVars(){
@ -1166,12 +1191,12 @@ setWireguardDefaultVars(){
pivpnDEV="wg0"
# Allow custom NET via unattend setupVARs file. Use default if not provided.
if [ -z "$pivpnNET" ]; then
pivpnNET="10.6.0.0"
pivpnNET="$(generateRandomSubnet)"
fi
if [ "$pivpnenableipv6" == "1" ] && [ -z "$pivpnNETv6" ]; then
pivpnNETv6="fd11:5ee:bad:c0de::"
fi
vpnGw="${pivpnNET/.0.0/.0.1}"
vpnGw="$(cut -d '.' -f 1-3 <<< "${pivpnNET}").1"
if [ "$pivpnenableipv6" == "1" ]; then
vpnGwv6="${pivpnNETv6}1"
fi
@ -1315,9 +1340,8 @@ installOpenVPN(){
updatePackageCache
fi
# grepcidr is used to redact IPs in the debug log whereas expect is used
# to feed easy-rsa with passwords
PIVPN_DEPS=(openvpn grepcidr expect)
# Expect is used to feed easy-rsa with passwords
PIVPN_DEPS=(openvpn expect)
installDependentPackages PIVPN_DEPS[@]
}

View file

@ -134,7 +134,7 @@ for (( ii = 0; ii < ${#CERTS_TO_REVOKE[@]}; ii++)); do
if [ -n "$CONFIRM" ]; then
REPLY="y"
else
read -r -p "Do you really want to revoke '${CERTS_TO_REVOKE[ii]}'? [Y/n] "
read -r -p "Do you really want to revoke '${CERTS_TO_REVOKE[ii]}'? [y/N] "
fi
if [[ $REPLY =~ ^[Yy]$ ]]; then
printf "\n::: Revoking certificate '%s'. \n" "${CERTS_TO_REVOKE[ii]}"

View file

@ -92,8 +92,8 @@ showHelp(){
echo "::: -l, list List all clients"
echo "::: -qr, qrcode Show the qrcode of a client for use with the mobile app"
echo "::: -r, remove Remove a client"
echo "::: -off, off Disable a user"
echo "::: -on, on Enable a user"
echo "::: -off, off Disable a client"
echo "::: -on, on Enable a client"
echo "::: -h, help Show this help dialog"
echo "::: -u, uninstall Uninstall pivpn from your system!"
echo "::: -up, update Updates PiVPN Scripts"

View file

@ -47,7 +47,7 @@ else
fi
printf "=============================================\n"
echo -e ":::: \t\e[4mRecursive list of files in\e[0m\t ::::\n::::\e\t[4m/etc/wireguard shown below\e[0m\t ::::"
echo -e ":::: \t\e[4mRecursive list of files in\e[0m\t ::::\n::::\t\e[4m/etc/wireguard shown below\e[0m\t ::::"
ls -LR /etc/wireguard
printf "=============================================\n"
echo -e "::::\t\t\e[4mSelf check\e[0m\t\t ::::"