Skip to contentSkip to conversation

xt_asn: support quiet mode

PATCH In review Philip Prindeville 2 participants 3 messages Jul 10, 2023 – Jul 11, 2023 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xt_asn: support quiet mode

From: Philip Prindeville <[email protected]>

---
 asn/xt_asn_build | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
asn/xt_asn_build +6 -4
index 4c406799480538c03efb8a5ccb9479aef3ef3060..63019ca689c56d5c9c686838fc4cc758047887e5 100755
@@ -18,6 +18,7 @@ my $csv = Text::CSV_XS->new({
 	binary => 1,
 	eol => $/,
 }); # or Text::CSV
+my $quiet = 0;
 my $source_dir = ".";
 my $target_dir = ".";
 my $output_txt;
@@ -27,6 +28,7 @@ my $output_txt;
 	"D=s" => \$target_dir,
 	"S=s" => \$source_dir,
 	"O=s" => \$output_txt,
+	"q" => \$quiet,
 );
 
 if (!-d $source_dir) {
@@ -85,7 +87,7 @@ sub collect
 
 		$asns{$asn}->{pool_v4}->add($cidr);
 
-		if ($. % 4096 == 0) {
+		if (!$quiet && $. % 4096 == 0) {
 			print STDERR "\r\e[2K$. entries";
 		}
 
@@ -95,7 +97,7 @@ sub collect
 		}
 	}
 
-	print STDERR "\r\e[2K$. entries total\n";
+	print STDERR "\r\e[2K$. entries total\n" unless ($quiet);
 
 	close($fh);
 
@@ -132,7 +134,7 @@ sub collect
 
 		$asns{$asn}->{pool_v6}->add($cidr);
 
-		if ($. % 4096 == 0) {
+		if (!$quiet && $. % 4096 == 0) {
 			print STDERR "\r\e[2K$. entries";
 		}
 
@@ -142,7 +144,7 @@ sub collect
 		}
 	}
 
-	print STDERR "\r\e[2K$. entries total\n";
+	print STDERR "\r\e[2K$. entries total\n" unless ($quiet);
 
 	close($fh);
 
Signature · 1 line
2.34.1