From 7865df2c00fa4844020aca0469c691033bcdf728 Mon Sep 17 00:00:00 2001 From: Nyr Date: Thu, 19 Oct 2023 20:56:55 +0200 Subject: [PATCH] Fix #114 --- wireguard-install.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/wireguard-install.sh b/wireguard-install.sh index c194cf7..7df8744 100644 --- a/wireguard-install.sh +++ b/wireguard-install.sh @@ -250,8 +250,8 @@ if [[ ! -e /etc/wireguard/wg0.conf ]]; then echo echo "Enter a name for the first client:" read -p "Name [client]: " unsanitized_client - # Allow a limited set of characters to avoid conflicts - client=$(sed 's/[^0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-]/_/g' <<< "$unsanitized_client") + # Allow a limited lenght and set of characters to avoid conflicts + client=$(sed 's/[^0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-]/_/g' <<< "$unsanitized_client" | cut -c-15) [[ -z "$client" ]] && client="client" echo new_client_dns @@ -546,12 +546,12 @@ else echo echo "Provide a name for the client:" read -p "Name: " unsanitized_client - # Allow a limited set of characters to avoid conflicts - client=$(sed 's/[^0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-]/_/g' <<< "$unsanitized_client") + # Allow a limited lenght and set of characters to avoid conflicts + client=$(sed 's/[^0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-]/_/g' <<< "$unsanitized_client" | cut -c-15) while [[ -z "$client" ]] || grep -q "^# BEGIN_PEER $client$" /etc/wireguard/wg0.conf; do echo "$client: invalid name." read -p "Name: " unsanitized_client - client=$(sed 's/[^0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-]/_/g' <<< "$unsanitized_client") + client=$(sed 's/[^0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-]/_/g' <<< "$unsanitized_client" | cut -c-15) done echo new_client_dns