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

Add validation on $SERVER_PORT

This commit is contained in:
randomshell 2020-07-02 10:43:15 +00:00
parent aa583ce4b2
commit 1b5288996f

View File

@ -76,8 +76,10 @@ function installWireGuard() {
read -rp "Server's WireGuard IPv6: " -e -i "$SERVER_WG_IPV6" SERVER_WG_IPV6
# Generate random number within private ports range
SERVER_PORT=$(shuf -i49152-65535 -n1)
read -rp "Server's WireGuard port: " -e -i "$SERVER_PORT" SERVER_PORT
RANDOM_PORT=$(shuf -i49152-65535 -n1)
until [[ $SERVER_PORT =~ ^[0-9]+$ ]] && [ "$SERVER_PORT" -ge 1 ] && [ "$SERVER_PORT" -le 65535 ]; do
read -rp "Server's WireGuard port [1-65535]: " -e -i "$RANDOM_PORT" SERVER_PORT
done
# Install WireGuard tools and module
if [[ $OS == 'ubuntu' ]]; then