diff options
author | Viacheslav Hletenko <v.gletenko@vyos.io> | 2022-07-30 09:00:45 +0000 |
---|---|---|
committer | Viacheslav Hletenko <v.gletenko@vyos.io> | 2022-07-30 09:00:45 +0000 |
commit | fa8a09089af3a9062ae4f4f0ebc8c8474d870783 (patch) | |
tree | 9573c835023421da71ec5fc9601c032bba301295 /src/op_mode/nat.py | |
parent | 2a9a2cfa12e87ae1b300354aeb3bdf7b10059d26 (diff) | |
download | vyos-1x-fa8a09089af3a9062ae4f4f0ebc8c8474d870783.tar.gz vyos-1x-fa8a09089af3a9062ae4f4f0ebc8c8474d870783.zip |
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"
Diffstat (limited to 'src/op_mode/nat.py')
-rwxr-xr-x | src/op_mode/nat.py | 10 |
1 files changed, 10 insertions, 0 deletions
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 @@ -133,6 +133,16 @@ port {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' # Overwrite match loop 'proto' if specified filed 'protocol' exist |