diff options
author | John Southworth <john.southworth@vyatta.com> | 2011-01-20 18:00:04 -0600 |
---|---|---|
committer | John Southworth <john.southworth@vyatta.com> | 2011-01-20 19:22:31 -0600 |
commit | 681ee566b2077a454ed996b7ba60cba0bb873d3a (patch) | |
tree | 48d510a3582c77800ca5eadbf4c17ab6f3a36a09 | |
parent | 1baa1c2b1c9c817c2ec3d4526b95f077767a962d (diff) | |
download | vyatta-op-vpn-681ee566b2077a454ed996b7ba60cba0bb873d3a.tar.gz vyatta-op-vpn-681ee566b2077a454ed996b7ba60cba0bb873d3a.zip |
Make adjustment so OP mode can deal with new secrets file format
(cherry picked from commit 35fa51ef099248991ab79d562462c3be6d2c8884)
-rwxr-xr-x | scripts/vyatta-show-vpn.pl | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/scripts/vyatta-show-vpn.pl b/scripts/vyatta-show-vpn.pl index f1c1078..983f344 100755 --- a/scripts/vyatta-show-vpn.pl +++ b/scripts/vyatta-show-vpn.pl @@ -41,16 +41,33 @@ if ($arg0 eq 'secrets') { open(DAT, $secret_file); my @raw_data=<DAT>; close(DAT); - print "Local Peer Secret\n"; - print "-------- ------- ------\n"; + print "Local Peer Local ID Peer ID Secret\n"; + print "-------- ------- -------- ------- ------\n"; foreach my $line (@raw_data) { if ($line =~ /PSK/) { - my ($lip, $pip, $secret) = ('', '', ''); + my ($lip, $pip, $lid, $pid, $secret) = ('', '', 'N/A', 'N/A', ''); ($secret) = $line =~ /.*:\s+PSK\s+(\"\S+\")/; ($lip, $pip) = $line =~ /^(\S+)\s+(\S+)\s+\:\s+PSK\s+\"\S+\"/; + # This processing with depend heavily on the way we write ipsec.secrets + # lines with 3 entries are tagged by the config module so that we can tell + # if the 3rd entry is a localid or peerid (left or right) + if (! defined($lip)){ + if ($line =~ /^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+\:\s+PSK\s+\"\S+\"/){ + $lip = $1; + $pip = $2; + $lid = $3; + $pid = $4; + } elsif ($line =~ /^(\S+)\s+(\S+)\s+(\S+)\s+\:\s+PSK\s+\"\S+\".*\#(.*)\#/){ + $lip = $1; + $pip = $2; + if ($4 eq 'RIGHT'){ + $pid = $3 + } else {$lid = $3} + } + } $lip = '0.0.0.0' if ! defined $lip; $pip = '0.0.0.0' if ! defined $pip; - printf "%-15s %-15s %s\n", $lip, $pip, $secret; + printf "%-15s %-15s %-13s %-13s %s\n", $lip, $pip, substr($lid,0,12), substr($pid,0,12), $secret; } } exit 0; |