diff options
author | Christian Poessinger <christian@poessinger.com> | 2022-09-28 17:35:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-28 17:35:26 +0200 |
commit | a4c679ead2ede6f6c64b560f86fdceee01eef431 (patch) | |
tree | e8dd0f44556b31cdef34d8cbf57f4054f8e188a7 /src | |
parent | f5a50135f07ac4ec8ed431a757b9c56e607d2132 (diff) | |
parent | 87fdfa6c6ece87e6f719fc8ba80ae185a9f689c1 (diff) | |
download | vyos-1x-a4c679ead2ede6f6c64b560f86fdceee01eef431.tar.gz vyos-1x-a4c679ead2ede6f6c64b560f86fdceee01eef431.zip |
Merge pull request #1564 from sarthurdev/T4713
nat: T4713: Fix op-mode nat translation output
Diffstat (limited to 'src')
-rwxr-xr-x | src/op_mode/nat.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/op_mode/nat.py b/src/op_mode/nat.py index a0496dedb..845dbbb2c 100755 --- a/src/op_mode/nat.py +++ b/src/op_mode/nat.py @@ -109,7 +109,7 @@ def _get_formatted_output_rules(data, direction, family): if jmespath.search('rule.expr[*].match.left.meta', rule) else 'any' for index, match in enumerate(jmespath.search('rule.expr[*].match', rule)): if 'payload' in match['left']: - if 'prefix' in match['right'] or 'set' in match['right']: + if isinstance(match['right'], dict) and ('prefix' in match['right'] or 'set' in match['right']): # Merge dict src/dst l3_l4 parameters my_dict = {**match['left']['payload'], **match['right']} my_dict['op'] = match['op'] @@ -136,10 +136,15 @@ def _get_formatted_output_rules(data, direction, family): dport = my_dict.get('set') dport = ','.join(map(str, dport)) else: - if jmespath.search('left.payload.field', match) == 'saddr': + field = jmespath.search('left.payload.field', match) + if field == 'saddr': saddr = match.get('right') - if jmespath.search('left.payload.field', match) == 'daddr': + elif field == 'daddr': daddr = match.get('right') + elif field == 'sport': + sport = match.get('right') + elif field == 'dport': + dport = match.get('right') else: saddr = '::/0' if family == 'inet6' else '0.0.0.0/0' daddr = '::/0' if family == 'inet6' else '0.0.0.0/0' |