mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-07-26 09:52:14 +03:00
fix(script): confirm auto-detected public IPv4 before issuing IP certificate
On networks with asymmetric routing (or proxies/multi-WAN), external IP-echo services can return a transit or gateway address instead of the server's real incoming IP, and every IP-certificate flow silently issued for that wrong address. The x-ui.sh menu flow (option 20 -> 6) and the install.sh/update.sh SSL menus now show the detected IPv4 for confirmation (Enter keeps the old behavior), and declining falls into the same validated manual-entry loop already used when every provider fails. Non-interactive installs are untouched - XUI_SERVER_IP already pins the address there. Closes #5867
This commit is contained in:
18
install.sh
18
install.sh
@@ -873,6 +873,24 @@ prompt_and_setup_ssl() {
|
|||||||
# User chose Let's Encrypt IP certificate option
|
# User chose Let's Encrypt IP certificate option
|
||||||
echo -e "${green}Using Let's Encrypt for IP certificate (shortlived profile)...${plain}"
|
echo -e "${green}Using Let's Encrypt for IP certificate (shortlived profile)...${plain}"
|
||||||
|
|
||||||
|
# Confirm the auto-detected IP before issuing for it: with asymmetric
|
||||||
|
# routing / multi-WAN the echo services can return a transit address.
|
||||||
|
if [[ "$NONINTERACTIVE" != "1" ]]; then
|
||||||
|
local ip_confirm=""
|
||||||
|
read -rp "Is ${server_ip} the correct incoming public IPv4 address for this server? [Default y]: " ip_confirm
|
||||||
|
if [[ -n "$ip_confirm" && "$ip_confirm" != "y" && "$ip_confirm" != "Y" ]]; then
|
||||||
|
server_ip=""
|
||||||
|
while [[ -z "$server_ip" ]]; do
|
||||||
|
read -rp "Please enter your server's public IPv4 address: " server_ip
|
||||||
|
server_ip="${server_ip// /}"
|
||||||
|
if [[ ! "$server_ip" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||||
|
echo -e "${red}Invalid IPv4 address. Please try again.${plain}"
|
||||||
|
server_ip=""
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Ask for optional IPv6
|
# Ask for optional IPv6
|
||||||
local ipv6_addr=""
|
local ipv6_addr=""
|
||||||
prompt_or_default ipv6_addr "Do you have an IPv6 address to include? (leave empty to skip): " "" XUI_SSL_IPV6
|
prompt_or_default ipv6_addr "Do you have an IPv6 address to include? (leave empty to skip): " "" XUI_SSL_IPV6
|
||||||
|
|||||||
16
update.sh
16
update.sh
@@ -667,6 +667,22 @@ prompt_and_setup_ssl() {
|
|||||||
# User chose Let's Encrypt IP certificate option
|
# User chose Let's Encrypt IP certificate option
|
||||||
echo -e "${green}Using Let's Encrypt for IP certificate (shortlived profile)...${plain}"
|
echo -e "${green}Using Let's Encrypt for IP certificate (shortlived profile)...${plain}"
|
||||||
|
|
||||||
|
# Confirm the auto-detected IP before issuing for it: with asymmetric
|
||||||
|
# routing / multi-WAN the echo services can return a transit address.
|
||||||
|
local ip_confirm=""
|
||||||
|
read -rp "Is ${server_ip} the correct incoming public IPv4 address for this server? [Default y]: " ip_confirm
|
||||||
|
if [[ -n "$ip_confirm" && "$ip_confirm" != "y" && "$ip_confirm" != "Y" ]]; then
|
||||||
|
server_ip=""
|
||||||
|
while [[ -z "$server_ip" ]]; do
|
||||||
|
read -rp "Please enter your server's public IPv4 address: " server_ip
|
||||||
|
server_ip="${server_ip// /}"
|
||||||
|
if [[ ! "$server_ip" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||||
|
echo -e "${red}Invalid IPv4 address. Please try again.${plain}"
|
||||||
|
server_ip=""
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
# Ask for optional IPv6
|
# Ask for optional IPv6
|
||||||
local ipv6_addr=""
|
local ipv6_addr=""
|
||||||
read -rp "Do you have an IPv6 address to include? (leave empty to skip): " ipv6_addr
|
read -rp "Do you have an IPv6 address to include? (leave empty to skip): " ipv6_addr
|
||||||
|
|||||||
12
x-ui.sh
12
x-ui.sh
@@ -1548,8 +1548,15 @@ ssl_cert_issue_for_ip() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ -z "$server_ip" ]]; then
|
if [[ -n "$server_ip" ]]; then
|
||||||
|
LOGI "Server IP detected: ${server_ip}"
|
||||||
|
if ! confirm "Is ${server_ip} the correct incoming public IPv4 address for this server?" "y"; then
|
||||||
|
server_ip=""
|
||||||
|
fi
|
||||||
|
else
|
||||||
LOGI "Could not auto-detect server IP from any provider."
|
LOGI "Could not auto-detect server IP from any provider."
|
||||||
|
fi
|
||||||
|
|
||||||
while [[ -z "$server_ip" ]]; do
|
while [[ -z "$server_ip" ]]; do
|
||||||
read -rp "Please enter your server's public IPv4 address: " server_ip
|
read -rp "Please enter your server's public IPv4 address: " server_ip
|
||||||
server_ip="${server_ip// /}"
|
server_ip="${server_ip// /}"
|
||||||
@@ -1558,9 +1565,8 @@ ssl_cert_issue_for_ip() {
|
|||||||
server_ip=""
|
server_ip=""
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
|
||||||
|
|
||||||
LOGI "Server IP detected: ${server_ip}"
|
LOGI "Issuing certificate for server IP: ${server_ip}"
|
||||||
|
|
||||||
# Ask for optional IPv6
|
# Ask for optional IPv6
|
||||||
local ipv6_addr=""
|
local ipv6_addr=""
|
||||||
|
|||||||
Reference in New Issue
Block a user