diff options
author | Daniil Baturin <daniil@baturin.org> | 2018-12-31 11:52:29 +0100 |
---|---|---|
committer | Daniil Baturin <daniil@baturin.org> | 2018-12-31 11:52:29 +0100 |
commit | dd2a15158e8f22b8b1ba68160b686ff1047babf4 (patch) | |
tree | 22a1c92d509d5b5a7fe5a5a8da0f7674255ffb9e /src | |
parent | 5ae0e478b41a5ca2b179f712ac1a71b4d1fca616 (diff) | |
download | vyos-1x-dd2a15158e8f22b8b1ba68160b686ff1047babf4.tar.gz vyos-1x-dd2a15158e8f22b8b1ba68160b686ff1047babf4.zip |
T1108: warn the user and exit if there are no established IPsec SAs.
Diffstat (limited to 'src')
-rwxr-xr-x | src/op_mode/show_ipsec_sa.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/op_mode/show_ipsec_sa.py b/src/op_mode/show_ipsec_sa.py index 9e1d6ce4d..117824632 100755 --- a/src/op_mode/show_ipsec_sa.py +++ b/src/op_mode/show_ipsec_sa.py @@ -1,14 +1,21 @@ #!/usr/bin/env python3 import re +import sys import subprocess import tabulate import hurry.filesize def parse_conn_spec(s): - # Example: ESTABLISHED 14 seconds ago, 10.0.0.2[foo]...10.0.0.1[10.0.0.1] - return re.search(r'.*ESTABLISHED\s+(.*)ago,\s(.*)\[(.*)\]\.\.\.(.*)\[(.*)\].*', s).groups() + try: + # Example: ESTABLISHED 14 seconds ago, 10.0.0.2[foo]...10.0.0.1[10.0.0.1] + return re.search(r'.*ESTABLISHED\s+(.*)ago,\s(.*)\[(.*)\]\.\.\.(.*)\[(.*)\].*', s).groups() + except AttributeError: + # No active SAs found, so we have nothing to display + print("No established security associations found.") + print("Use \"show vpn ipsec sa\" to view inactive and connecting tunnels.") + sys.exit(0) def parse_ike_line(s): try: |