Skip to content

Commit

Permalink
Firewall: Automation: Filter - add 'statetimeout' and validations for #…
Browse files Browse the repository at this point in the history
…8143

Although this component is mainly used for api access, experiment a bit further with the inpu dialog as well.
  • Loading branch information
AdSchellevis committed Dec 24, 2024
1 parent 3cbea52 commit d07e3c6
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,8 @@
<help>Log packets that are handled by this rule</help>
</field>
<field>
<id>rule.nopfsync</id>
<label>NO pfsync</label>
<type>checkbox</type>
<help>Hint: This prevents states created by this rule to be sync'ed over pfsync.</help>
<type>header</type>
<label>Stateful firewall</label>
</field>
<field>
<id>rule.statetype</id>
Expand All @@ -149,6 +147,19 @@
Interface bound states are more secure, floating more flexible
</help>
</field>
<field>
<id>rule.statetimeout</id>
<label>State timeout</label>
<type>text</type>
<help>State Timeout in seconds (TCP only)</help>
<advanced>true</advanced>
</field>
<field>
<id>rule.nopfsync</id>
<label>NO pfsync</label>
<type>checkbox</type>
<help>Hint: This prevents states created by this rule to be sync'ed over pfsync.</help>
</field>
<field>
<type>header</type>
<label>Source routing</label>
Expand Down
12 changes: 12 additions & 0 deletions src/opnsense/mvc/app/models/OPNsense/Firewall/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,18 @@ public function performValidation($validateFullModel = false)
$rule->interfacenot->__reference
));
}
if ($rule->statetype == 'none' && !empty((string)$rule->statetimeout)) {
$messages->appendMessage(new Message(
gettext("You cannot specify the state timeout (advanced option) if statetype is none."),
$rule->statetimeout->__reference
));
}
if (!in_array($rule->protocol, ['TCP', 'TCP/UDP']) && !empty((string)$rule->statetimeout)) {
$messages->appendMessage(new Message(
gettext("You can only specify the state timeout (advanced option) for TCP protocol."),
$rule->statetimeout->__reference
));
}
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/opnsense/mvc/app/models/OPNsense/Firewall/Filter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@
<Default>0</Default>
<Required>Y</Required>
</nopfsync>
<statetimeout type="IntegerField">
<MinimumValue>1</MinimumValue>
<MaximumValue>65536</MaximumValue>
</statetimeout>
<categories type="ModelRelationField">
<Model>
<rulesets>
Expand Down

0 comments on commit d07e3c6

Please sign in to comment.