Refactor message output and improve SSH check logic

Replaces many msg_info calls with msg_custom for more consistent and expressive status messages in build.func. Refines SSH client detection in core.func to better distinguish local, subnet, and external connections, and adds additional warnings for external SSH usage.
This commit is contained in:
CanbiZ
2025-11-04 16:38:46 +01:00
parent 2ff12b1f01
commit 8ccd06b596
2 changed files with 39 additions and 26 deletions

View File

@@ -231,11 +231,24 @@ ssh_check() {
local client_ip=$(awk '{print $1}' <<<"$SSH_CLIENT")
local host_ip=$(hostname -I | awk '{print $1}')
if [[ "$client_ip" == "127.0.0.1" || "$client_ip" == "$host_ip" ]]; then
# Check if connection is local (Proxmox WebUI or same machine)
# - localhost (127.0.0.1, ::1)
# - same IP as host
# - local network range (10.x, 172.16-31.x, 192.168.x)
if [[ "$client_ip" == "127.0.0.1" || "$client_ip" == "::1" || "$client_ip" == "$host_ip" ]]; then
return
fi
# Check if client is in same local network (optional, safer approach)
local host_subnet=$(echo "$host_ip" | cut -d. -f1-3)
local client_subnet=$(echo "$client_ip" | cut -d. -f1-3)
if [[ "$host_subnet" == "$client_subnet" ]]; then
return
fi
# Only warn for truly external connections
msg_warn "Running via external SSH (client: $client_ip)."
msg_warn "For better stability, consider using the Proxmox Shell (Console) instead."
fi
}