fix: check if selected port is already in use

fixes #68
This commit is contained in:
Ilya Apasov 2021-12-28 10:00:05 +02:00 committed by GitHub
parent f2f0d3d3ac
commit 9fdc122a71
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -240,6 +240,10 @@ if [[ ! -e /etc/wireguard/wg0.conf ]]; then
echo "$port: invalid port."
read -p "Port [51820]: " port
done
until [[ -z "$port" || -z $(lsof -i :"$port") ]]; do
echo "Port $port is already in use. Please select another."
read -p "Port [51820]: " port
done
[[ -z "$port" ]] && port="51820"
echo
echo "Enter a name for the first client:"