mirror of
https://github.com/hwdsl2/setup-ipsec-vpn.git
synced 2026-05-16 23:55:44 +03:00
Improve IPv6 check
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
# The latest version of this script is available at:
|
||||
# https://github.com/hwdsl2/setup-ipsec-vpn
|
||||
#
|
||||
# Copyright (C) 2021-2025 Lin Song <linsongui@gmail.com>
|
||||
# Copyright (C) 2021-2026 Lin Song <linsongui@gmail.com>
|
||||
#
|
||||
# This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
|
||||
# Unported License: http://creativecommons.org/licenses/by-sa/3.0/
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
# The latest version of this script is available at:
|
||||
# https://github.com/hwdsl2/setup-ipsec-vpn
|
||||
#
|
||||
# Copyright (C) 2021-2025 Lin Song <linsongui@gmail.com>
|
||||
# Copyright (C) 2021-2026 Lin Song <linsongui@gmail.com>
|
||||
#
|
||||
# This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
|
||||
# Unported License: http://creativecommons.org/licenses/by-sa/3.0/
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
# The latest version of this script is available at:
|
||||
# https://github.com/hwdsl2/setup-ipsec-vpn
|
||||
#
|
||||
# Copyright (C) 2020-2025 Lin Song <linsongui@gmail.com>
|
||||
# Copyright (C) 2020-2026 Lin Song <linsongui@gmail.com>
|
||||
#
|
||||
# This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
|
||||
# Unported License: http://creativecommons.org/licenses/by-sa/3.0/
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
# The latest version of this script is available at:
|
||||
# https://github.com/hwdsl2/setup-ipsec-vpn
|
||||
#
|
||||
# Copyright (C) 2016-2025 Lin Song <linsongui@gmail.com>
|
||||
# Copyright (C) 2016-2026 Lin Song <linsongui@gmail.com>
|
||||
#
|
||||
# This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
|
||||
# Unported License: http://creativecommons.org/licenses/by-sa/3.0/
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
# The latest version of this script is available at:
|
||||
# https://github.com/hwdsl2/setup-ipsec-vpn
|
||||
#
|
||||
# Copyright (C) 2016-2025 Lin Song <linsongui@gmail.com>
|
||||
# Copyright (C) 2016-2026 Lin Song <linsongui@gmail.com>
|
||||
#
|
||||
# This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
|
||||
# Unported License: http://creativecommons.org/licenses/by-sa/3.0/
|
||||
|
||||
@@ -200,11 +200,10 @@ detect_ipv6() {
|
||||
fi
|
||||
if [ -n "$VPN_PUBLIC_IP6" ]; then
|
||||
ip6="$VPN_PUBLIC_IP6"
|
||||
check_ip6 "$ip6" || exiterr "Invalid IPv6 address. Check variable 'VPN_PUBLIC_IP6'."
|
||||
else
|
||||
ip6_addr=$(ip -6 addr 2>/dev/null | awk '/inet6 [23]/ {print $2}' | cut -d'/' -f1 | head -n1)
|
||||
[ -n "$ip6_addr" ] && ip6="$ip6_addr"
|
||||
check_ip6 "$ip6" || { echo "Warning: Invalid IPv6 address in 'VPN_PUBLIC_IP6'. Detecting IPv6..." >&2; ip6=""; }
|
||||
fi
|
||||
[ -z "$ip6" ] && ip6=$(ip -6 addr 2>/dev/null | awk '/inet6 [23]/ {print $2}' | cut -d'/' -f1 | head -n1)
|
||||
check_ip6 "$ip6" || ip6=""
|
||||
}
|
||||
|
||||
install_vpn_pkgs() {
|
||||
|
||||
@@ -187,11 +187,10 @@ detect_ipv6() {
|
||||
fi
|
||||
if [ -n "$VPN_PUBLIC_IP6" ]; then
|
||||
ip6="$VPN_PUBLIC_IP6"
|
||||
check_ip6 "$ip6" || exiterr "Invalid IPv6 address. Check variable 'VPN_PUBLIC_IP6'."
|
||||
else
|
||||
ip6_addr=$(ip -6 addr 2>/dev/null | awk '/inet6 [23]/ {print $2}' | cut -d'/' -f1 | head -n1)
|
||||
[ -n "$ip6_addr" ] && ip6="$ip6_addr"
|
||||
check_ip6 "$ip6" || { echo "Warning: Invalid IPv6 address in 'VPN_PUBLIC_IP6'. Detecting IPv6..." >&2; ip6=""; }
|
||||
fi
|
||||
[ -z "$ip6" ] && ip6=$(ip -6 addr 2>/dev/null | awk '/inet6 [23]/ {print $2}' | cut -d'/' -f1 | head -n1)
|
||||
check_ip6 "$ip6" || ip6=""
|
||||
}
|
||||
|
||||
add_epel_repo() {
|
||||
|
||||
@@ -241,11 +241,10 @@ detect_ipv6() {
|
||||
fi
|
||||
if [ -n "$VPN_PUBLIC_IP6" ]; then
|
||||
ip6="$VPN_PUBLIC_IP6"
|
||||
check_ip6 "$ip6" || exiterr "Invalid IPv6 address. Check variable 'VPN_PUBLIC_IP6'."
|
||||
else
|
||||
ip6_addr=$(ip -6 addr 2>/dev/null | awk '/inet6 [23]/ {print $2}' | cut -d'/' -f1 | head -n1)
|
||||
[ -n "$ip6_addr" ] && ip6="$ip6_addr"
|
||||
check_ip6 "$ip6" || { echo "Warning: Invalid IPv6 address in 'VPN_PUBLIC_IP6'. Detecting IPv6..." >&2; ip6=""; }
|
||||
fi
|
||||
[ -z "$ip6" ] && ip6=$(ip -6 addr 2>/dev/null | awk '/inet6 [23]/ {print $2}' | cut -d'/' -f1 | head -n1)
|
||||
check_ip6 "$ip6" || ip6=""
|
||||
}
|
||||
|
||||
add_epel_repo() {
|
||||
|
||||
@@ -265,11 +265,10 @@ detect_ipv6() {
|
||||
fi
|
||||
if [ -n "$VPN_PUBLIC_IP6" ]; then
|
||||
ip6="$VPN_PUBLIC_IP6"
|
||||
check_ip6 "$ip6" || exiterr "Invalid IPv6 address. Check variable 'VPN_PUBLIC_IP6'."
|
||||
else
|
||||
ip6_addr=$(ip -6 addr 2>/dev/null | awk '/inet6 [23]/ {print $2}' | cut -d'/' -f1 | head -n1)
|
||||
[ -n "$ip6_addr" ] && ip6="$ip6_addr"
|
||||
check_ip6 "$ip6" || { echo "Warning: Invalid IPv6 address in 'VPN_PUBLIC_IP6'. Detecting IPv6..." >&2; ip6=""; }
|
||||
fi
|
||||
[ -z "$ip6" ] && ip6=$(ip -6 addr 2>/dev/null | awk '/inet6 [23]/ {print $2}' | cut -d'/' -f1 | head -n1)
|
||||
check_ip6 "$ip6" || ip6=""
|
||||
}
|
||||
|
||||
install_vpn_pkgs() {
|
||||
|
||||
Reference in New Issue
Block a user