mirror of
https://github.com/angristan/wireguard-install.git
synced 2024-10-31 18:52:31 +00:00
Add check for WireGuard server IP
Code adapted from angristan/openvpn-install#550. Thanks @TheBritishAccent IPv6 regex tested with fd42:42:42::1 and fdc9:281f:04d7:9ee9::1
This commit is contained in:
parent
1b5288996f
commit
93c49879ea
@ -69,11 +69,13 @@ function installWireGuard() {
|
|||||||
SERVER_WG_NIC="wg0"
|
SERVER_WG_NIC="wg0"
|
||||||
read -rp "WireGuard interface name: " -e -i "$SERVER_WG_NIC" SERVER_WG_NIC
|
read -rp "WireGuard interface name: " -e -i "$SERVER_WG_NIC" SERVER_WG_NIC
|
||||||
|
|
||||||
SERVER_WG_IPV4="10.66.66.1"
|
until [[ "$SERVER_WG_IPV4" =~ ^([0-9]{1,3}\.){3}1$ ]]; do
|
||||||
read -rp "Server's WireGuard IPv4: " -e -i "$SERVER_WG_IPV4" SERVER_WG_IPV4
|
read -rp "Server's WireGuard IPv4 [x.x.x.1]: " -e -i 10.66.66.1 SERVER_WG_IPV4
|
||||||
|
done
|
||||||
|
|
||||||
SERVER_WG_IPV6="fd42:42:42::1"
|
until [[ "$SERVER_WG_IPV6" =~ ^([a-f0-9]{1,4}:){3,4}:1$ ]]; do
|
||||||
read -rp "Server's WireGuard IPv6: " -e -i "$SERVER_WG_IPV6" SERVER_WG_IPV6
|
read -rp "Server's WireGuard IPv6 [x:x:x::1]: " -e -i fd42:42:42::1 SERVER_WG_IPV6
|
||||||
|
done
|
||||||
|
|
||||||
# Generate random number within private ports range
|
# Generate random number within private ports range
|
||||||
RANDOM_PORT=$(shuf -i49152-65535 -n1)
|
RANDOM_PORT=$(shuf -i49152-65535 -n1)
|
||||||
@ -186,11 +188,11 @@ function newClient() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
until [[ "$CLIENT_WG_IPV4" =~ ^([0-9]{1,3}\.?){4}$ ]]; do
|
until [[ "$CLIENT_WG_IPV4" =~ ^([0-9]{1,3}\.?){4}$ ]]; do
|
||||||
read -rp "Client's WireGuard IPv4: " -e -i "${SERVER_WG_IPV4: : -1}"2 CLIENT_WG_IPV4
|
read -rp "Client's WireGuard IPv4: " -e -i "${SERVER_WG_IPV4::-1}"2 CLIENT_WG_IPV4
|
||||||
done
|
done
|
||||||
|
|
||||||
until [[ "$CLIENT_WG_IPV6" =~ ^([a-f0-9]{1,4}:?:?){3,5} ]]; do
|
until [[ "$CLIENT_WG_IPV6" =~ ^([a-f0-9]{1,4}:?:?){3,5} ]]; do
|
||||||
read -rp "Client's WireGuard IPv6 : " -e -i "${SERVER_WG_IPV6: : -1}"2 CLIENT_WG_IPV6
|
read -rp "Client's WireGuard IPv6 : " -e -i "${SERVER_WG_IPV6::-1}"2 CLIENT_WG_IPV6
|
||||||
done
|
done
|
||||||
|
|
||||||
# Adguard DNS by default
|
# Adguard DNS by default
|
||||||
|
Loading…
Reference in New Issue
Block a user