diff options
7 files changed, 15 insertions, 14 deletions
diff --git a/scripts/vyatta-nat-translations.pl b/scripts/vyatta-nat-translations.pl index d156df8..256ae70 100755 --- a/scripts/vyatta-nat-translations.pl +++ b/scripts/vyatta-nat-translations.pl @@ -37,7 +37,6 @@ my $mode; my $verbose_format = "%-20s %-18s %-20s %-18s\n"; my $format = "%-20s %-20s %-4s %-4s %-8s"; - sub add_xml_root { my $xml = shift; @@ -45,6 +44,7 @@ sub add_xml_root { return $xml; } + sub read_xml_file { my $file = shift; @@ -52,7 +52,6 @@ sub read_xml_file { open FD, "<", $file or die "Couldn't open $file\n"; my $xml = <FD>; close FD; - $xml = add_xml_root($xml); return $xml; } @@ -227,6 +226,8 @@ if (defined $xml_file) { } elsif (defined $pipe) { while ($xml = <STDIN>) { + $xml =~ s/\<\?xml version=\"1\.0\" encoding=\"utf-8\"\?\>//; + $xml =~ s/\<conntrack\>//; $xml = add_xml_root($xml); $data = $xs->XMLin($xml); nat_print_xml($data, $mode); @@ -243,9 +244,9 @@ if (defined $xml_file) { if (defined $ipaddr) { $ipopt = "--orig-src $ipaddr"; } - $xml = `sudo $conntrack -L -n $ipopt -o xml $proto`; - my $snat_xml = add_xml_root($xml); - $data = $xs->XMLin($snat_xml); + $xml = `sudo $conntrack -L -n $ipopt -o xml $proto 2>/dev/null`; + chomp $xml; + $data = $xs->XMLin($xml) if ! $xml eq ''; nat_print_xml($data, 'snat'); } if ($mode eq 'both' or $mode eq 'dnat') { @@ -253,9 +254,9 @@ if (defined $xml_file) { if (defined $ipaddr) { $ipopt = "--orig-dst $ipaddr"; } - $xml = `sudo $conntrack -L -g $ipopt -o xml $proto`; - my $dnat_xml = add_xml_root($xml); - $data = $xs->XMLin($dnat_xml); + $xml = `sudo $conntrack -L -g $ipopt -o xml $proto 2>/dev/null`; + chomp $xml; + $data = $xs->XMLin($xml) if ! $xml eq ''; nat_print_xml($data, 'dnat'); } } diff --git a/templates-op/show/nat/translations/destination/monitor/detail/node.def b/templates-op/show/nat/translations/destination/monitor/detail/node.def index 5f8cb0b..2f9dd00 100644 --- a/templates-op/show/nat/translations/destination/monitor/detail/node.def +++ b/templates-op/show/nat/translations/destination/monitor/detail/node.def @@ -1,4 +1,4 @@ help: Show active NAT destination translations events detail run: LESSOPEN=cat echo Type control-C to quit - sudo /usr/sbin/conntrack -E -g -o xml | ${vyatta_bindir}/sudo-users/vyatta-nat-translations.pl --mode=dnat --pipe --verbose + sudo /usr/sbin/conntrack -E -g -o xml 2>/dev/null | ${vyatta_bindir}/sudo-users/vyatta-nat-translations.pl --mode=dnat --pipe --verbose diff --git a/templates-op/show/nat/translations/destination/monitor/node.def b/templates-op/show/nat/translations/destination/monitor/node.def index 4b51368..383f880 100644 --- a/templates-op/show/nat/translations/destination/monitor/node.def +++ b/templates-op/show/nat/translations/destination/monitor/node.def @@ -1,4 +1,4 @@ help: Show active NAT destination translations events run: LESSOPEN=cat echo Type control-C to quit - sudo /usr/sbin/conntrack -E -g -o xml | ${vyatta_bindir}/sudo-users/vyatta-nat-translations.pl --mode=dnat --pipe + sudo /usr/sbin/conntrack -E -g -o xml 2>/dev/null | ${vyatta_bindir}/sudo-users/vyatta-nat-translations.pl --mode=dnat --pipe diff --git a/templates-op/show/nat/translations/monitor/detail/node.def b/templates-op/show/nat/translations/monitor/detail/node.def index e96aa6f..19d0c7a 100644 --- a/templates-op/show/nat/translations/monitor/detail/node.def +++ b/templates-op/show/nat/translations/monitor/detail/node.def @@ -1,4 +1,4 @@ help: Show active NAT translations events verbose run: LESSOPEN=cat echo Type control-C to quit - sudo /usr/sbin/conntrack -E -n -g -o xml | ${vyatta_bindir}/sudo-users/vyatta-nat-translations.pl --pipe --verbose
\ No newline at end of file + sudo /usr/sbin/conntrack -E -n -g -o xml 2>/dev/null | ${vyatta_bindir}/sudo-users/vyatta-nat-translations.pl --pipe --verbose diff --git a/templates-op/show/nat/translations/monitor/node.def b/templates-op/show/nat/translations/monitor/node.def index ed8786f..c871dad 100644 --- a/templates-op/show/nat/translations/monitor/node.def +++ b/templates-op/show/nat/translations/monitor/node.def @@ -1,4 +1,4 @@ help: Show active NAT translations events run: LESSOPEN=cat echo Type control-C to quit - sudo /usr/sbin/conntrack -E -n -g -o xml | ${vyatta_bindir}/sudo-users/vyatta-nat-translations.pl --pipe + sudo /usr/sbin/conntrack -E -n -g -o xml 2>/dev/null | ${vyatta_bindir}/sudo-users/vyatta-nat-translations.pl --pipe diff --git a/templates-op/show/nat/translations/source/monitor/detail/node.def b/templates-op/show/nat/translations/source/monitor/detail/node.def index 4d69843..d0ac59d 100644 --- a/templates-op/show/nat/translations/source/monitor/detail/node.def +++ b/templates-op/show/nat/translations/source/monitor/detail/node.def @@ -1,4 +1,4 @@ help: Show active NAT source translations events run: LESSOPEN=cat echo Type control-C to quit - sudo /usr/sbin/conntrack -E -n -o xml | ${vyatta_bindir}/sudo-users/vyatta-nat-translations.pl --mode=snat --pipe --verbose
\ No newline at end of file + sudo /usr/sbin/conntrack -E -n -o xml 2>/dev/null | ${vyatta_bindir}/sudo-users/vyatta-nat-translations.pl --mode=snat --pipe --verbose diff --git a/templates-op/show/nat/translations/source/monitor/node.def b/templates-op/show/nat/translations/source/monitor/node.def index 2956935..fcaec10 100644 --- a/templates-op/show/nat/translations/source/monitor/node.def +++ b/templates-op/show/nat/translations/source/monitor/node.def @@ -1,4 +1,4 @@ help: Show active NAT source translations events run: LESSOPEN=cat echo Type control-C to quit - sudo /usr/sbin/conntrack -E -n -o xml | ${vyatta_bindir}/sudo-users/vyatta-nat-translations.pl --mode=snat --pipe + sudo /usr/sbin/conntrack -E -n -o xml 2>/dev/null | ${vyatta_bindir}/sudo-users/vyatta-nat-translations.pl --mode=snat --pipe |