Skip to content

Commit

Permalink
[pfsense_nat_port_forward] Add ipprotocol paramter
Browse files Browse the repository at this point in the history
  • Loading branch information
opoplawski committed Jan 21, 2023
1 parent 624684a commit 0ffd133
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions plugins/module_utils/nat_port_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
disabled=dict(default=False, required=False, type='bool'),
nordr=dict(default=False, required=False, type='bool'),
interface=dict(required=False, type='str'),
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'),
destination=dict(required=False, type='str'),
Expand Down Expand Up @@ -70,6 +71,7 @@ def _params_to_obj(self):
obj['descr'] = self.params['descr']
if self.params['state'] == 'present':
obj['interface'] = self.pfsense.parse_interface(self.params['interface'])
self._get_ansible_param(obj, 'ipprotocol')
self._get_ansible_param(obj, 'protocol')
self._get_ansible_param(obj, 'poolopts')
self._get_ansible_param(obj, 'source_hash_key')
Expand Down Expand Up @@ -389,6 +391,7 @@ def _log_fields(self, before=None):
values += self.format_cli_field(self.params, 'disabled', fvalue=self.fvalue_bool, default=False)
values += self.format_cli_field(self.params, 'nordr', fvalue=self.fvalue_bool, default=False)
values += self.format_cli_field(self.params, 'interface')
values += self.format_cli_field(self.params, 'ipprotocol', default='inet')
values += self.format_cli_field(self.params, 'protocol', default='tcp')
values += self.format_cli_field(self.params, 'source')
values += self.format_cli_field(self.params, 'destination')
Expand All @@ -406,6 +409,7 @@ def _log_fields(self, before=None):
values += self.format_updated_cli_field(self.obj, before, 'disabled', fvalue=self.fvalue_bool, default=False, add_comma=(values))
values += self.format_updated_cli_field(self.obj, before, 'nordr', fvalue=self.fvalue_bool, default=False, add_comma=(values))
values += self.format_updated_cli_field(fafter, fbefore, 'interface', add_comma=(values))
values += self.format_updated_cli_field(self.obj, before, 'ipprotocol', add_comma=(values))
values += self.format_updated_cli_field(self.obj, before, 'protocol', fvalue=self.fprotocol, add_comma=(values))
values += self.format_updated_cli_field(fafter, fbefore, 'source', add_comma=(values))
values += self.format_updated_cli_field(fafter, fbefore, 'destination', add_comma=(values))
Expand Down
5 changes: 5 additions & 0 deletions plugins/modules/pfsense_aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,11 @@
description: The interface for the rule
required: false
type: str
ipprotocol:
description: The IP protocol
default: inet
choices: [ "inet", "inet6" ]
type: str
protocol:
description: Which protocol this rule should match.
default: tcp
Expand Down
6 changes: 6 additions & 0 deletions plugins/modules/pfsense_nat_port_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-

# Copyright: (c) 2019, Frederic Bor <frederic.bor@wanadoo.fr>
# Copyright: (c) 2023, Orion Poplawski <orion@nwra.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

from __future__ import absolute_import, division, print_function
Expand Down Expand Up @@ -38,6 +39,11 @@
description: The interface for the rule
required: false
type: str
ipprotocol:
description: The IP protocol
default: inet
choices: [ "inet", "inet6" ]
type: str
protocol:
description: Which protocol this rule should match.
default: tcp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@
<network>wanip</network>
<port>22022</port>
</destination>
<ipprotocol>inet</ipprotocol>
<protocol>tcp</protocol>
<target>10.255.1.20</target>
<local-port>22</local-port>
Expand All @@ -291,6 +292,7 @@
<network>wanip</network>
<port>22022</port>
</destination>
<ipprotocol>inet</ipprotocol>
<protocol>tcp</protocol>
<target>10.255.1.20</target>
<local-port>22</local-port>
Expand All @@ -314,6 +316,7 @@
<network>wanip</network>
<port>22022</port>
</destination>
<ipprotocol>inet</ipprotocol>
<protocol>tcp</protocol>
<target>10.255.1.20</target>
<local-port>22</local-port>
Expand All @@ -339,6 +342,7 @@
<network>wanip</network>
<port>22022</port>
</destination>
<ipprotocol>inet</ipprotocol>
<protocol>tcp</protocol>
<interface>wan</interface>
<descr>NAT last</descr>
Expand Down Expand Up @@ -375,6 +379,7 @@
<username></username>
<time>1545574416</time>
</updated>
<ipprotocol>inet</ipprotocol>
<protocol>tcp</protocol>
<descr>test_rule</descr>
<created>
Expand All @@ -399,6 +404,7 @@
<username></username>
<time>1545574416</time>
</updated>
<ipprotocol>inet</ipprotocol>
<protocol>tcp</protocol>
<log></log>
<descr>test_rule_2</descr>
Expand All @@ -424,6 +430,7 @@
<username></username>
<time>1545574416</time>
</updated>
<ipprotocol>inet</ipprotocol>
<protocol>tcp</protocol>
<descr>test_lan_100_1</descr>
<created>
Expand All @@ -449,6 +456,7 @@
<username></username>
<time>1545574416</time>
</updated>
<ipprotocol>inet</ipprotocol>
<protocol>tcp</protocol>
<descr>test_lan_100_2</descr>
<created>
Expand All @@ -475,6 +483,7 @@
<username></username>
<time>1545574416</time>
</updated>
<ipprotocol>inet</ipprotocol>
<protocol>tcp</protocol>
<descr>test_lan_100_3</descr>
<created>
Expand All @@ -500,6 +509,7 @@
<username></username>
<time>1545574416</time>
</updated>
<ipprotocol>inet</ipprotocol>
<protocol>tcp</protocol>
<descr>test_lan_100_4</descr>
<created>
Expand All @@ -526,6 +536,7 @@
<username></username>
<time>1545574416</time>
</updated>
<ipprotocol>inet</ipprotocol>
<protocol>tcp</protocol>
<descr>test_lan_100_5</descr>
<created>
Expand All @@ -551,6 +562,7 @@
<username></username>
<time>1545574416</time>
</updated>
<ipprotocol>inet</ipprotocol>
<protocol>tcp</protocol>
<descr>test_rule_3</descr>
<created>
Expand All @@ -576,6 +588,7 @@
<username></username>
<time>1545574416</time>
</updated>
<ipprotocol>inet</ipprotocol>
<protocol>tcp</protocol>
<descr>antilock_out_3</descr>
<created>
Expand All @@ -601,6 +614,7 @@
<username>fbor</username>
<time>1545907554</time>
</updated>
<ipprotocol>inet</ipprotocol>
<protocol>tcp</protocol>
<descr>test_rule_floating</descr>
<created>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def check_target_elt(self, obj, target_elt, target_idx=-1):
self.check_param_equal_or_not_find(obj, target_elt, 'natreflection', not_find_val='system-default')

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_rule_idx(obj, target_idx)
Expand Down

0 comments on commit 0ffd133

Please sign in to comment.