Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions plugins/module_utils/nat_port_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
ipprotocol=dict(default='inet', choices=['inet', 'inet6']),
protocol=dict(default='tcp', required=False, choices=["tcp", "udp", "tcp/udp", "icmp", "esp", "ah", "gre", "ipv6", "igmp", "pim", "ospf"]),
source=dict(required=False, type='str'),
source_port=dict(required=False, type='str'),
destination=dict(required=False, type='str'),
destination_port=dict(required=False, type='str'),
target=dict(required=False, type='str'),
natreflection=dict(default='system-default', choices=["system-default", "enable", "purenat", "disable"]),
associated_rule=dict(default='associated', required=False, choices=["associated", "unassociated", "pass", "none"]),
Expand Down Expand Up @@ -47,8 +49,6 @@ def get_argument_spec():
def __init__(self, module, pfsense=None):
super(PFSenseNatPortForwardModule, self).__init__(module, pfsense)
self.name = "pfsense_nat_port_forward"
# Override for use with aggregate
self.argument_spec = NAT_PORT_FORWARD_ARGUMENT_SPEC
self.obj = dict()

self.after = None
Expand Down Expand Up @@ -102,7 +102,15 @@ def _params_to_obj(self):
self.before = self.params['before']

obj['source'] = self.pfsense.parse_address(self.params['source'], allow_self=False)
if self.params.get('source_port'):
if not self.pfsense.is_port_or_alias(self.params['source_port']):
self.module.fail_json(msg='Cannot parse port %s, not port number or alias' % (self.params['source_port']))
obj['source']['port'] = self.params['source_port']
obj['destination'] = self.pfsense.parse_address(self.params['destination'])
if self.params.get('destination_port'):
if not self.pfsense.is_port_or_alias(self.params['destination_port']):
self.module.fail_json(msg='Cannot parse port %s, not port number or alias' % (self.params['destination_port']))
obj['destination']['port'] = self.params['destination_port']
self._parse_target_address(obj)

return obj
Expand Down
14 changes: 14 additions & 0 deletions plugins/modules/pfsense_nat_port_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,24 @@
description: The source address, in [!]{IP,HOST,ALIAS,any,IP:INTERFACE,NET:INTERFACE}[:port] format.
default: null
type: str
source_port:
description:
- Source port or port range specification.
- This can either be a alias or a port number.
- An inclusive range can also be specified, using the format C(first-last).
default: null
type: str
destination:
description: The destination address, in [!]{IP,HOST,ALIAS,any,IP:INTERFACE,NET:INTERFACE}[:port] format.
default: null
type: str
destination_port:
description:
- Destination port or port range specification.
- This can either be a alias or a port number.
- An inclusive range can also be specified, using the format C(first-last).
default: null
type: str
target:
description: The translated to address, in {ALIAS,IP}[:port] format.
required: false
Expand Down