diff options
author | Viacheslav Hletenko <v.gletenko@vyos.io> | 2022-07-17 08:12:16 +0000 |
---|---|---|
committer | Viacheslav Hletenko <v.gletenko@vyos.io> | 2022-07-17 08:12:16 +0000 |
commit | 08b1cdd5b6865d1106413ef01fa700f9a8c5d042 (patch) | |
tree | fe4c1d28fd88e03ad8b3daab60f6d63ae1234eb3 /src | |
parent | 3631cf3e5293c8856d87112fe50b6c2713a42d81 (diff) | |
download | vyos-1x-08b1cdd5b6865d1106413ef01fa700f9a8c5d042.tar.gz vyos-1x-08b1cdd5b6865d1106413ef01fa700f9a8c5d042.zip |
op-mode: T3435: Fix SNAT any address and DNAT port dict check
If SNAT source address in not exists use 'any'
Add check if 'port' exists in dictionary
Diffstat (limited to 'src')
-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)): |