1
1
mirror of https://github.com/angristan/wireguard-install.git synced 2024-11-21 20:25:14 +00:00

Forbid interface names exceeding 15 chars in length (#157)

This commit is contained in:
Julian Gaal 2020-11-24 15:33:39 +01:00 committed by GitHub
parent a1b1ac2ece
commit af935850cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -79,7 +79,7 @@ function installQuestions() {
read -rp "Public interface: " -e -i "${SERVER_NIC}" SERVER_PUB_NIC read -rp "Public interface: " -e -i "${SERVER_NIC}" SERVER_PUB_NIC
done done
until [[ ${SERVER_WG_NIC} =~ ^[a-zA-Z0-9_]+$ ]]; do until [[ ${SERVER_WG_NIC} =~ ^[a-zA-Z0-9_]+$ && ${#SERVER_WG_NIC} -lt 16 ]]; do
read -rp "WireGuard interface name: " -e -i wg0 SERVER_WG_NIC read -rp "WireGuard interface name: " -e -i wg0 SERVER_WG_NIC
done done
@ -219,9 +219,9 @@ function newClient() {
echo "" echo ""
echo "Tell me a name for the client." echo "Tell me a name for the client."
echo "The name must consist of alphanumeric character. It may also include an underscore or a dash." echo "The name must consist of alphanumeric character. It may also include an underscore or a dash and can't exceed 15 chars."
until [[ ${CLIENT_NAME} =~ ^[a-zA-Z0-9_-]+$ && ${CLIENT_EXISTS} == '0' ]]; do until [[ ${CLIENT_NAME} =~ ^[a-zA-Z0-9_-]+$ && ${CLIENT_EXISTS} == '0' && ${#CLIENT_NAME} -lt 16 ]]; do
read -rp "Client name: " -e CLIENT_NAME read -rp "Client name: " -e CLIENT_NAME
CLIENT_EXISTS=$(grep -c -E "^### Client ${CLIENT_NAME}\$" "/etc/wireguard/${SERVER_WG_NIC}.conf") CLIENT_EXISTS=$(grep -c -E "^### Client ${CLIENT_NAME}\$" "/etc/wireguard/${SERVER_WG_NIC}.conf")