mirror of
https://github.com/angristan/wireguard-install.git
synced 2024-11-24 05:56:02 +03:00
Improve IP parsing (fix #204)
This commit is contained in:
parent
9fae7ad587
commit
bd37d606f1
@ -245,10 +245,11 @@ function newClient() {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
BASE_IP=$(echo "$SERVER_WG_IPV4" | awk -F '.' '{ print $1"."$2"."$3 }')
|
||||||
until [[ ${IPV4_EXISTS} == '0' ]]; do
|
until [[ ${IPV4_EXISTS} == '0' ]]; do
|
||||||
read -rp "Client's WireGuard IPv4: ${SERVER_WG_IPV4::-1}" -e -i "${DOT_IP}" DOT_IP
|
read -rp "Client's WireGuard IPv4: ${BASE_IP}." -e -i "${DOT_IP}" DOT_IP
|
||||||
CLIENT_WG_IPV4="${SERVER_WG_IPV4::-1}${DOT_IP}"
|
CLIENT_WG_IPV4="${BASE_IP}.${DOT_IP}"
|
||||||
IPV4_EXISTS=$(grep -c "$CLIENT_WG_IPV4" "/etc/wireguard/${SERVER_WG_NIC}.conf")
|
IPV4_EXISTS=$(grep -c "$CLIENT_WG_IPV4/24" "/etc/wireguard/${SERVER_WG_NIC}.conf")
|
||||||
|
|
||||||
if [[ ${IPV4_EXISTS} == '1' ]]; then
|
if [[ ${IPV4_EXISTS} == '1' ]]; then
|
||||||
echo ""
|
echo ""
|
||||||
@ -257,10 +258,11 @@ function newClient() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
BASE_IP=$(echo "$SERVER_WG_IPV6" | awk -F '::' '{ print $1 }')
|
||||||
until [[ ${IPV6_EXISTS} == '0' ]]; do
|
until [[ ${IPV6_EXISTS} == '0' ]]; do
|
||||||
read -rp "Client's WireGuard IPv6: ${SERVER_WG_IPV6::-1}" -e -i "${DOT_IP}" DOT_IP
|
read -rp "Client's WireGuard IPv6: ${BASE_IP}::" -e -i "${DOT_IP}" DOT_IP
|
||||||
CLIENT_WG_IPV6="${SERVER_WG_IPV6::-1}${DOT_IP}"
|
CLIENT_WG_IPV6="${BASE_IP}::${DOT_IP}"
|
||||||
IPV6_EXISTS=$(grep -c "${CLIENT_WG_IPV6}" "/etc/wireguard/${SERVER_WG_NIC}.conf")
|
IPV6_EXISTS=$(grep -c "${CLIENT_WG_IPV6}/64" "/etc/wireguard/${SERVER_WG_NIC}.conf")
|
||||||
|
|
||||||
if [[ ${IPV6_EXISTS} == '1' ]]; then
|
if [[ ${IPV6_EXISTS} == '1' ]]; then
|
||||||
echo ""
|
echo ""
|
||||||
|
Loading…
Reference in New Issue
Block a user