From fa8a09089af3a9062ae4f4f0ebc8c8474d870783 Mon Sep 17 00:00:00 2001 From: Viacheslav Hletenko Date: Sat, 30 Jul 2022 09:00:45 +0000 Subject: nat: T4089: Rewrite show nat destination rules Rewrite op-mode "show nat destination rules" to new format use "show_rules --direction destination" Delete old script "show_nat_rules.py" --- src/op_mode/nat.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/op_mode/nat.py') diff --git a/src/op_mode/nat.py b/src/op_mode/nat.py index 4b54ecf31..a98fc4227 100755 --- a/src/op_mode/nat.py +++ b/src/op_mode/nat.py @@ -132,6 +132,16 @@ port {port}''' port = expr['masquerade']['port'] translation = f'''{translation} +port {port}''' + elif 'dnat' in expr: + translation = dict_search('dnat.addr', expr) + if expr['dnat'] and 'port' in expr['dnat']: + if jmespath.search('dnat.port.range', expr): + port = dict_search('dnat.port.range', expr) + port = '-'.join(map(str, port)) + else: + port = expr['dnat']['port'] + translation = f'''{translation} port {port}''' else: translation = 'exclude' -- cgit v1.2.3