1
|
<?php
|
2
|
/*
|
3
|
* services_igmpproxy.php
|
4
|
*
|
5
|
* part of pfSense (https://www.pfsense.org)
|
6
|
* Copyright (c) 2004-2013 BSD Perimeter
|
7
|
* Copyright (c) 2013-2016 Electric Sheep Fencing
|
8
|
* Copyright (c) 2014-2024 Rubicon Communications, LLC (Netgate)
|
9
|
* All rights reserved.
|
10
|
*
|
11
|
* originally based on m0n0wall (http://m0n0.ch/wall)
|
12
|
* Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
13
|
* All rights reserved.
|
14
|
*
|
15
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
16
|
* you may not use this file except in compliance with the License.
|
17
|
* You may obtain a copy of the License at
|
18
|
*
|
19
|
* http://www.apache.org/licenses/LICENSE-2.0
|
20
|
*
|
21
|
* Unless required by applicable law or agreed to in writing, software
|
22
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
23
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
24
|
* See the License for the specific language governing permissions and
|
25
|
* limitations under the License.
|
26
|
*/
|
27
|
|
28
|
##|+PRIV
|
29
|
##|*IDENT=page-services-igmpproxy
|
30
|
##|*NAME=Services: IGMP Proxy
|
31
|
##|*DESCR=Allow access to the 'Services: IGMP Proxy' page.
|
32
|
##|*MATCH=services_igmpproxy.php*
|
33
|
##|-PRIV
|
34
|
|
35
|
require_once("guiconfig.inc");
|
36
|
|
37
|
//igmpproxy_sort();
|
38
|
|
39
|
config_init_path('igmpproxy/igmpentry');
|
40
|
|
41
|
if ($_POST['apply']) {
|
42
|
$pconfig = $_POST;
|
43
|
|
44
|
$changes_applied = true;
|
45
|
/* reload all components that use igmpproxy */
|
46
|
if (services_igmpproxy_configure()) {
|
47
|
$retval = 0;
|
48
|
} else {
|
49
|
$retval = 1;
|
50
|
}
|
51
|
|
52
|
clear_subsystem_dirty('igmpproxy');
|
53
|
}
|
54
|
|
55
|
if (config_path_enabled('igmpproxy')) {
|
56
|
$pconfig['enable'] = true;
|
57
|
}
|
58
|
$pconfig['igmpxverbose'] = config_path_enabled('syslog', 'igmpxverbose');
|
59
|
|
60
|
if ($_POST['save']) {
|
61
|
unset($input_errors);
|
62
|
$pconfig = $_POST;
|
63
|
|
64
|
if (isset($pconfig['enable'])) {
|
65
|
foreach (config_get_path('igmpproxy/igmpentry', []) as $igmpcf) {
|
66
|
if ($igmpcf['type'] == 'upstream') {
|
67
|
$upstream = true;
|
68
|
} else {
|
69
|
$downstream = true;
|
70
|
}
|
71
|
}
|
72
|
if (!$upstream || !$downstream) {
|
73
|
$input_errors[] = gettext("At least one upstream and one downstream interface must be added.");
|
74
|
}
|
75
|
}
|
76
|
|
77
|
if (!$input_errors) {
|
78
|
if (isset($pconfig['enable'])) {
|
79
|
config_set_path('igmpproxy/enable', true);
|
80
|
} else {
|
81
|
config_del_path('igmpproxy/enable');
|
82
|
}
|
83
|
config_set_path('syslog/igmpxverbose', $_POST['igmpxverbose'] ? true : false);
|
84
|
write_config("IGMP Proxy settings saved");
|
85
|
mark_subsystem_dirty('igmpproxy');
|
86
|
header("Location: services_igmpproxy.php");
|
87
|
exit;
|
88
|
}
|
89
|
}
|
90
|
|
91
|
if ($_POST['act'] == "del") {
|
92
|
if (config_get_path("igmpproxy/igmpentry/{$_POST['id']}")) {
|
93
|
config_del_path("igmpproxy/igmpentry/{$_POST['id']}");
|
94
|
write_config("IGMP Proxy item deleted");
|
95
|
mark_subsystem_dirty('igmpproxy');
|
96
|
header("Location: services_igmpproxy.php");
|
97
|
exit;
|
98
|
}
|
99
|
}
|
100
|
|
101
|
$pgtitle = array(gettext("Services"), gettext("IGMP Proxy"));
|
102
|
include("head.inc");
|
103
|
|
104
|
if ($input_errors) {
|
105
|
print_input_errors($input_errors);
|
106
|
}
|
107
|
|
108
|
if ($changes_applied) {
|
109
|
print_apply_result_box($retval);
|
110
|
}
|
111
|
|
112
|
if (is_subsystem_dirty('igmpproxy')) {
|
113
|
print_apply_box(gettext('The IGMP entry list has been changed.') . '<br />' . gettext('The changes must be applied for them to take effect.'));
|
114
|
}
|
115
|
?>
|
116
|
|
117
|
<?php
|
118
|
|
119
|
$form = new Form();
|
120
|
|
121
|
$section = new Form_Section('General IGMP Options');
|
122
|
|
123
|
$section->addInput(new Form_Checkbox(
|
124
|
'enable',
|
125
|
'Enable',
|
126
|
'Enable IGMP',
|
127
|
$pconfig['enable']
|
128
|
));
|
129
|
|
130
|
$section->addInput(new Form_Checkbox(
|
131
|
'igmpxverbose',
|
132
|
'Verbose Logging',
|
133
|
'Enable verbose logging (Default is terse logging)',
|
134
|
$pconfig['igmpxverbose']
|
135
|
));
|
136
|
|
137
|
$form->add($section);
|
138
|
|
139
|
print($form);
|
140
|
|
141
|
?>
|
142
|
<form action="services_igmpproxy.php" method="post">
|
143
|
<div class="panel panel-default">
|
144
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext('IGMP Proxy')?></h2></div>
|
145
|
<div class="panel-body">
|
146
|
<div class="table-responsive">
|
147
|
<table class="table table-striped table-hover table-condensed table-rowdblclickedit">
|
148
|
<thead>
|
149
|
<tr>
|
150
|
<th><?=gettext("Name")?></th>
|
151
|
<th><?=gettext("Type")?></th>
|
152
|
<th><?=gettext("Values")?></th>
|
153
|
<th><?=gettext("Description")?></th>
|
154
|
<th><?=gettext("Actions")?></th>
|
155
|
</tr>
|
156
|
</thead>
|
157
|
<tbody>
|
158
|
<?php
|
159
|
$i = 0;
|
160
|
foreach (config_get_path('igmpproxy/igmpentry', []) as $igmpentry):
|
161
|
?>
|
162
|
<tr>
|
163
|
<td>
|
164
|
<?=htmlspecialchars(convert_friendly_interface_to_friendly_descr($igmpentry['ifname']))?>
|
165
|
</td>
|
166
|
<td>
|
167
|
<?=htmlspecialchars($igmpentry['type'])?>
|
168
|
</td>
|
169
|
<td>
|
170
|
<?php
|
171
|
$addresses = implode(", ", array_slice(explode(" ", $igmpentry['address']), 0, 10));
|
172
|
print(htmlspecialchars($addresses));
|
173
|
|
174
|
if (!is_array($igmpentry['address']) || count($igmpentry['address']) < 10) {
|
175
|
print(' ');
|
176
|
} else {
|
177
|
print('...');
|
178
|
}
|
179
|
?>
|
180
|
</td>
|
181
|
<td>
|
182
|
<?=htmlspecialchars($igmpentry['descr'])?>
|
183
|
</td>
|
184
|
<td>
|
185
|
<a class="fa-solid fa-pencil" title="<?=gettext('Edit IGMP entry')?>" href="services_igmpproxy_edit.php?id=<?=$i?>"></a>
|
186
|
<a class="fa-solid fa-trash-can" title="<?=gettext('Delete IGMP entry')?>" href="services_igmpproxy.php?act=del&id=<?=$i?>" usepost></a>
|
187
|
</td>
|
188
|
</tr>
|
189
|
<?php
|
190
|
$i++;
|
191
|
endforeach;
|
192
|
?>
|
193
|
</tbody>
|
194
|
</table>
|
195
|
</div>
|
196
|
</div>
|
197
|
</div>
|
198
|
</form>
|
199
|
|
200
|
<nav class="action-buttons">
|
201
|
<a href="services_igmpproxy_edit.php" class="btn btn-success btn-sm">
|
202
|
<i class="fa-solid fa-plus icon-embed-btn"></i>
|
203
|
<?=gettext('Add')?>
|
204
|
</a>
|
205
|
</nav>
|
206
|
|
207
|
<div class="infoblock">
|
208
|
<?php print_info_box(gettext('Please add the interface for upstream, the allowed subnets, and the downstream interfaces for the proxy to allow. ' .
|
209
|
'Only one "upstream" interface can be configured.'), 'info', false); ?>
|
210
|
</div>
|
211
|
<?php
|
212
|
include("foot.inc");
|