1
1
mirror of https://github.com/angristan/wireguard-install.git synced 2024-05-31 18:50:47 +00:00

Add validation on DNS input

Fixes #68

Co-authored-by: Chris Lewicki <chris@lewicki.dev>
This commit is contained in:
randomshell 2020-07-02 10:10:53 +00:00
parent 1c77cb7073
commit 9c6576dfc9

View File

@ -192,11 +192,15 @@ function newClient() {
read -rp "Client's WireGuard IPv6 " -e -i "$CLIENT_WG_IPV6" CLIENT_WG_IPV6
# Adguard DNS by default
CLIENT_DNS_1="176.103.130.130"
read -rp "First DNS resolver to use for the client: " -e -i "$CLIENT_DNS_1" CLIENT_DNS_1
CLIENT_DNS_2="176.103.130.131"
read -rp "Second DNS resolver to use for the client: " -e -i "$CLIENT_DNS_2" CLIENT_DNS_2
until [[ $CLIENT_DNS_1 =~ ^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$ ]]; do
read -rp "First DNS resolver to use for the client: " -e -i 176.103.130.130 CLIENT_DNS_1
done
until [[ $CLIENT_DNS_2 =~ ^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$ ]]; do
read -rp "Second DNS resolver to use for the client (optional): " -e -i 176.103.130.131 CLIENT_DNS_2
if [[ $CLIENT_DNS_2 == "" ]]; then
CLIENT_DNS_2=$CLIENT_DNS_1
fi
done
CLIENT_NAME=$(
head /dev/urandom | tr -dc A-Za-z0-9 | head -c 10
@ -265,4 +269,4 @@ if [[ -e /etc/wireguard/params ]]; then
manageMenu
else
installWireGuard
fi
fi