File tree 4 files changed +54
-1
lines changed
controllers/OPNsense/CaptivePortal/forms
models/OPNsense/CaptivePortal
service/templates/OPNsense/IPFW
4 files changed +54
-1
lines changed Original file line number Diff line number Diff line change 17
17
<type >select_multiple</type >
18
18
<help ><![CDATA[ Select interface(s) to enable for captive portal.]]> </help >
19
19
</field >
20
+ <field >
21
+ <id >zone.interfaces_inbound</id >
22
+ <label >Allow inbound</label >
23
+ <type >select_multiple</type >
24
+ <help ><![CDATA[
25
+ Select interfaces from which to allow inbound (stateful) traffic. This can be convenient if the zone in question
26
+ contains machines/servers which should be accessible from other networks attached to this firewall.
27
+ ]]> </help >
28
+ </field >
20
29
<field >
21
30
<id >zone.authservers</id >
22
31
<label >Authenticate using</label >
Original file line number Diff line number Diff line change 31
31
namespace OPNsense \CaptivePortal ;
32
32
33
33
use OPNsense \Base \BaseModel ;
34
+ use OPNsense \Base \Messages \Message ;
34
35
35
36
/**
36
37
* Class CaptivePortal
@@ -84,4 +85,35 @@ public function getTemplateByName($name)
84
85
$ newItem ->fileid = uniqid ();
85
86
return $ newItem ;
86
87
}
88
+ /**
89
+ * {@inheritdoc}
90
+ */
91
+ public function performValidation ($ validateFullModel = false )
92
+ {
93
+ $ messages = parent ::performValidation ($ validateFullModel );
94
+ // validate changed instances
95
+ foreach ($ this ->zones ->zone ->iterateItems () as $ zone ) {
96
+ if (!$ validateFullModel && !$ zone ->isFieldChanged ()) {
97
+ continue ;
98
+ }
99
+ $ key = $ zone ->__reference ;
100
+ if (!empty ((string )$ zone ->interfaces_inbound ) && !empty ((string )$ zone ->interfaces )) {
101
+ $ ifs_inbound = array_filter (explode (', ' , $ zone ->interfaces_inbound ));
102
+ $ ifs = array_filter (explode (', ' , $ zone ->interfaces ));
103
+ $ overlap = array_intersect ($ ifs_inbound , $ ifs );
104
+ if (!empty ($ overlap )) {
105
+ $ messages ->appendMessage (
106
+ new Message (
107
+ sprintf (
108
+ gettext ("Inbound interfaces may not overlap with zone interfaces (%s) " ),
109
+ implode (', ' , $ overlap )
110
+ ),
111
+ $ key . ".interfaces_inbound "
112
+ )
113
+ );
114
+ }
115
+ }
116
+ }
117
+ return $ messages ;
118
+ }
87
119
}
Original file line number Diff line number Diff line change 1
1
<model >
2
2
<mount >//OPNsense/captiveportal</mount >
3
- <version >1.0.1 </version >
3
+ <version >1.0.2 </version >
4
4
<description >Captive portal application model</description >
5
5
<items >
6
6
<zones >
25
25
</filters >
26
26
<ValidationMessage >At least one interface must be selected</ValidationMessage >
27
27
</interfaces >
28
+ <interfaces_inbound type =" InterfaceField" >
29
+ <Multiple >Y</Multiple >
30
+ <filters >
31
+ <enable >/^(?!0).*$/</enable >
32
+ </filters >
33
+ </interfaces_inbound >
28
34
<authservers type =" AuthenticationServerField" >
29
35
<Multiple >Y</Multiple >
30
36
</authservers >
Original file line number Diff line number Diff line change @@ -116,6 +116,12 @@ add {{loop.index + 1000}} skipto 60000 icmp from any to { 255.255.255.255 or me
116
116
{# authenticated clients #}
117
117
add {{3000 + item.zoneid|int }} skipto tablearg ip from table({{item.zoneid|int}}) to any via {{item.if}}
118
118
add {{3000 + item.zoneid|int }} skipto tablearg ip from any to table({{item.zoneid|int}}) via {{item.if}}
119
+ # Allowed traffic heading into this zone #
120
+ {% if item.obj.interfaces_inbound|default('') != '' %}
121
+ {% for inbound_if in item.obj.interfaces_inbound.split(',') if helpers.physical_interface(inbound_if)%}
122
+ add {{3000 + item.zoneid|int }} skipto 60000 ip from any to any recv {{helpers.physical_interface(inbound_if)}} xmit {{item.if}} keep-state
123
+ {% endfor %}
124
+ {% endif %}
119
125
{% endfor %}
120
126
121
127
You can’t perform that action at this time.
0 commit comments