diff options
author | Christian Poessinger <christian@poessinger.com> | 2022-07-17 10:24:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-17 10:24:17 +0200 |
commit | 3705f9164101156febac2dd1dfd1e62671121602 (patch) | |
tree | fe4c1d28fd88e03ad8b3daab60f6d63ae1234eb3 | |
parent | 3631cf3e5293c8856d87112fe50b6c2713a42d81 (diff) | |
parent | 08b1cdd5b6865d1106413ef01fa700f9a8c5d042 (diff) | |
download | vyos-1x-3705f9164101156febac2dd1dfd1e62671121602.tar.gz vyos-1x-3705f9164101156febac2dd1dfd1e62671121602.zip |
Merge pull request #1417 from sever-sever/T3435
op-mode: T3435: Fix SNAT any address and DNAT port dict check
-rwxr-xr-x | src/op_mode/show_nat_rules.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/op_mode/show_nat_rules.py b/src/op_mode/show_nat_rules.py index 98adb31dd..60a4bdd13 100755 --- a/src/op_mode/show_nat_rules.py +++ b/src/op_mode/show_nat_rules.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -# Copyright (C) 2021 VyOS maintainers and contributors +# Copyright (C) 2021-2022 VyOS maintainers and contributors # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 or later as @@ -99,8 +99,9 @@ if args.source or args.destination: if addr_tmp and len_tmp: tran_addr += addr_tmp + '/' + str(len_tmp) + ' ' - if isinstance(tran_addr_json['port'],int): - tran_addr += 'port ' + str(tran_addr_json['port']) + if tran_addr_json.get('port'): + if isinstance(tran_addr_json['port'],int): + tran_addr += 'port ' + str(tran_addr_json['port']) else: if 'masquerade' in data['expr'][i]: @@ -111,6 +112,8 @@ if args.source or args.destination: if srcdest != '': srcdests.append(srcdest) srcdest = '' + else: + srcdests.append('any') print(format_nat_rule.format(rule, srcdests[0], tran_addr, interface)) for i in range(1, len(srcdests)): |