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