mirror of
https://github.com/pcvolkmer/docker-wireguard-boringtun.git
synced 2025-04-19 21:36:49 +00:00
Print which client uses already given public key
This commit is contained in:
parent
d47e1a1a23
commit
2fe5f14383
@ -20,9 +20,11 @@ if [ -z $1 ]; then
|
|||||||
CLIENT_PUB_KEY=$(echo $CLIENT_SEC_KEY | wg pubkey)
|
CLIENT_PUB_KEY=$(echo $CLIENT_SEC_KEY | wg pubkey)
|
||||||
else
|
else
|
||||||
# Check if public key is already used
|
# Check if public key is already used
|
||||||
for key in $(cat $DEVICE.conf | grep "PublicKey = " | sed "s/PublicKey = \(.*\)$/\1/"); do
|
clients=($(cat $DEVICE.conf | grep "# Client" | sed "s/# Client \([0-9]*\)$/\1/"))
|
||||||
if [[ "$1" == "$key" ]]; then
|
keys=($(cat $DEVICE.conf | grep "PublicKey = " | sed "s/PublicKey = \(.*\)$/\1/"))
|
||||||
echo "Key '$1' already used!"
|
for i in "${!keys[@]}"; do
|
||||||
|
if [[ "$1" = "${keys[$i]}" ]]; then
|
||||||
|
echo "Key '$1' already used in 'Client ${clients[$i]}'"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
Loading…
x
Reference in New Issue
Block a user