Commit e8923ba7 authored by Vitaly Lipatov's avatar Vitaly Lipatov

route-update.sh: skip DNS resolution for pure IP lists

Split .list files into pure-IP (antifilter) and domain lists. Pure IP files go through cat directly, avoiding slow per-line bash processing of 155k entries through cat_expanded and is_ipv4. Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent f5f7f3c9
...@@ -144,13 +144,32 @@ process_v4() ...@@ -144,13 +144,32 @@ process_v4()
log "[$gw] Changes detected, resolving..." log "[$gw] Changes detected, resolving..."
# Fetch lists and run DNS resolution # Fetch lists and run DNS resolution
# Split: pure IP files (no letters except comments) go through cat,
# domain files go through cat_expanded + get_ipv4_list_bulk
resolved_new="$STATE_DIR/$state/resolved.new" resolved_new="$STATE_DIR/$state/resolved.new"
ip_lists=""
domain_lists=""
for f in $lists ; do
if grep -v '^#' "$f" | grep -q '[a-zA-Z]' ; then
domain_lists="$domain_lists $f"
else
ip_lists="$ip_lists $f"
fi
done
{ {
for f in $lists ; do # Pure IP lists — pass through directly
cat_expanded "$f" for f in $ip_lists ; do
grep -v '^#' "$f" | grep -v '^$'
done done
} | grep -v '^#' | grep -v '^$' | get_ipv4_list_bulk | \ # Domain lists — expand ranges and resolve
grep -v '^#' | grep -v '^$' | sort -u > "$resolved_new" if [ -n "$domain_lists" ] ; then
for f in $domain_lists ; do
cat_expanded "$f"
done | grep -v '^#' | grep -v '^$' | get_ipv4_list_bulk | \
grep -v '^#' | grep -v '^$'
fi
} | sort -u > "$resolved_new"
# Check if resolved IPs actually changed # Check if resolved IPs actually changed
if [ -z "$FORCE" ] && [ -f "$STATE_DIR/$state/resolved" ] ; then if [ -z "$FORCE" ] && [ -f "$STATE_DIR/$state/resolved" ] ; then
...@@ -246,12 +265,27 @@ process_v6() ...@@ -246,12 +265,27 @@ process_v6()
log "[$dirname] (v6) Changes detected, resolving..." log "[$dirname] (v6) Changes detected, resolving..."
resolved_new="$STATE_DIR/$state/resolved.new" resolved_new="$STATE_DIR/$state/resolved.new"
ip_lists=""
domain_lists=""
for f in $lists ; do
if grep -v '^#' "$f" | grep -q '[a-zA-Z]' ; then
domain_lists="$domain_lists $f"
else
ip_lists="$ip_lists $f"
fi
done
{ {
for f in $lists ; do for f in $ip_lists ; do
cat_expanded "$f" grep -v '^#' "$f" | grep -v '^$'
done done
} | grep -v '^#' | grep -v '^$' | get_ipv6_list_bulk | \ if [ -n "$domain_lists" ] ; then
grep -v '^#' | grep -v '^$' | sort -u > "$resolved_new" for f in $domain_lists ; do
cat_expanded "$f"
done | grep -v '^#' | grep -v '^$' | get_ipv6_list_bulk | \
grep -v '^#' | grep -v '^$'
fi
} | sort -u > "$resolved_new"
if [ -z "$FORCE" ] && [ -f "$STATE_DIR/$state/resolved" ] ; then if [ -z "$FORCE" ] && [ -f "$STATE_DIR/$state/resolved" ] ; then
if diff -q "$STATE_DIR/$state/resolved" "$resolved_new" >/dev/null 2>&1 ; then if diff -q "$STATE_DIR/$state/resolved" "$resolved_new" >/dev/null 2>&1 ; then
......
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