fix: handle domain names in IP4 configuration variable

Previously, when the IP4 variable contained a domain name instead of an actual IP address, the SNI validation would fail and force the use of self-signed certificates. This update adds detection and resolution of domain names in the IP4 variable, ensuring proper DNS comparison when checking if the SNI domain points to the server.
This commit is contained in:
Whispering Wind
2025-04-27 11:32:43 +03:30
committed by GitHub
parent c89134f40e
commit 7546e13cfb

View File

@ -10,6 +10,7 @@ else
echo "Error: Config file $CONFIG_ENV not found." echo "Error: Config file $CONFIG_ENV not found."
exit 1 exit 1
fi fi
update_sni() { update_sni() {
local sni=$1 local sni=$1
local server_ip local server_ip
@ -21,10 +22,21 @@ update_sni() {
fi fi
if [ -n "$IP4" ]; then if [ -n "$IP4" ]; then
server_ip="$IP4" if [[ $IP4 =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Using server IP from config: $server_ip" server_ip="$IP4"
echo "Using server IP from config: $server_ip"
else
domain_ip=$(dig +short "$IP4" A | head -n 1)
if [ -n "$domain_ip" ]; then
server_ip="$domain_ip"
echo "Resolved domain $IP4 to IP: $server_ip"
else
server_ip=$(curl -s -4 ifconfig.me)
echo "Could not resolve domain $IP4. Using auto-detected server IP: $server_ip"
fi
fi
else else
server_ip=$(curl -s ifconfig.me) server_ip=$(curl -s -4 ifconfig.me)
echo "Using auto-detected server IP: $server_ip" echo "Using auto-detected server IP: $server_ip"
fi fi