Commit 1dcd7190 authored by Vitaly Lipatov's avatar Vitaly Lipatov

route-update: use list_has_domains() for reliable domain detection

Replace grep '[g-zG-Z]' with list_has_domains() that filters out IPv4 (digits/dots/slashes) and IPv6 (hex/colons/slashes) patterns, then checks if anything remains. This correctly handles IPv6 IP-only lists where hex digits a-f caused false positive domain detection. Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 0e2b2430
......@@ -89,6 +89,10 @@ is_ipv4()
echo "$1" | grep -q -E "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"
}
# Check if a list file contains domain names (not just IPs/subnets)
# Returns 0 if domains found, 1 if IP-only
list_has_domains() { grep -v '^#' "$1" | grep -vE '^$|^[0-9./]+$|^[0-9a-f:/]+$' | grep -q . ; }
is_ipv6()
{
echo "$1" | grep -q ':'
......
......@@ -524,7 +524,7 @@ resolve_list_file()
vlog "$_tag$_label resolving..."
> "$_resolved_new.tmp"
if grep -v '^#' "$_f" | grep -q '[g-zG-Z]' ; then
if list_has_domains "$_f" ; then
cat_expanded "$_f" | grep -v '^#' | grep -v '^$' | $_resolve_func | \
grep -v '^#' | grep -v '^$' >> "$_resolved_new.tmp"
else
......@@ -553,7 +553,7 @@ resolve_list_file()
rm -f "$_resolved_new.tmp"
# Accumulate resolve history (DNS round-robin) — only for lists with domains
if grep -v '^#' "$_f" | grep -q '[g-zG-Z]' ; then
if list_has_domains "$_f" ; then
local history_dir="$STATE_DIR/$_state/resolve_history"
mkdir -p "$history_dir"
rm -f "$history_dir/$HISTORY_SIZE"
......@@ -571,7 +571,7 @@ resolve_list_file()
fi
# Detect volatile domains (IPv4 and IPv6)
if grep -v '^#' "$_f" | grep -q '[g-zG-Z]' ; then
if list_has_domains "$_f" ; then
local _vname=$(echo "$_tag" | tr -d '[]')
local _rtype="A"
[ "$_ipcmd" = "ip -6" ] && _rtype="AAAA"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment