Configuration for additional clients provided with error — duplicated port in the Endpoint
vasylenko opened this issue · 0 comments
Describe the bug
When an additional client config is created, there's an error in the output: the Endpoint value provided with a duplicated port value, for example:
Endpoint = 17.143.212.215:1023010230
While it should be
Endpoint = 17.143.212.215:10230
To Reproduce
Steps to reproduce the behavior:
Run: NEW_CLIENT_NAME="client-name" wireguard-manager.sh --add
Expected behavior
Client's Endpoint
configuration should be provided without error as: IP:PORT
Additional context
wireguard-manager/wireguard-manager.sh
Line 1575 in dbe16cc
Looks like the bug occurs here, where the SERVER_HOST variable is read from the config file.
The thing is that the field number 4 is already in the format "IP:PORT" (e.g, "17.143.212.215:10230")
SERVER_HOST=$(head --lines=1 ${WIREGUARD_CONFIG} | cut --delimiter=" " --fields=4)
# head --lines=1 /etc/wireguard/wg0.conf
# 10.0.0.0/8 fd00:00:00::0/8 17.143.212.215:10230 KEY_REDACTED 10.0.0.1,fd00:00:00::1 1280 25 0.0.0.0/0,::/0
# head --lines=1 /etc/wireguard/wg0.conf | cut --delimiter=" " --fields=4
17.143.212.215:10230
So when the final configuration is created, it goes as
wireguard-manager/wireguard-manager.sh
Line 1627 in dbe16cc
Endpoint = ${SERVER_HOST}${SERVER_PORT}
Which ultimately makes this port duplication as 17.143.212.215:1023010230