1
1
mirror of https://github.com/angristan/wireguard-install.git synced 2024-06-05 21:10:48 +00:00

Add check for existing IPv4 and IPv6

Ask the user again if this is the case
This commit is contained in:
randomshell 2020-07-02 16:20:59 +00:00
parent f80eca7de9
commit dbdce6f98c

View File

@ -27,9 +27,27 @@ function addClient() {
exit 1
fi
read -rp "Client's WireGuard IPv4 " -e -i "${SERVER_WG_IPV4: : -1}2" CLIENT_WG_IPV4
until [[ "$IPV4_EXISTS" == '0' ]]; do
read -rp "Client's WireGuard IPv4 " -e -i "${SERVER_WG_IPV4: : -1}2" CLIENT_WG_IPV4
IPV4_EXISTS=$(grep -c "$CLIENT_WG_IPV4" "/etc/wireguard/$SERVER_WG_NIC.conf")
read -rp "Client's WireGuard IPv6 " -e -i "${SERVER_WG_IPV6: : -1}2" CLIENT_WG_IPV6
if [[ $IPV4_EXISTS == '1' ]]; then
echo ""
echo "A client with the specified IPv4 was already created, please choose another IPv4."
echo ""
fi
done
until [[ "$IPV6_EXISTS" == '0' ]]; do
read -rp "Client's WireGuard IPv6 " -e -i "${SERVER_WG_IPV6: : -1}2" CLIENT_WG_IPV6
IPV6_EXISTS=$(grep -c "$CLIENT_WG_IPV6" "/etc/wireguard/$SERVER_WG_NIC.conf")
if [[ $IPV6_EXISTS == '1' ]]; then
echo ""
echo "A client with the specified IPv6 was already created, please choose another IPv6."
echo ""
fi
done
# Adguard DNS by default
CLIENT_DNS_1="176.103.130.130"