diff options
author | Mohit Mehta <mohit.mehta@vyatta.com> | 2010-06-10 11:36:08 -0700 |
---|---|---|
committer | Mohit Mehta <mohit.mehta@vyatta.com> | 2010-06-10 11:36:08 -0700 |
commit | cf6044455bedf4fba9611dcb3745d4f535c3a3ff (patch) | |
tree | 3aef1052bb8a2414cc62d950ad6bbb37d420b69c /scripts | |
parent | e59c2db5e7edd67d6d847c4f328566917ac2530d (diff) | |
download | vyatta-nat-cf6044455bedf4fba9611dcb3745d4f535c3a3ff.tar.gz vyatta-nat-cf6044455bedf4fba9611dcb3745d4f535c3a3ff.zip |
* make 'show nat translations' cmnds work with conntrack-tools 0.9.14
* might have to build conntrack-tools locally to patch it for filtering
src and dst nat entries together
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/vyatta-nat-translations.pl | 17 |
1 files changed, 9 insertions, 8 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'); } } |