From f14b8d3ece4de61f8f0de0f2ef4dd4e2512527b2 Mon Sep 17 00:00:00 2001 From: Stig Thormodsrud Date: Sat, 2 Aug 2008 20:42:30 -0700 Subject: Tweak "show nat translations" headings. --- scripts/vyatta-nat-translations.pl | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/scripts/vyatta-nat-translations.pl b/scripts/vyatta-nat-translations.pl index e5e9e64..681845f 100755 --- a/scripts/vyatta-nat-translations.pl +++ b/scripts/vyatta-nat-translations.pl @@ -189,6 +189,19 @@ if (! -f $conntrack) { my $xs = XML::Simple->new(ForceArray => 1, KeepRoot => 0); my ($xml, $data); +if (defined $verbose) { + printf($verbose_format, 'Pre-NAT src', 'Pre-NAT dst', + 'Post-NAT src', 'Post-NAT dst'); +} else { + printf($format, 'Pre-NAT', 'Post-NAT', 'Type', 'Prot', 'Timeout'); + if (defined $pipe) { + # flush stdout after every write + $| = 1; + print " Type"; + } + print "\n"; +} + if (defined $xml_file) { $xml = read_xml_file($xml_file); $data = $xs->XMLin($xml); @@ -196,39 +209,20 @@ if (defined $xml_file) { print_xml($data); exit; } - if (defined $verbose) { - printf($verbose_format, 'Inside src', 'Inside dst', - 'Outside src', 'Outside dst'); - } else { - printf($format, 'Pre-NAT', 'Post-NAT', 'Type', 'Prot', 'Timeout'); - print "\n"; - } nat_print_xml($data, 'snat'); } elsif (defined $pipe) { - # flush stdout after every write - $| = 1; - printf($format, 'Pre-NAT', 'Post-NAT', 'Type', 'Prot', 'Timeout'); - print " Type\n"; while ($xml = ) { $xml = add_xml_root($xml); $data = $xs->XMLin($xml); nat_print_xml($data, $mode); } } else { - if (defined $proto) { $proto = "-p $proto" } else { $proto = ""; } - if (defined $verbose) { - printf($verbose_format, 'Inside src', 'Inside dst', - 'Outside src', 'Outside dst'); - } else { - printf($format, 'Pre-NAT', 'Post-NAT', 'Type', 'Prot', 'Timeout'); - print "\n"; - } if ($mode eq 'both' or $mode eq 'snat') { my $ipopt = ""; if (defined $ipaddr) { -- cgit v1.2.3