summaryrefslogtreecommitdiff
path: root/src/op_mode/show_ipsec_sa.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-08-14 19:01:53 +0200
committerChristian Poessinger <christian@poessinger.com>2021-08-14 19:01:53 +0200
commit1229665d353a070e14ee9cceafbfdb107d669745 (patch)
treeb58812446687e4db5889aab3060f3e22d513daf5 /src/op_mode/show_ipsec_sa.py
parentb4629d14d8ec5c780f665222205a396eb4dc3158 (diff)
downloadvyos-1x-1229665d353a070e14ee9cceafbfdb107d669745.tar.gz
vyos-1x-1229665d353a070e14ee9cceafbfdb107d669745.zip
op-mode: ipsec: T3745: "show vpn ipse sa" improve sorting
Diffstat (limited to 'src/op_mode/show_ipsec_sa.py')
-rwxr-xr-xsrc/op_mode/show_ipsec_sa.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/op_mode/show_ipsec_sa.py b/src/op_mode/show_ipsec_sa.py
index e491267fd..c964caaeb 100755
--- a/src/op_mode/show_ipsec_sa.py
+++ b/src/op_mode/show_ipsec_sa.py
@@ -23,6 +23,12 @@ import hurry.filesize
import vyos.util
+def convert(text):
+ return int(text) if text.isdigit() else text.lower()
+
+def alphanum_key(key):
+ return [convert(c) for c in re.split('([0-9]+)', str(key))]
+
def format_output(conns, sas):
sa_data = []
@@ -111,7 +117,7 @@ if __name__ == '__main__':
headers = ["Connection", "State", "Uptime", "Bytes In/Out", "Packets In/Out", "Remote address", "Remote ID", "Proposal"]
sa_data = format_output(conns, sas)
- sa_data = sorted(sa_data, key=lambda peer: peer[0])
+ sa_data = sorted(sa_data, key=alphanum_key)
output = tabulate.tabulate(sa_data, headers)
print(output)
except PermissionError: