From 97481785623e7027ce4392b9be4247b6d515af31 Mon Sep 17 00:00:00 2001 From: Ivan K Date: Tue, 20 May 2025 17:28:00 +0300 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor(podkop):=20enhanc?= =?UTF-8?q?e=20nft=20set=20statistics=20and=20chain=20configurations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- podkop/files/usr/bin/podkop | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/podkop/files/usr/bin/podkop b/podkop/files/usr/bin/podkop index 21e1518..1fdb118 100755 --- a/podkop/files/usr/bin/podkop +++ b/podkop/files/usr/bin/podkop @@ -1889,12 +1889,33 @@ check_nft() { nolog "PodkopTable not found" return 1 fi + + # List of possible sets + local sets="podkop_subnets podkop_domains interfaces podkop_discord_subnets localv4" + + echo "Sets statistics:" + for set_name in $sets; do + if nft list set inet PodkopTable $set_name >/dev/null 2>&1; then + # Count elements using grep to count commas and add 1 (last element has no comma) + local count=$(nft list set inet PodkopTable $set_name 2>/dev/null | grep -o ',\|{' | wc -l) + echo "- $set_name: $count elements" + fi + done - # Get all sets - nolog "\nSets configuration:" - - nft list table inet PodkopTable - + echo "" + echo "Chain configurations:" + + # Create a temporary file for processing + local tmp_file=$(mktemp) + nft list table inet PodkopTable > "$tmp_file" + + # Extract chain configurations without element listings + sed -n '/chain mangle {/,/}/p' "$tmp_file" | grep -v "elements" | grep -v "^[[:space:]]*[0-9]" + sed -n '/chain proxy {/,/}/p' "$tmp_file" | grep -v "elements" | grep -v "^[[:space:]]*[0-9]" + + # Clean up + rm -f "$tmp_file" + nolog "\nNFT check completed" }