Skip to content

Commit

Permalink
[pfsense_nat_port_forward] Always add a local-port element
Browse files Browse the repository at this point in the history
  • Loading branch information
opoplawski committed Jan 21, 2023
1 parent 0ffd133 commit 5e0ea2a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions plugins/module_utils/nat_port_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,12 @@ def _parse_target_address(self, obj):
else:
self.module.fail_json(msg='"%s" is not a valid redirect target IP address or host alias.' % (param))

if ports is None and self.params['protocol'] in ["tcp", "udp", "tcp/udp"]:
self.module.fail_json(msg='Must specify a target port with protocol "{0}".'.format(self.params['protocol']))
if ports is None:
if self.params['protocol'] in ["tcp", "udp", "tcp/udp"]:
self.module.fail_json(msg='Must specify a target port with protocol "{0}".'.format(self.params['protocol']))
else:
# pfSense seems to always add an empty local-port element
obj['local-port'] = ''

if ports is not None:
if self.params['protocol'] not in ["tcp", "udp", "tcp/udp"]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def check_target_elt(self, obj, target_elt, target_idx=-1):
self.check_value_equal(target_elt, 'interface', self.unalias_interface(obj['interface']))
self.check_param_equal(obj, target_elt, 'ipprotocol', 'inet')
self.check_param_equal(obj, target_elt, 'protocol', 'tcp')
self.check_param_equal_or_present(obj, target_elt, 'local-port')

self.check_rule_idx(obj, target_idx)
if 'associated_rule' not in obj:
Expand Down

0 comments on commit 5e0ea2a

Please sign in to comment.